예제 #1
0
 /**
  * @param \EBT\ExtensionBuilder\Domain\Model\ClassObject\Method $methodObject
  * @return \PhpParser\Node\Stmt\ClassMethod
  */
 public function buildMethodNode(\EBT\ExtensionBuilder\Domain\Model\ClassObject\Method $methodObject)
 {
     $factory = new \PhpParser\BuilderFactory();
     $methodNodeBuilder = $factory->method($methodObject->getName());
     $parameters = $methodObject->getParameters();
     if (count($parameters) > 0) {
         foreach ($parameters as $parameter) {
             $parameterNode = $this->buildParameterNode($parameter);
             $methodNodeBuilder->addParam($parameterNode);
         }
     }
     $methodNodeBuilder->addStmts($methodObject->getBodyStmts());
     $methodNode = $methodNodeBuilder->getNode();
     $methodNode->type = $methodObject->getModifiers();
     $methodNode->setAttribute('startLine', $methodObject->getStartLine());
     $methodNode->setAttribute('endLine', $methodObject->getEndLine());
     $methodObject->updateParamTags();
     $this->addCommentAttributes($methodObject, $methodNode);
     return $methodNode;
 }
예제 #2
0
 /**
  * @param \EBT\ExtensionBuilder\Domain\Model\ClassObject\Method $classMethod
  * @return \EBT\ExtensionBuilder\Domain\Model\ClassObject\ClassObject
  */
 public function addMethod($classMethod)
 {
     if (!$this->methodExists($classMethod->getName())) {
         $this->methods[$classMethod->getName()] = $classMethod;
     }
     return $this;
 }