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

parseMethodOrFieldDeclaration() private method

This method will parse a list of modifiers and a following property or method.
Since: 0.9.6
private parseMethodOrFieldDeclaration ( integer $modifiers ) : PDepend\Source\AST\ASTMethod | PDepend\Source\AST\ASTFieldDeclaration
$modifiers integer
return PDepend\Source\AST\ASTMethod | PDepend\Source\AST\ASTFieldDeclaration
    private function parseMethodOrFieldDeclaration($modifiers = 0)
    {
        $this->tokenStack->push();
        $tokenType = $this->tokenizer->peek();
        while ($tokenType !== Tokenizer::T_EOF) {
            switch ($tokenType) {
                case Tokens::T_PRIVATE:
                    $modifiers |= State::IS_PRIVATE;
                    $modifiers = $modifiers & ~State::IS_PUBLIC;
                    break;
                case Tokens::T_PROTECTED:
                    $modifiers |= State::IS_PROTECTED;
                    $modifiers = $modifiers & ~State::IS_PUBLIC;
                    break;
                case Tokens::T_VAR:
                case Tokens::T_PUBLIC:
                    $modifiers |= State::IS_PUBLIC;
                    break;
                case Tokens::T_STATIC:
                    $modifiers |= State::IS_STATIC;
                    break;
                case Tokens::T_ABSTRACT:
                    $modifiers |= State::IS_ABSTRACT;
                    break;
                case Tokens::T_FINAL:
                    $modifiers |= State::IS_FINAL;
                    break;
                case Tokens::T_FUNCTION:
                    $method = $this->parseMethodDeclaration();
                    $method->setModifiers($modifiers);
                    $method->setCompilationUnit($this->compilationUnit);
                    $method->setId($this->idBuilder->forMethod($method));
                    $method->setTokens($this->tokenStack->pop());
                    return $method;
                case Tokens::T_VARIABLE:
                    $declaration = $this->parseFieldDeclaration();
                    $declaration->setModifiers($modifiers);
                    return $declaration;
                default:
                    break 2;
            }
            $this->consumeToken($tokenType);
            $this->consumeComments();
            $tokenType = $this->tokenizer->peek();
        }
        $this->throwUnexpectedTokenException();
    }
AbstractPHPParser