/** * Store newly defined function names on the way in, to allow recursion. * * @param Node $node */ public function enterNode(Node $node) { parent::enterNode($node); if ($node instanceof FunctionStmt) { $name = $this->getFullyQualifiedName($node->name); if (function_exists($name) || isset($this->currentScope[strtolower($name)])) { throw new FatalErrorException(sprintf('Cannot redeclare %s()', $name), 0, 1, null, $node->getLine()); } $this->currentScope[strtolower($name)] = true; } }
/** * Validate class, interface and trait definitions. * * Validate them upon entering the node, so that we know about their * presence and can validate constant fetches and static calls in class or * trait methods. * * @param Node */ public function enterNode(Node $node) { parent::enterNode($node); if ($node instanceof ClassStmt) { $this->validateClassStatement($node); } elseif ($node instanceof InterfaceStmt) { $this->validateInterfaceStatement($node); } elseif ($node instanceof TraitStmt) { $this->validateTraitStatement($node); } }