/** * Return parameter reflection * @param ReflectionParameter $param * @param PHPParser_Builder_Method $methodStmt * * @return PHPParser_Builder_Method */ private function getMethodStatement(ReflectionParameter $param, PHPParser_Builder_Method $methodStmt) { /** @var $param \ReflectionParameter */ $paramStmt = $this->factory->param($param->name); $typeHint = $param->getClass(); if ($typeHint) { $paramStmt->setTypeHint($typeHint->name); } if ($param->isDefaultValueAvailable()) { $paramStmt->setDefault($param->getDefaultValue()); } $methodStmt->addParam($paramStmt); return $methodStmt; }
public function testCreateFunctionBuilder() { $factory = new PHPParser_BuilderFactory(); $this->assertInstanceOf('PHPParser_Builder_Function', $factory->function('test')); }
/** * @param \EBT\ExtensionBuilder\Domain\Model\ClassObject\Property $property * @return \PHPParser_Node_Stmt_Property */ public function buildPropertyNode(\EBT\ExtensionBuilder\Domain\Model\ClassObject\Property $property) { $factory = new \PHPParser_BuilderFactory(); $propertyNodeBuilder = $factory->property($property->getName()); $propertyNode = $propertyNodeBuilder->getNode(); $propertyNode->type = $property->getModifiers(); foreach ($propertyNode->props as $subNode) { if ($subNode instanceof \PHPParser_Node_Stmt_PropertyProperty) { if (!is_null($property->getDefaultValueNode())) { $subNode->default = $property->getDefaultValueNode(); } else { $subNode->default = $this->buildNodeFromValue($property->getDefault()); } } } $this->addCommentAttributes($property, $propertyNode); $propertyNode->default = $property->getDefault(); return $propertyNode; }