src/Language/Parser.php
private function parseFragment()
    {
        $start = $this->lexer->token;
        $this->expect(Token::SPREAD);

        if ($this->peek(Token::NAME) && $this->lexer->token->value !== 'on') {
            return new FragmentSpreadNode([
                'name'       => $this->parseFragmentName(),
                'directives' => $this->parseDirectives(false),
                'loc'        => $this->loc($start),
            ]);
        }

        $typeCondition = null;
        if ($this->lexer->token->value === 'on') {
            $this->lexer->advance();
            $typeCondition = $this->parseNamedType();
        }

        return new InlineFragmentNode([
            'typeCondition' => $typeCondition,
            'directives'    => $this->parseDirectives(false),
            'selectionSet'  => $this->parseSelectionSet(),
            'loc'           => $this->loc($start),
        ]);
    }
private function parseFragment()
    {
        $start = $this->lexer->token;
        $this->expect(Token::SPREAD);

        if ($this->peek(Token::NAME) && $this->lexer->token->value !== 'on') {
            return new FragmentSpreadNode([
                'name'       => $this->parseFragmentName(),
                'directives' => $this->parseDirectives(false),
                'loc'        => $this->loc($start),
            ]);
        }

        $typeCondition = null;
        if ($this->lexer->token->value === 'on') {
            $this->lexer->advance();
            $typeCondition = $this->parseNamedType();
        }

        return new InlineFragmentNode([
            'typeCondition' => $typeCondition,
            'directives'    => $this->parseDirectives(false),
            'selectionSet'  => $this->parseSelectionSet(),
            'loc'           => $this->loc($start),
        ]);
    }
private function parseFragment ( ) { $ start = $ this -> lexer -> token ; $ this -> expect ( Token :: SPREAD ) ; if ( $ this -> peek ( Token :: NAME ) && $ this -> lexer -> token -> value !== 'on' ) { return new FragmentSpreadNode ( [ 'name' => $ this -> parseFragmentName ( ) , 'directives' => $ this -> parseDirectives ( false ) , 'loc' => $ this -> loc ( $ start ) , ] ) ; } $ typeCondition = null ; if ( $ this -> lexer -> token -> value === 'on' ) { $ this -> lexer -> advance ( ) ; $ typeCondition = $ this -> parseNamedType ( ) ; } return new InlineFragmentNode ( [ 'typeCondition' => $ typeCondition , 'directives' => $ this -> parseDirectives ( false ) , 'selectionSet' => $ this -> parseSelectionSet ( ) , 'loc' => $ this -> loc ( $ start ) , ] ) ; }
@return FragmentSpreadNode|InlineFragmentNode

@throws SyntaxError
@return FragmentSpreadNode|InlineFragmentNode