@@ -62,25 +62,25 @@ public function __construct($lineNumber = 0)
6262 * @throws UnexpectedTokenException
6363 * @throws SourceException
6464 */
65- public static function parseList (ParserState $ oParserState , CSSList $ oList ): void
65+ public static function parseList (ParserState $ parserState , CSSList $ oList ): void
6666 {
6767 $ bIsRoot = $ oList instanceof Document;
68- if (\is_string ($ oParserState )) {
69- $ oParserState = new ParserState ($ oParserState , Settings::create ());
68+ if (\is_string ($ parserState )) {
69+ $ parserState = new ParserState ($ parserState , Settings::create ());
7070 }
71- $ bLenientParsing = $ oParserState ->getSettings ()->bLenientParsing ;
71+ $ bLenientParsing = $ parserState ->getSettings ()->bLenientParsing ;
7272 $ aComments = [];
73- while (!$ oParserState ->isEnd ()) {
74- $ aComments = \array_merge ($ aComments , $ oParserState ->consumeWhiteSpace ());
73+ while (!$ parserState ->isEnd ()) {
74+ $ aComments = \array_merge ($ aComments , $ parserState ->consumeWhiteSpace ());
7575 $ oListItem = null ;
7676 if ($ bLenientParsing ) {
7777 try {
78- $ oListItem = self ::parseListItem ($ oParserState , $ oList );
78+ $ oListItem = self ::parseListItem ($ parserState , $ oList );
7979 } catch (UnexpectedTokenException $ e ) {
8080 $ oListItem = false ;
8181 }
8282 } else {
83- $ oListItem = self ::parseListItem ($ oParserState , $ oList );
83+ $ oListItem = self ::parseListItem ($ parserState , $ oList );
8484 }
8585 if ($ oListItem === null ) {
8686 // List parsing finished
@@ -90,11 +90,11 @@ public static function parseList(ParserState $oParserState, CSSList $oList): voi
9090 $ oListItem ->addComments ($ aComments );
9191 $ oList ->append ($ oListItem );
9292 }
93- $ aComments = $ oParserState ->consumeWhiteSpace ();
93+ $ aComments = $ parserState ->consumeWhiteSpace ();
9494 }
9595 $ oList ->addComments ($ aComments );
9696 if (!$ bIsRoot && !$ bLenientParsing ) {
97- throw new SourceException ('Unexpected end of document ' , $ oParserState ->currentLine ());
97+ throw new SourceException ('Unexpected end of document ' , $ parserState ->currentLine ());
9898 }
9999 }
100100
@@ -105,96 +105,96 @@ public static function parseList(ParserState $oParserState, CSSList $oList): voi
105105 * @throws UnexpectedEOFException
106106 * @throws UnexpectedTokenException
107107 */
108- private static function parseListItem (ParserState $ oParserState , CSSList $ oList )
108+ private static function parseListItem (ParserState $ parserState , CSSList $ oList )
109109 {
110110 $ bIsRoot = $ oList instanceof Document;
111- if ($ oParserState ->comes ('@ ' )) {
112- $ oAtRule = self ::parseAtRule ($ oParserState );
111+ if ($ parserState ->comes ('@ ' )) {
112+ $ oAtRule = self ::parseAtRule ($ parserState );
113113 if ($ oAtRule instanceof Charset) {
114114 if (!$ bIsRoot ) {
115115 throw new UnexpectedTokenException (
116116 '@charset may only occur in root document ' ,
117117 '' ,
118118 'custom ' ,
119- $ oParserState ->currentLine ()
119+ $ parserState ->currentLine ()
120120 );
121121 }
122122 if (\count ($ oList ->getContents ()) > 0 ) {
123123 throw new UnexpectedTokenException (
124124 '@charset must be the first parseable token in a document ' ,
125125 '' ,
126126 'custom ' ,
127- $ oParserState ->currentLine ()
127+ $ parserState ->currentLine ()
128128 );
129129 }
130- $ oParserState ->setCharset ($ oAtRule ->getCharset ());
130+ $ parserState ->setCharset ($ oAtRule ->getCharset ());
131131 }
132132 return $ oAtRule ;
133- } elseif ($ oParserState ->comes ('} ' )) {
133+ } elseif ($ parserState ->comes ('} ' )) {
134134 if ($ bIsRoot ) {
135- if ($ oParserState ->getSettings ()->bLenientParsing ) {
136- return DeclarationBlock::parse ($ oParserState );
135+ if ($ parserState ->getSettings ()->bLenientParsing ) {
136+ return DeclarationBlock::parse ($ parserState );
137137 } else {
138- throw new SourceException ('Unopened { ' , $ oParserState ->currentLine ());
138+ throw new SourceException ('Unopened { ' , $ parserState ->currentLine ());
139139 }
140140 } else {
141141 // End of list
142142 return null ;
143143 }
144144 } else {
145- return DeclarationBlock::parse ($ oParserState , $ oList );
145+ return DeclarationBlock::parse ($ parserState , $ oList );
146146 }
147147 }
148148
149149 /**
150- * @param ParserState $oParserState
150+ * @param ParserState $parserState
151151 *
152152 * @return AtRuleBlockList|KeyFrame|Charset|CSSNamespace|Import|AtRuleSet|null
153153 *
154154 * @throws SourceException
155155 * @throws UnexpectedTokenException
156156 * @throws UnexpectedEOFException
157157 */
158- private static function parseAtRule (ParserState $ oParserState )
158+ private static function parseAtRule (ParserState $ parserState )
159159 {
160- $ oParserState ->consume ('@ ' );
161- $ sIdentifier = $ oParserState ->parseIdentifier ();
162- $ iIdentifierLineNum = $ oParserState ->currentLine ();
163- $ oParserState ->consumeWhiteSpace ();
160+ $ parserState ->consume ('@ ' );
161+ $ sIdentifier = $ parserState ->parseIdentifier ();
162+ $ iIdentifierLineNum = $ parserState ->currentLine ();
163+ $ parserState ->consumeWhiteSpace ();
164164 if ($ sIdentifier === 'import ' ) {
165- $ oLocation = URL ::parse ($ oParserState );
166- $ oParserState ->consumeWhiteSpace ();
165+ $ oLocation = URL ::parse ($ parserState );
166+ $ parserState ->consumeWhiteSpace ();
167167 $ sMediaQuery = null ;
168- if (!$ oParserState ->comes ('; ' )) {
169- $ sMediaQuery = \trim ($ oParserState ->consumeUntil (['; ' , ParserState::EOF ]));
168+ if (!$ parserState ->comes ('; ' )) {
169+ $ sMediaQuery = \trim ($ parserState ->consumeUntil (['; ' , ParserState::EOF ]));
170170 if ($ sMediaQuery === '' ) {
171171 $ sMediaQuery = null ;
172172 }
173173 }
174- $ oParserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
174+ $ parserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
175175 return new Import ($ oLocation , $ sMediaQuery , $ iIdentifierLineNum );
176176 } elseif ($ sIdentifier === 'charset ' ) {
177- $ oCharsetString = CSSString::parse ($ oParserState );
178- $ oParserState ->consumeWhiteSpace ();
179- $ oParserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
177+ $ oCharsetString = CSSString::parse ($ parserState );
178+ $ parserState ->consumeWhiteSpace ();
179+ $ parserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
180180 return new Charset ($ oCharsetString , $ iIdentifierLineNum );
181181 } elseif (self ::identifierIs ($ sIdentifier , 'keyframes ' )) {
182182 $ oResult = new KeyFrame ($ iIdentifierLineNum );
183183 $ oResult ->setVendorKeyFrame ($ sIdentifier );
184- $ oResult ->setAnimationName (\trim ($ oParserState ->consumeUntil ('{ ' , false , true )));
185- CSSList::parseList ($ oParserState , $ oResult );
186- if ($ oParserState ->comes ('} ' )) {
187- $ oParserState ->consume ('} ' );
184+ $ oResult ->setAnimationName (\trim ($ parserState ->consumeUntil ('{ ' , false , true )));
185+ CSSList::parseList ($ parserState , $ oResult );
186+ if ($ parserState ->comes ('} ' )) {
187+ $ parserState ->consume ('} ' );
188188 }
189189 return $ oResult ;
190190 } elseif ($ sIdentifier === 'namespace ' ) {
191191 $ sPrefix = null ;
192- $ mUrl = Value::parsePrimitiveValue ($ oParserState );
193- if (!$ oParserState ->comes ('; ' )) {
192+ $ mUrl = Value::parsePrimitiveValue ($ parserState );
193+ if (!$ parserState ->comes ('; ' )) {
194194 $ sPrefix = $ mUrl ;
195- $ mUrl = Value::parsePrimitiveValue ($ oParserState );
195+ $ mUrl = Value::parsePrimitiveValue ($ parserState );
196196 }
197- $ oParserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
197+ $ parserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
198198 if ($ sPrefix !== null && !\is_string ($ sPrefix )) {
199199 throw new UnexpectedTokenException ('Wrong namespace prefix ' , $ sPrefix , 'custom ' , $ iIdentifierLineNum );
200200 }
@@ -209,12 +209,12 @@ private static function parseAtRule(ParserState $oParserState)
209209 return new CSSNamespace ($ mUrl , $ sPrefix , $ iIdentifierLineNum );
210210 } else {
211211 // Unknown other at rule (font-face or such)
212- $ sArgs = \trim ($ oParserState ->consumeUntil ('{ ' , false , true ));
212+ $ sArgs = \trim ($ parserState ->consumeUntil ('{ ' , false , true ));
213213 if (\substr_count ($ sArgs , '( ' ) != \substr_count ($ sArgs , ') ' )) {
214- if ($ oParserState ->getSettings ()->bLenientParsing ) {
214+ if ($ parserState ->getSettings ()->bLenientParsing ) {
215215 return null ;
216216 } else {
217- throw new SourceException ('Unmatched brace count in media query ' , $ oParserState ->currentLine ());
217+ throw new SourceException ('Unmatched brace count in media query ' , $ parserState ->currentLine ());
218218 }
219219 }
220220 $ bUseRuleSet = true ;
@@ -226,12 +226,12 @@ private static function parseAtRule(ParserState $oParserState)
226226 }
227227 if ($ bUseRuleSet ) {
228228 $ oAtRule = new AtRuleSet ($ sIdentifier , $ sArgs , $ iIdentifierLineNum );
229- RuleSet::parseRuleSet ($ oParserState , $ oAtRule );
229+ RuleSet::parseRuleSet ($ parserState , $ oAtRule );
230230 } else {
231231 $ oAtRule = new AtRuleBlockList ($ sIdentifier , $ sArgs , $ iIdentifierLineNum );
232- CSSList::parseList ($ oParserState , $ oAtRule );
233- if ($ oParserState ->comes ('} ' )) {
234- $ oParserState ->consume ('} ' );
232+ CSSList::parseList ($ parserState , $ oAtRule );
233+ if ($ parserState ->comes ('} ' )) {
234+ $ parserState ->consume ('} ' );
235235 }
236236 }
237237 return $ oAtRule ;
0 commit comments