PDepend\Source\Language\PHP\AbstractPHPParser::parseFunctionDeclaration PHP Method

parseFunctionDeclaration() private method

This method parses a function declaration.
Since: 0.9.5
private parseFunctionDeclaration ( ) : PDepend\Source\AST\ASTFunction
return PDepend\Source\AST\ASTFunction
    private function parseFunctionDeclaration()
    {
        $this->consumeComments();
        // Next token must be the function identifier
        $functionName = $this->parseFunctionName();
        $function = $this->builder->buildFunction($functionName);
        $function->setCompilationUnit($this->compilationUnit);
        $function->setId($this->idBuilder->forFunction($function));
        $this->parseCallableDeclaration($function);
        // First check for an existing namespace
        if ($this->namespaceName !== null) {
            $packageName = $this->namespaceName;
        } elseif ($this->packageName !== Builder::DEFAULT_NAMESPACE) {
            $packageName = $this->packageName;
        } else {
            $packageName = $this->globalPackageName;
        }
        $this->builder->buildNamespace($packageName)->addFunction($function);
        // Store function in source file, because we need them during the file's
        // __wakeup() phase for function declarations within another function or
        // method declaration.
        $this->compilationUnit->addChild($function);
        return $function;
    }
AbstractPHPParser