src/Parser.php
protected function parseSection($section, $space0, $params, $open, $space1, $directives) : Context
    {
        switch ($section) {
            case 'server':
                return new Server($directives);
            
            case 'http':
                return new Http($directives);
            
            case 'location':
                $modifier = null;
                if (sizeof($params) == 2) {
                    list($modifier, $location) = $params;
                } elseif (sizeof($params) == 1) {
                    $location = $params[0];
                } else {
                    throw new GrammarException(
                        sprintf(
                            "Location context missing in %s",
                            $this->filename ? var_export($this->filename, true) : var_export($this->content, true)
                        )
                    );
                }
                return new Location($location, $modifier, $directives);
            
            case 'events':
                return new Events($directives);
            
            case 'upstream':
                list($upstream) = $params;
                return new Upstream($upstream, $directives);
        }

        throw new UnrecognizedContextException(
            sprintf(
                "Unrecognized context: {$section} found in %s",
                $this->filename ? var_export($this->filename, true) : var_export($this->content, true)
            )
        );
    }
protected function parseSection($section, $space0, $params, $open, $space1, $directives) : Context
    {
        switch ($section) {
            case 'server':
                return new Server($directives);
            
            case 'http':
                return new Http($directives);
            
            case 'location':
                $modifier = null;
                if (sizeof($params) == 2) {
                    list($modifier, $location) = $params;
                } elseif (sizeof($params) == 1) {
                    $location = $params[0];
                } else {
                    throw new GrammarException(
                        sprintf(
                            "Location context missing in %s",
                            $this->filename ? var_export($this->filename, true) : var_export($this->content, true)
                        )
                    );
                }
                return new Location($location, $modifier, $directives);
            
            case 'events':
                return new Events($directives);
            
            case 'upstream':
                list($upstream) = $params;
                return new Upstream($upstream, $directives);
        }

        throw new UnrecognizedContextException(
            sprintf(
                "Unrecognized context: {$section} found in %s",
                $this->filename ? var_export($this->filename, true) : var_export($this->content, true)
            )
        );
    }
protected function parseSection ( $ section , $ space0 , $ params , $ open , $ space1 , $ directives ) : Context { switch ( $ section ) { case 'server' : return new Server ( $ directives ) ; case 'http' : return new Http ( $ directives ) ; case 'location' : $ modifier = null ; if ( sizeof ( $ params ) == 2 ) { list ( $ modifier , $ location ) = $ params ; } elseif ( sizeof ( $ params ) == 1 ) { $ location = $ params [ 0 ] ; } else { throw new GrammarException ( sprintf ( "Location context missing in %s" , $ this -> filename ? var_export ( $ this -> filename , true ) : var_export ( $ this -> content , true ) ) ) ; } return new Location ( $ location , $ modifier , $ directives ) ; case 'events' : return new Events ( $ directives ) ; case 'upstream' : list ( $ upstream ) = $ params ; return new Upstream ( $ upstream , $ directives ) ; } throw new UnrecognizedContextException ( sprintf ( "Unrecognized context: {$section} found in %s" , $ this -> filename ? var_export ( $ this -> filename , true ) : var_export ( $ this -> content , true ) ) ) ; }
Parses section entries
@param string $section Section name
@param null $space0 Ignored
@param Param[] $params Params collection
@param null $open Ignored
@param null $space1 Ignored
@param Directive[] $directives Directives collection
@return Context
@throws GrammarException
@throws UnrecognizedContextException
Parses section entries