addTrait() public method

public addTrait ( string $name ) : TheSeer\phpDox\Collector\TraitUseObject
$name string
return TheSeer\phpDox\Collector\TraitUseObject
Exemplo n.º 1
0
 private function processTraitUse(NodeType\TraitUse $node)
 {
     foreach ($node->traits as $trait) {
         $traitUse = $this->unit->addTrait((string) $trait);
         $traitUse->setStartLine($node->getAttribute('startLine'));
         $traitUse->setEndLine($node->getAttribute('endLine'));
     }
     foreach ($node->adaptations as $adaptation) {
         if ($adaptation instanceof NodeType\TraitUseAdaptation\Alias) {
             $traitUse = $this->getTraitUse((string) $adaptation->trait);
             $traitUse->addAlias($adaptation->method, $adaptation->newName, $adaptation->newModifier ? $this->modifier[$adaptation->newModifier] : NULL);
         } elseif ($adaptation instanceof NodeType\TraitUseAdaptation\Precedence) {
             $traitUse = $this->getTraitUse((string) $adaptation->insteadof[0]);
             $traitUse->addExclude($adaptation->method);
         } else {
             throw new ParseErrorException(sprintf('Unexpected adaption type %s', get_class($adaptation)), ParseErrorException::UnexpectedExpr);
         }
     }
 }