public function enterNode(Node $node)
    {
        parent::enterNode($node);

        if (self::isConditional($node)) {
            $this->conditionalScopes++;
        } elseif ($node instanceof Function_) {
            $name = $this->getFullyQualifiedName($node->name);

            // @todo add an "else" here which adds a runtime check for instances where we can't tell
            // whether a function is being redefined by static analysis alone.
            if ($this->conditionalScopes === 0) {
                if (\function_exists($name) ||
                    isset($this->currentScope[\strtolower($name)])) {
                    $msg = \sprintf('Cannot redeclare %s()', $name);
                    throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
                }
            }

            $this->currentScope[\strtolower($name)] = true;
        }
    }
public function enterNode(Node $node)
    {
        parent::enterNode($node);

        if (self::isConditional($node)) {
            $this->conditionalScopes++;
        } elseif ($node instanceof Function_) {
            $name = $this->getFullyQualifiedName($node->name);

            // @todo add an "else" here which adds a runtime check for instances where we can't tell
            // whether a function is being redefined by static analysis alone.
            if ($this->conditionalScopes === 0) {
                if (\function_exists($name) ||
                    isset($this->currentScope[\strtolower($name)])) {
                    $msg = \sprintf('Cannot redeclare %s()', $name);
                    throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
                }
            }

            $this->currentScope[\strtolower($name)] = true;
        }
    }
public function enterNode ( Node $ node ) { parent :: enterNode ( $ node ) ; if ( self :: isConditional ( $ node ) ) { $ this -> conditionalScopes ++ ; } elseif ( $ node instanceof Function_ ) { $ name = $ this -> getFullyQualifiedName ( $ node -> name ) ; // @todo add an "else" here which adds a runtime check for instances where we can't tell // whether a function is being redefined by static analysis alone. if ( $ this -> conditionalScopes === 0 ) { if ( \ function_exists ( $ name ) || isset ( $ this -> currentScope [ \ strtolower ( $ name ) ] ) ) { $ msg = \ sprintf ( 'Cannot redeclare %s()' , $ name ) ; throw new FatalErrorException ( $ msg , 0 , E_ERROR , null , $ node -> getLine ( ) ) ; } } $ this -> currentScope [ \ strtolower ( $ name ) ] = true ; } }
Store newly defined function names on the way in, to allow recursion.

@param Node $node
Store newly defined function names on the way in to allow recursion .