validator = new ConstantExpressionValidator($phpVersion); } public function enterNode(Node $node): null { try { return $this->validateNode($node); } catch (SyntaxError $error) { if ($this->fatalError !== null) { ($this->fatalError)($node, $error->getMessage()); } throw $error; } } private function validateNode(Node $node): null { if ($node instanceof Node\Attribute) { $this->validator->validateArguments( $node->args, allowDynamic: true, attributeArgumentList: true, ); return null; } if ($node instanceof Node\Stmt\ClassConst) { foreach ($node->consts as $constant) { $this->validator->validate($constant->value, allowDynamic: false); } return null; } if ($node instanceof Node\Stmt\Property) { foreach ($node->props as $property) { if ($property->default !== null) { $this->validator->validate($property->default, allowDynamic: false); } } return null; } if ($node instanceof Node\Stmt\EnumCase && $node->expr !== null) { $this->validator->validate($node->expr, allowDynamic: false); return null; } if ($node instanceof Node\Param && $node->default !== null) { $this->validator->validate($node->default, allowDynamic: true); return null; } if ($node instanceof Node\Stmt\Const_) { foreach ($node->consts as $constant) { $this->validator->validate($constant->value, allowDynamic: true); } return null; } return null; } }