diff --git a/composer.json b/composer.json index 79ae793..96c3a15 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "hoa/router" : "~3.0", "hoa/view" : "~3.0", "league/commonmark": "~0.16", - "nikic/php-parser" : "~3.1" + "nikic/php-parser" : "~4.0" }, "autoload": { "psr-4": { diff --git a/src/Compiler/IntermediateRepresentation/Into.php b/src/Compiler/IntermediateRepresentation/Into.php index 69881ad..ce07fac 100644 --- a/src/Compiler/IntermediateRepresentation/Into.php +++ b/src/Compiler/IntermediateRepresentation/Into.php @@ -96,7 +96,7 @@ public function __construct(string $filename) */ public function leaveNode(Node $node) { - if ($node instanceof Node\Stmt\Class_) { + if ($node instanceof Node\Stmt\Class_ && false === $node->isAnonymous()) { $classNode = $node; $class = new Class_($classNode->namespacedName->toString()); $class->lineStart = $classNode->getAttribute('startLine'); @@ -195,7 +195,7 @@ protected function intoConstants(Node\Stmt\ClassLike $node): array } foreach ($statement->consts as $constantNode) { - $constant = new Constant($constantNode->name); + $constant = new Constant($constantNode->name->name); $constant->visibility = $visibility; $constant->value = $this->_prettyPrinter->prettyPrint([$constantNode->value]); @@ -247,7 +247,7 @@ protected function intoAttributes(Node\Stmt\ClassLike $node): array $static = $statement->isStatic(); foreach ($statement->props as $attributeNode) { - $attribute = new Attribute($attributeNode->name); + $attribute = new Attribute($attributeNode->name->name); $attribute->visibility = $visibility; $attribute->static = $static; @@ -279,7 +279,7 @@ protected function intoMethods(Node\Stmt\ClassLike $node): array $methods = []; foreach ($node->getMethods() as $methodNode) { - $method = new Method($methodNode->name); + $method = new Method($methodNode->name->name); $method->lineStart = $methodNode->getAttribute('startLine'); $method->lineEnd = $methodNode->getAttribute('endLine'); @@ -319,7 +319,7 @@ protected function intoInputs($node): array $parametersNode = $node->params; foreach ($parametersNode as $parameterNode) { - $parameter = new Parameter($parameterNode->name); + $parameter = new Parameter($parameterNode->var->name); $parameter->type = $this->intoType($parameterNode->type); $parameter->type->reference = $parameterNode->byRef; $parameter->variadic = $parameterNode->variadic;