本文整理汇总了PHP中XPClass::getComment方法的典型用法代码示例。如果您正苦于以下问题:PHP XPClass::getComment方法的具体用法?PHP XPClass::getComment怎么用?PHP XPClass::getComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPClass
的用法示例。
在下文中一共展示了XPClass::getComment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Main
*
* @param string[] $args
* @return int
*/
public static function main(array $args)
{
$command = null;
if (empty($args)) {
$class = new XPClass(self::class);
$source = $class->getClassLoader();
$markdown = $class->getComment();
} else {
if ('@' === $args[0][0]) {
$resource = substr($args[0], 1);
if (null === ($source = ClassLoader::getDefault()->findResource($resource))) {
Console::$err->writeLine('No help topic named ', $resource);
return 2;
}
$markdown = $source->getResource($resource);
} else {
$class = $args[0];
if (null === ($source = ClassLoader::getDefault()->findClass($class))) {
Console::$err->writeLine('No class named ', $class);
return 2;
}
$markdown = $source->loadClass($class)->getComment();
}
}
self::render(Console::$out, $markdown, $source);
return 1;
}
示例2: showUsage
/**
* Show usage
*
* @param lang.XPClass class
*/
public static function showUsage(XPClass $class)
{
// Description
if (NULL !== ($comment = $class->getComment())) {
self::$err->writeLine(self::textOf($comment));
self::$err->writeLine(str_repeat('=', 72));
}
$extra = $details = $positional = array();
foreach ($class->getMethods() as $method) {
if (!$method->hasAnnotation('arg')) {
continue;
}
$arg = $method->getAnnotation('arg');
$name = strtolower(preg_replace('/^set/', '', $method->getName()));
$comment = self::textOf($method->getComment());
if (0 == $method->numParameters()) {
$optional = TRUE;
} else {
list($first, ) = $method->getParameters();
$optional = $first->isOptional();
}
if (isset($arg['position'])) {
$details['#' . ($arg['position'] + 1)] = $comment;
$positional[$arg['position']] = $name;
} else {
if (isset($arg['name'])) {
$details['--' . $arg['name'] . ' | -' . (isset($arg['short']) ? $arg['short'] : $arg['name'][0])] = $comment;
$extra[$arg['name']] = $optional;
} else {
$details['--' . $name . ' | -' . (isset($arg['short']) ? $arg['short'] : $name[0])] = $comment;
$extra[$name] = $optional;
}
}
}
// Usage
asort($positional);
self::$err->write('Usage: $ xpcli ', $class->getName(), ' ');
foreach ($positional as $name) {
self::$err->write('<', $name, '> ');
}
foreach ($extra as $name => $optional) {
self::$err->write($optional ? '[' : '', '--', $name, $optional ? '] ' : ' ');
}
self::$err->writeLine();
// Argument details
self::$err->writeLine('Arguments:');
foreach ($details as $which => $comment) {
self::$err->writeLine('* ', $which, "\n ", str_replace("\n", "\n ", $comment), "\n");
}
}
示例3: usage
/**
* Displays usage
*
* @param lang.XPClass class
* @return int
*/
protected static function usage(XPClass $class)
{
Console::$err->writeLine(self::textOf($class->getComment()));
return 1;
}