yii\apidoc\models\BaseDoc::__construct PHP Метод

__construct() публичный Метод

public __construct ( phpDocumentor\Reflection\BaseReflector $reflector = null, Context $context = null, array $config = [] )
$reflector phpDocumentor\Reflection\BaseReflector
$context Context
$config array
    public function __construct($reflector = null, $context = null, $config = [])
    {
        parent::__construct($config);
        if ($reflector === null) {
            return;
        }
        // base properties
        $this->name = ltrim($reflector->getName(), '\\');
        $this->startLine = $reflector->getNode()->getAttribute('startLine');
        $this->endLine = $reflector->getNode()->getAttribute('endLine');
        $docblock = $reflector->getDocBlock();
        if ($docblock !== null) {
            $this->shortDescription = static::mbUcFirst($docblock->getShortDescription());
            if (empty($this->shortDescription) && !$this instanceof PropertyDoc && $context !== null && $docblock->getTagsByName('inheritdoc') === null) {
                $context->warnings[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No short description for " . substr(StringHelper::basename(get_class($this)), 0, -3) . " '{$this->name}'"];
            }
            $this->description = $docblock->getLongDescription()->getContents();
            $this->phpDocContext = $docblock->getContext();
            $this->tags = $docblock->getTags();
            foreach ($this->tags as $i => $tag) {
                if ($tag instanceof SinceTag) {
                    $this->since = $tag->getVersion();
                    unset($this->tags[$i]);
                } elseif ($tag instanceof DeprecatedTag) {
                    $this->deprecatedSince = $tag->getVersion();
                    $this->deprecatedReason = $tag->getDescription();
                    unset($this->tags[$i]);
                }
            }
        } elseif ($context !== null) {
            $context->warnings[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No docblock for element '{$this->name}'"];
        }
    }

Usage Example

Пример #1
0
 /**
  * @param \phpDocumentor\Reflection\FunctionReflector $reflector
  * @param Context $context
  * @param array $config
  */
 public function __construct($reflector = null, $context = null, $config = [])
 {
     parent::__construct($reflector, $context, $config);
     if ($reflector === null) {
         return;
     }
     $this->isReturnByReference = $reflector->isByRef();
     foreach ($reflector->getArguments() as $arg) {
         $arg = new ParamDoc($arg, $context, ['sourceFile' => $this->sourceFile]);
         $this->params[$arg->name] = $arg;
     }
     foreach ($this->tags as $i => $tag) {
         if ($tag instanceof ThrowsTag) {
             $this->exceptions[$tag->getType()] = $tag->getDescription();
             unset($this->tags[$i]);
         } elseif ($tag instanceof PropertyTag) {
             // ignore property tag
         } elseif ($tag instanceof ParamTag) {
             $paramName = $tag->getVariableName();
             if (!isset($this->params[$paramName]) && $context !== null) {
                 $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "Undefined parameter documented: {$paramName} in {$this->name}()."];
                 continue;
             }
             $this->params[$paramName]->description = ucfirst($tag->getDescription());
             $this->params[$paramName]->type = $tag->getType();
             $this->params[$paramName]->types = $tag->getTypes();
             unset($this->tags[$i]);
         } elseif ($tag instanceof ReturnTag) {
             $this->returnType = $tag->getType();
             $this->returnTypes = $tag->getTypes();
             $this->return = ucfirst($tag->getDescription());
             unset($this->tags[$i]);
         }
     }
 }
All Usage Examples Of yii\apidoc\models\BaseDoc::__construct