当前位置: 首页>>代码示例>>PHP>>正文


PHP Reflection\DocBlock类代码示例

本文整理汇总了PHP中phpDocumentor\Reflection\DocBlock的典型用法代码示例。如果您正苦于以下问题:PHP DocBlock类的具体用法?PHP DocBlock怎么用?PHP DocBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DocBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: docblock

 /**
  * Generate docblock.
  *
  * @param string $class
  * @param array $properties
  * @param array $methods
  * @return mixed
  */
 public function docblock($class, $properties, $methods)
 {
     $phpdoc = new DocBlock('');
     $phpdoc->setText($class);
     foreach ($properties as $property) {
         $tag = Tag::createInstance("@{$property['type']} {$property['return']} {$property['name']}", $phpdoc);
         $phpdoc->appendTag($tag);
     }
     foreach ($methods as $method) {
         $tag = Tag::createInstance("@method {$method['type']} {$method['return']} {$method['name']}({$method['arguments']})", $phpdoc);
         $phpdoc->appendTag($tag);
     }
     $serializer = new DocBlockSerializer();
     $docComment = $serializer->getDocComment($phpdoc);
     return $docComment;
 }
开发者ID:bebnev,项目名称:laravel-schema-parser,代码行数:24,代码来源:Grammar.php

示例2: parseDoc

 /**
  * Parses doc comment and populates comment entity
  *
  * @param string $text
  */
 protected function parseDoc(Comment $comment, $text)
 {
     $context = $this->getContext();
     try {
         $block = new DocBlock($text, $context);
         foreach ($block->getTags() as $tag) {
             switch ($tag->getName()) {
                 case "param":
                     $comment->addVar($this->createMethodParam($tag));
                     break;
                 case "var":
                     $comment->addVar($this->createVar($tag));
                     break;
                 case "return":
                     $comment->setReturn($this->getFQCN($tag->getType()));
                     break;
                 case "property":
                     $comment->addProperty($this->createProperty($tag));
                     break;
                 case "inheritdoc":
                     $comment->markInheritDoc();
                     break;
             }
         }
     } catch (\Exception $e) {
     }
 }
开发者ID:nevernet,项目名称:padawan.php,代码行数:32,代码来源:CommentParser.php

示例3: __construct

 /**
  * Constructor
  *
  * @param string             $name     Name of the "entity"
  * @param DocBlock|null      $docblock Docblock
  * @param BaseReflector|null $source   Source Element.
  */
 public function __construct($name, $docblock = null, $source = null)
 {
     $this->entityName = $name;
     $this->lineNumber = $docblock ? $docblock->getLocation()->getLineNumber() : $source->getLineNumber();
     $this->docblock = $docblock;
     $this->source = $source;
 }
开发者ID:michaelyin1,项目名称:Modern-Toolkit,代码行数:14,代码来源:ValidatorAbstract.php

示例4: 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();
 }
开发者ID:mpcmf,项目名称:mpcmf-console,代码行数:29,代码来源:consoleCommandBase.php

示例5: getProperties

 protected function getProperties($propertyName)
 {
     $reflection = new \ReflectionClass($this->model);
     $docBlock = new DocBlock($reflection);
     $properties = $docBlock->getTagsByName($propertyName);
     return $this->buildProperties($properties);
 }
开发者ID:michaelmeelis,项目名称:docblock-model-parser,代码行数:7,代码来源:BasePropertyParser.php

示例6: __construct

 /**
  * Constructor
  *
  * @param \phpDocumentor\Plugin\Plugin            $plugin     Plugin to which this
  *     validator belongs.
  * @param string                                  $name       Name of the "entity"
  * @param \phpDocumentor\Reflection\DocBlock|null $docblock   Docblock
  * @param \phpDocumentor\Reflection\BaseReflector|null  $source     Source Element.
  */
 public function __construct($plugin, $name, $docblock = null, $source = null)
 {
     $this->entityName = $name;
     $this->lineNumber = $docblock ? $docblock->getLocation()->getLineNumber() : $source->getLineNumber();
     $this->docblock = $docblock;
     $this->source = $source;
     parent::__construct($plugin->getEventDispatcher(), $plugin->getConfiguration(), $plugin->getTranslator());
 }
开发者ID:laiello,项目名称:lion-framework,代码行数:17,代码来源:ValidatorAbstract.php

示例7: 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);
 }
开发者ID:consolidation,项目名称:annotated-command,代码行数:13,代码来源:CommandDocBlockParser2.php

示例8: getMethodDecorators

 /**
  * @param string $method
  * @return array
  */
 public function getMethodDecorators($method)
 {
     $reflectionMethod = new \ReflectionMethod($this->getInstance(), $method);
     $docBlock = new DocBlock($reflectionMethod);
     $decorators = [];
     foreach ($docBlock->getTagsByName(static::TAG_NAME) as $tag) {
         $decorators[] = $tag->getContent();
     }
     return $decorators;
 }
