__construct() 공개 메소드

public __construct ( phpDocumentor\Reflection\BaseReflector $reflector = null, Context $context = null, array $config = [] )
$reflector phpDocumentor\Reflection\BaseReflector
$context Context
$config array
예제 #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]);
         }
     }
 }
예제 #2
0
 /**
  * @param \phpDocumentor\Reflection\ClassReflector\PropertyReflector $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->visibility = $reflector->getVisibility();
     $this->isStatic = $reflector->isStatic();
     // bypass $reflector->getDefault() for short array syntax
     if ($reflector->getNode()->default) {
         $this->defaultValue = PrettyPrinter::getRepresentationOfValue($reflector->getNode()->default);
     }
     $hasInheritdoc = false;
     foreach ($this->tags as $tag) {
         if ($tag->getName() === 'inheritdoc') {
             $hasInheritdoc = true;
         }
         if ($tag instanceof VarTag) {
             $this->type = $tag->getType();
             $this->types = $tag->getTypes();
             $this->description = ucfirst($tag->getDescription());
             if (($pos = strpos($this->description, '.')) !== false) {
                 $this->shortDescription = substr($this->description, 0, $pos + 1);
             } else {
                 $this->shortDescription = $this->description;
             }
         }
     }
     if (empty($this->shortDescription) && $context !== null && !$hasInheritdoc) {
         $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No short description for element '{$this->name}'"];
     }
 }
예제 #3
0
 /**
  * @param \phpDocumentor\Reflection\InterfaceReflector $reflector
  * @param Context $context
  * @param array $config
  */
 public function __construct($reflector = null, $context = null, $config = [])
 {
     parent::__construct($reflector, $context, $config);
     if ($reflector === null) {
         return;
     }
     foreach ($this->tags as $i => $tag) {
         if ($tag instanceof AuthorTag) {
             $this->authors[$tag->getAuthorName()] = $tag->getAuthorEmail();
             unset($this->tags[$i]);
         } else {
             if ($tag->getName() == 'package') {
                 $this->namespace = $tag->getContent();
                 unset($this->tags[$i]);
             }
         }
     }
     if (empty($this->namespace)) {
         $this->namespace = trim(StringHelper::dirname($this->name), '\\');
     }
     foreach ($reflector->getProperties() as $propertyReflector) {
         if ($propertyReflector->getVisibility() != 'private') {
             $property = new PropertyDoc($propertyReflector, $context, ['sourceFile' => $this->sourceFile]);
             $property->definedBy = $this->name;
             $this->properties[$property->name] = $property;
         }
     }
     foreach ($reflector->getMethods() as $methodReflector) {
         if ($methodReflector->getVisibility() != 'private') {
             $method = new MethodDoc($methodReflector, $context, ['sourceFile' => $this->sourceFile]);
             $method->definedBy = $this->name;
             $this->methods[$method->name] = $method;
         }
     }
 }