本文整理汇总了PHP中ShellDispatcher::find方法的典型用法代码示例。如果您正苦于以下问题:PHP ShellDispatcher::find方法的具体用法?PHP ShellDispatcher::find怎么用?PHP ShellDispatcher::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShellDispatcher
的用法示例。
在下文中一共展示了ShellDispatcher::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Displays detailed help about a HeavyMetal shell command.
*
* @usage ./metal help your/command/uri
* @param $uri The URI of the shell command to display help about.
*/
public function index($uri)
{
try {
try {
$s = new ShellDispatcher($uri);
$f = $s->find();
} catch (Exception $ex) {
$s = new SysShellDispatcher($uri);
$f = $s->find();
}
} catch (Exception $ex) {
vomit($ex->getTrace());
echo "Could not find a suitable controller for {$uri} - are you sure you got it right?";
}
$method = new ReflectionMethod($f['classname'], $f['found_action']);
$help = $method->getDocComment();
$help = explode("\n", $help);
$description = '';
$switches = array();
$params = array();
$usage = '';
foreach ($help as $line) {
if (strpos(trim($line, "\t \n"), '/**') === FALSE && strpos(trim($line, "\t \n"), '*/') === FALSE) {
$line = trim($line, "\t* ");
if (strpos($line, '@') === FALSE) {
$description .= $line;
} else {
if (strpos($line, '@usage') === 0) {
$usage = substr($line, 6);
} else {
$matches = array();
preg_match_all('#([@a-z0-9]*) ([$a-z0-9]*) (.*)#', $line, $matches);
switch ($matches[1][0]) {
case '@switch':
$switches[$matches[2][0]] = $matches[3][0];
break;
case '@param':
$params[trim($matches[2][0], '$')] = $matches[3][0];
break;
}
}
}
}
}
return array('description' => $description, 'usage' => $usage, 'switches' => $switches, 'params' => $params);
}