开发者ID:marcojetson,项目名称:php-decorators,代码行数:14,代码来源:AnnotationDecorator.php

示例9: extractPackageFromDocBlock

 /**
  * Extracts the package from the DocBlock.
  *
  * @param DocBlock $docBlock
  *
  * @return string|null
  */
 protected function extractPackageFromDocBlock($docBlock)
 {
     $packageTags = $docBlock ? $docBlock->getTagsByName('package') : null;
     if (!$packageTags) {
         return null;
     }
     /** @var DocBlock\Tag $tag */
     $tag = reset($packageTags);
     return trim($tag->getContent());
 }
开发者ID:crazycodr,项目名称:phpDocumentor2,代码行数:17,代码来源:AssemblerAbstract.php

示例10: detectType

 /**
  * @param \ReflectionProperty $reflectionProperty
  *
  * @return string|null
  */
 public function detectType(\ReflectionProperty $reflectionProperty)
 {
     $docBlock = new DocBlock($reflectionProperty->getDocComment());
     $tags = $docBlock->getTagsByName('var');
     if (count($tags) == 0) {
         return null;
     }
     /** @var VarTag $typeTag */
     $typeTag = reset($tags);
     return $typeTag->getType();
 }
开发者ID:tonicforhealth,项目名称:json-rpc,代码行数:16,代码来源:Normalizer.php

示例11: apply

 /**
  * Discover Magical API
  *
  * @param ClassNode $node
  */
 public function apply(ClassNode $node)
 {
     $parentClass = $node->getParentClass();
     $reflectionClass = new \ReflectionClass($parentClass);
     $phpdoc = new DocBlock($reflectionClass->getDocComment());
     $tagList = $phpdoc->getTagsByName('method');
     foreach ($tagList as $tag) {
         $methodNode = new MethodNode($tag->getMethodName());
         $methodNode->setStatic($tag->isStatic());
         $node->addMethod($methodNode);
     }
 }
开发者ID:mawaha,项目名称:tracker,代码行数:17,代码来源:MagicCallPatch.php

示例12: 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;
 }
开发者ID:Kaemmelot,项目名称:php-type-reflection,代码行数:17,代码来源:DocBlockParser.php

示例13: 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);
     }
 }
开发者ID:EvgenyGavrilov,项目名称:yii2-rest-doc,代码行数:17,代码来源:ControllerParser.php

示例14: __invoke

 /**
  * Given a property, attempt to find the type of the property.
  *
  * @param ReflectionProperty $reflectionProperty
  * @return Type[]
  */
 public function __invoke(ReflectionProperty $reflectionProperty)
 {
     $contextFactory = new ContextFactory();
     $context = $contextFactory->createForNamespace($reflectionProperty->getDeclaringClass()->getNamespaceName(), $reflectionProperty->getDeclaringClass()->getLocatedSource()->getSource());
     $docBlock = new DocBlock($reflectionProperty->getDocComment(), new DocBlock\Context($context->getNamespace(), $context->getNamespaceAliases()));
     /* @var \phpDocumentor\Reflection\DocBlock\Tag\VarTag $varTag */
     $resolvedTypes = [];
     $varTags = $docBlock->getTagsByName('var');
     foreach ($varTags as $varTag) {
         $resolvedTypes = array_merge($resolvedTypes, (new ResolveTypes())->__invoke($varTag->getTypes(), $context));
     }
     return $resolvedTypes;
 }
开发者ID:AydinHassan,项目名称:BetterReflection,代码行数:19,代码来源:FindPropertyType.php

示例15: __invoke

 /**
  * Given a function and parameter, attempt to find the type of the parameter.
  *
  * @param ReflectionFunctionAbstract $function
  * @param ParamNode $node
  * @return Type[]
  */
 public function __invoke(ReflectionFunctionAbstract $function, ParamNode $node)
 {
     $context = $this->createContextForFunction($function);
     $docBlock = new DocBlock($function->getDocComment(), new DocBlock\Context($context->getNamespace(), $context->getNamespaceAliases()));
     $paramTags = $docBlock->getTagsByName('param');
     foreach ($paramTags as $paramTag) {
         /* @var $paramTag \phpDocumentor\Reflection\DocBlock\Tag\ParamTag */
         if ($paramTag->getVariableName() === '$' . $node->name) {
             return (new ResolveTypes())->__invoke($paramTag->getTypes(), $context);
         }
     }
     return [];
 }
开发者ID:AydinHassan,项目名称:BetterReflection,代码行数:20,代码来源:FindParameterType.php


注:本文中的phpDocumentor\Reflection\DocBlock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。