本文整理汇总了PHP中phpDocumentor\Reflection\DocBlock::getShortDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP DocBlock::getShortDescription方法的具体用法?PHP DocBlock::getShortDescription怎么用?PHP DocBlock::getShortDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpDocumentor\Reflection\DocBlock
的用法示例。
在下文中一共展示了DocBlock::getShortDescription方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addDescription
/**
* Adds the short description of $docblock to the given node as description
* field.
*
* @param \DOMElement $node
* @param DocBlock $docblock
*
* @return void
*/
protected function addDescription(\DOMElement $node, DocBlock $docblock)
{
$cdata = $node->ownerDocument->createCDATASection($docblock->getShortDescription());
$description = new \DOMElement('description');
$node->appendChild($description);
$description->appendChild($cdata);
}
示例2: configure
protected function configure()
{
$reflection = new \ReflectionClass(get_called_class());
$baseNamespaceChunks = [];
foreach (explode('\\', $reflection->getNamespaceName()) as $namespaceChunk) {
$baseNamespaceChunks[] = $namespaceChunk;
if ($namespaceChunk == consoleBase::COMMANDS_DIRECTORY) {
break;
}
}
$namespace = str_replace(implode('\\', $baseNamespaceChunks), '', get_called_class());
$namespace = trim($namespace, '\\');
$commandNameData = explode('\\', $namespace);
$phpdoc = new DocBlock($reflection);
/** @var DocBlock\Tag $tag */
$tag = reset($phpdoc->getTagsByName('consoleNs'));
$commandNameValues = [];
if ($tag) {
$consoleNs = trim($tag->getDescription());
if (!empty($consoleNs)) {
$commandNameValues[] = $consoleNs;
}
}
foreach ($commandNameData as $commandNameValue) {
$commandNameValues[] = $commandNameValue;
}
$this->setName(implode(':', $commandNameValues))->setDescription($phpdoc->getShortDescription())->setHelp($phpdoc->getLongDescription());
$this->defineArguments();
}
示例3: addDescription
protected function addDescription(\DOMElement $child, \phpDocumentor\Reflection\DocBlock $docblock)
{
$node = $child->ownerDocument->createCDATASection($docblock->getShortDescription());
$description = new \DOMElement('description');
$child->appendChild($description);
$description->appendChild($node);
}
示例4: parse
/**
* Parse the docBlock comment for this command, and set the
* fields of this class with the data thereby obtained.
*/
public function parse()
{
$docblockComment = $this->reflection->getDocComment();
$phpdoc = new DocBlock($docblockComment);
// First set the description (synopsis) and help.
$this->commandInfo->setDescription((string) $phpdoc->getShortDescription());
$this->commandInfo->setHelp((string) $phpdoc->getLongDescription());
$this->processAllTags($phpdoc);
}
示例5: getMethodDesc
public function getMethodDesc($methodName)
{
if (!$this->reflection->hasMethod($methodName)) {
return null;
}
$docComment = $this->reflection->getMethod($methodName)->getDocComment();
if ($docComment) {
$docBlock = new DocBlock($docComment);
return join(' ', [$docBlock->getShortDescription(), $docBlock->getLongDescription()]);
}
return null;
}
示例6: parsePropertyDocBlock
/**
*
* @param ReflectionProperty $reflector
* @return ParsePropertyBlockResult
*/
public function parsePropertyDocBlock(ReflectionProperty $reflector)
{
$phpdoc = new DocBlock($reflector->getDocComment());
/* @var $varTags VarTag[] */
$varTags = $phpdoc->getTagsByName("var");
/* @var $varTag VarTag */
$varTag = $varTags[0];
$result = new ParsePropertyBlockResult();
$result->description = $phpdoc->getShortDescription();
$result->type = (string) $varTag->getType();
return $result;
}
示例7: getMethodsDetails
public function getMethodsDetails()
{
$methods = [];
foreach ($this->reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
$docblock = new DocBlock($method);
$data = ['shortDescription' => $docblock->getShortDescription(), 'longDescription' => $docblock->getLongDescription(), 'argumentsList' => $this->retriveParams($docblock->getTagsByName('param')), 'argumentsDescription' => $this->retriveParamsDescription($docblock->getTagsByName('param')), 'returnValue' => $this->retriveReturnValue($docblock->getTagsByName('return')), 'visibility' => join('', [$method->isFinal() ? 'final ' : '', 'public', $method->isStatic() ? ' static' : ''])];
if (strlen($data['shortDescription'])) {
$methods[$method->getName()] = (object) $data;
}
}
return $methods;
}
示例8: parseClass
/**
* @param $doc
* @return bool
*/
public function parseClass(ControllerDoc $doc)
{
if (!($docBlock = new DocBlock($this->reflection))) {
return false;
}
$doc->longDescription = $docBlock->getLongDescription()->getContents();
$doc->shortDescription = $docBlock->getShortDescription();
$doc->populateTags($docBlock);
if (DocBlockHelper::isInherit($docBlock)) {
$parentParser = $this->getParentParser();
$parentParser->parseClass($doc);
}
}
示例9: extractAction
/**
* {@inheritDoc}
*/
public function extractAction(ActionInterface $action)
{
$callable = $this->callableResolver->resolve($action);
if ($this->parameterExtractor) {
$parameters = $this->parameterExtractor->extract($action, $callable);
} else {
$parameters = [];
}
$reflection = $callable->getReflection();
$docBlock = new DocBlock($reflection);
$description = $docBlock->getShortDescription();
$actionDoc = new Action($action->getName(), $description, $parameters);
return $actionDoc;
}
示例10: assembleDocBlock
/**
* Assemble DocBlock.
*
* @param DocBlock|null $docBlock
* @param DescriptorAbstract $target
*
* @return void
*/
protected function assembleDocBlock($docBlock, $target)
{
if (!$docBlock) {
return;
}
$target->setSummary($docBlock->getShortDescription());
$target->setDescription($docBlock->getLongDescription()->getContents());
/** @var DocBlock\Tag $tag */
foreach ($docBlock->getTags() as $tag) {
$tagDescriptor = $this->builder->buildDescriptor($tag);
// allow filtering of tags
if (!$tagDescriptor) {
continue;
}
$target->getTags()->get($tag->getName(), new Collection())->add($tagDescriptor);
}
}
示例11: getEndpoints
/**
* Returns an array of endpoints
*
* @return array
*/
protected function getEndpoints()
{
$endpoints = [];
foreach ($this->routes as $route) {
$array = explode("@", $route['action']);
$class = $array[0];
if ($class == "Closure") {
// check for api/v1/docs
if (strpos($route['uri'], $this->prefix . '/docs') !== false) {
continue;
}
}
$reflector = new ReflectionClass($class);
$docBlock = new DocBlock($reflector);
// remove Controller
$class = str_replace('Controller', '', $class);
$endpoints["{$class}"]['methods'] = [];
$endpoints["{$class}"]['description'] = $docBlock->getShortDescription();
}
return $this->getEndpointMethods($endpoints);
}
示例12: parse
public function parse($comment, ParserContext $context)
{
$docBlock = null;
$errorMessage = '';
try {
$docBlockContext = new DocBlock\Context($context->getNamespace(), $context->getAliases() ?: array());
$docBlock = new DocBlock((string) $comment, $docBlockContext);
} catch (\Exception $e) {
$errorMessage = $e->getMessage();
}
$result = new DocBlockNode();
if ($errorMessage) {
$result->addError($errorMessage);
return $result;
}
$result->setShortDesc($docBlock->getShortDescription());
$result->setLongDesc((string) $docBlock->getLongDescription());
foreach ($docBlock->getTags() as $tag) {
$result->addTag($tag->getName(), $this->parseTag($tag));
}
return $result;
}
示例13: fetchMethod
public function fetchMethod($className, $method)
{
$phpdoc = new DocBlock($method->getDocComment());
$call = array();
$params = array();
$return = null;
// build the call example string
foreach ($method->getParameters() as $param) {
if ($param->isOptional()) {
try {
$value = var_export($param->getDefaultValue(), true);
$value = str_replace(PHP_EOL, '', $value);
$value = str_replace('NULL', 'null', $value);
$value = str_replace('array ()', 'array()', $value);
$call[] = '$' . $param->getName() . ' = ' . $value;
} catch (Exception $e) {
$call[] = '$' . $param->getName();
}
} else {
$call[] = '$' . $param->getName();
}
}
// get all parameter docs
foreach ($phpdoc->getTags() as $tag) {
switch ($tag->getName()) {
case 'param':
$params[] = array('name' => $tag->getVariableName(), 'type' => $tag->getType(), 'text' => $tag->getDescription());
break;
case 'return':
$return = array('type' => $tag->getType(), 'text' => $tag->getDescription());
break;
}
}
// a::first
$methodName = strtolower($className) . '::' . $method->getName();
$methodSlug = str::slug($method->getName());
// build the full method array
return array('name' => $methodName, 'slug' => $methodSlug, 'excerpt' => str_replace(PHP_EOL, ' ', $phpdoc->getShortDescription()), 'call' => $methodName . '(' . implode(', ', $call) . ')', 'return' => $return, 'params' => $params);
}
示例14: findSummary
protected function findSummary(\ReflectionClass $scopeClass, \ReflectionMethod $scopeMethod, Language $lang = null, &$alreadyScopedClasses = array())
{
foreach ($alreadyScopedClasses as $sc) {
/* @var \ReflectionClass $sc */
if ($sc->getName() === $scopeClass->getName()) {
return null;
}
}
$alreadyScopedClasses[] = $scopeClass;
$doc = new DocBlock($scopeMethod);
$result = $doc->getShortDescription();
if ('{@inheritdoc}' === \trim(\strtolower($result))) {
$result = null;
$typesToCheck = \array_merge($scopeClass->getTraits(), [$scopeClass->getParentClass()], $scopeClass->getInterfaces());
foreach ($typesToCheck as $type) {
if (!$type instanceof \ReflectionClass) {
continue;
}
$matchingMethod = null;
foreach ($type->getMethods() as $otherMethod) {
if ($otherMethod->getName() !== $scopeMethod->getName()) {
continue;
}
$matchingMethod = $otherMethod;
}
if (!$matchingMethod instanceof \ReflectionMethod) {
continue;
}
$summary = \trim($this->findSummary($type, $matchingMethod, $lang, $alreadyScopedClasses));
if ('' !== $summary) {
$result = $summary;
}
}
}
$result = \trim($result);
return '' !== $result ? $result : null;
}
示例15: extractParameters
/**
* @param string $class
* @param array $processed
*
* @return array
*/
private function extractParameters($class, $processed = [])
{
if (isset($processed[$class])) {
return [];
}
$processed[$class] = true;
$reflectionClass = new \ReflectionClass($class);
$parameters = [];
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
$type = $this->determinePropertyType($reflectionProperty);
$isCollection = false;
if ($extractedType = $this->typeResolver->extractTypeFromCollectionType($type)) {
$isCollection = true;
$type = $extractedType;
}
$docBlock = new DocBlock($reflectionProperty);
$parameter = ['name' => $reflectionProperty->getName(), 'description' => $docBlock->getShortDescription(), 'type' => $type . ($isCollection ? '[]' : '')];
if (class_exists($type)) {
$parameter = array_merge($parameter, ['type' => 'object' . ($isCollection ? '[]' : ''), 'properties' => $this->extractParameters($type, $processed)]);
}
$parameters[] = $parameter;
}
return $parameters;
}