src/Parser.php
protected function mediaQuery(&$out)
    {
        $expressions = null;
        $parts = [];

        if (($this->literal('only', 4) && ($only = true) || $this->literal('not', 3) && ($not = true) || true) &&
            $this->mixedKeyword($mediaType)
        ) {
            $prop = [Type::T_MEDIA_TYPE];

            if (isset($only)) {
                $prop[] = [Type::T_KEYWORD, 'only'];
            }

            if (isset($not)) {
                $prop[] = [Type::T_KEYWORD, 'not'];
            }

            $media = [Type::T_LIST, '', []];

            foreach ((array) $mediaType as $type) {
                if (is_array($type)) {
                    $media[2][] = $type;
                } else {
                    $media[2][] = [Type::T_KEYWORD, $type];
                }
            }

            $prop[]  = $media;
            $parts[] = $prop;
        }

        if (empty($parts) || $this->literal('and', 3)) {
            $this->genericList($expressions, 'mediaExpression', 'and', false);

            if (is_array($expressions)) {
                $parts = array_merge($parts, $expressions[2]);
            }
        }

        $out = $parts;

        return true;
    }
protected function mediaQuery(&$out)
    {
        $expressions = null;
        $parts = [];

        if (($this->literal('only', 4) && ($only = true) || $this->literal('not', 3) && ($not = true) || true) &&
            $this->mixedKeyword($mediaType)
        ) {
            $prop = [Type::T_MEDIA_TYPE];

            if (isset($only)) {
                $prop[] = [Type::T_KEYWORD, 'only'];
            }

            if (isset($not)) {
                $prop[] = [Type::T_KEYWORD, 'not'];
            }

            $media = [Type::T_LIST, '', []];

            foreach ((array) $mediaType as $type) {
                if (is_array($type)) {
                    $media[2][] = $type;
                } else {
                    $media[2][] = [Type::T_KEYWORD, $type];
                }
            }

            $prop[]  = $media;
            $parts[] = $prop;
        }

        if (empty($parts) || $this->literal('and', 3)) {
            $this->genericList($expressions, 'mediaExpression', 'and', false);

            if (is_array($expressions)) {
                $parts = array_merge($parts, $expressions[2]);
            }
        }

        $out = $parts;

        return true;
    }
protected function mediaQuery ( & $ out ) { $ expressions = null ; $ parts = [ ] ; if ( ( $ this -> literal ( 'only' , 4 ) && ( $ only = true ) || $ this -> literal ( 'not' , 3 ) && ( $ not = true ) || true ) && $ this -> mixedKeyword ( $ mediaType ) ) { $ prop = [ Type :: T_MEDIA_TYPE ] ; if ( isset ( $ only ) ) { $ prop [ ] = [ Type :: T_KEYWORD , 'only' ] ; } if ( isset ( $ not ) ) { $ prop [ ] = [ Type :: T_KEYWORD , 'not' ] ; } $ media = [ Type :: T_LIST , '' , [ ] ] ; foreach ( ( array ) $ mediaType as $ type ) { if ( is_array ( $ type ) ) { $ media [ 2 ] [ ] = $ type ; } else { $ media [ 2 ] [ ] = [ Type :: T_KEYWORD , $ type ] ; } } $ prop [ ] = $ media ; $ parts [ ] = $ prop ; } if ( empty ( $ parts ) || $ this -> literal ( 'and' , 3 ) ) { $ this -> genericList ( $ expressions , 'mediaExpression' , 'and' , false ) ; if ( is_array ( $ expressions ) ) { $ parts = array_merge ( $ parts , $ expressions [ 2 ] ) ; } } $ out = $ parts ; return true ; }
Parse media query

@param array $out

@return boolean
Parse media query