@@ -62,25 +62,25 @@ public function __construct($lineNumber = 0)
62
62
* @throws UnexpectedTokenException
63
63
* @throws SourceException
64
64
*/
65
- public static function parseList (ParserState $ oParserState , CSSList $ oList ): void
65
+ public static function parseList (ParserState $ parserState , CSSList $ oList ): void
66
66
{
67
67
$ 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 ());
70
70
}
71
- $ bLenientParsing = $ oParserState ->getSettings ()->bLenientParsing ;
71
+ $ bLenientParsing = $ parserState ->getSettings ()->bLenientParsing ;
72
72
$ aComments = [];
73
- while (!$ oParserState ->isEnd ()) {
74
- $ aComments = \array_merge ($ aComments , $ oParserState ->consumeWhiteSpace ());
73
+ while (!$ parserState ->isEnd ()) {
74
+ $ aComments = \array_merge ($ aComments , $ parserState ->consumeWhiteSpace ());
75
75
$ oListItem = null ;
76
76
if ($ bLenientParsing ) {
77
77
try {
78
- $ oListItem = self ::parseListItem ($ oParserState , $ oList );
78
+ $ oListItem = self ::parseListItem ($ parserState , $ oList );
79
79
} catch (UnexpectedTokenException $ e ) {
80
80
$ oListItem = false ;
81
81
}
82
82
} else {
83
- $ oListItem = self ::parseListItem ($ oParserState , $ oList );
83
+ $ oListItem = self ::parseListItem ($ parserState , $ oList );
84
84
}
85
85
if ($ oListItem === null ) {
86
86
// List parsing finished
@@ -90,11 +90,11 @@ public static function parseList(ParserState $oParserState, CSSList $oList): voi
90
90
$ oListItem ->addComments ($ aComments );
91
91
$ oList ->append ($ oListItem );
92
92
}
93
- $ aComments = $ oParserState ->consumeWhiteSpace ();
93
+ $ aComments = $ parserState ->consumeWhiteSpace ();
94
94
}
95
95
$ oList ->addComments ($ aComments );
96
96
if (!$ bIsRoot && !$ bLenientParsing ) {
97
- throw new SourceException ('Unexpected end of document ' , $ oParserState ->currentLine ());
97
+ throw new SourceException ('Unexpected end of document ' , $ parserState ->currentLine ());
98
98
}
99
99
}
100
100
@@ -105,96 +105,96 @@ public static function parseList(ParserState $oParserState, CSSList $oList): voi
105
105
* @throws UnexpectedEOFException
106
106
* @throws UnexpectedTokenException
107
107
*/
108
- private static function parseListItem (ParserState $ oParserState , CSSList $ oList )
108
+ private static function parseListItem (ParserState $ parserState , CSSList $ oList )
109
109
{
110
110
$ bIsRoot = $ oList instanceof Document;
111
- if ($ oParserState ->comes ('@ ' )) {
112
- $ oAtRule = self ::parseAtRule ($ oParserState );
111
+ if ($ parserState ->comes ('@ ' )) {
112
+ $ oAtRule = self ::parseAtRule ($ parserState );
113
113
if ($ oAtRule instanceof Charset) {
114
114
if (!$ bIsRoot ) {
115
115
throw new UnexpectedTokenException (
116
116
'@charset may only occur in root document ' ,
117
117
'' ,
118
118
'custom ' ,
119
- $ oParserState ->currentLine ()
119
+ $ parserState ->currentLine ()
120
120
);
121
121
}
122
122
if (\count ($ oList ->getContents ()) > 0 ) {
123
123
throw new UnexpectedTokenException (
124
124
'@charset must be the first parseable token in a document ' ,
125
125
'' ,
126
126
'custom ' ,
127
- $ oParserState ->currentLine ()
127
+ $ parserState ->currentLine ()
128
128
);
129
129
}
130
- $ oParserState ->setCharset ($ oAtRule ->getCharset ());
130
+ $ parserState ->setCharset ($ oAtRule ->getCharset ());
131
131
}
132
132
return $ oAtRule ;
133
- } elseif ($ oParserState ->comes ('} ' )) {
133
+ } elseif ($ parserState ->comes ('} ' )) {
134
134
if ($ bIsRoot ) {
135
- if ($ oParserState ->getSettings ()->bLenientParsing ) {
136
- return DeclarationBlock::parse ($ oParserState );
135
+ if ($ parserState ->getSettings ()->bLenientParsing ) {
136
+ return DeclarationBlock::parse ($ parserState );
137
137
} else {
138
- throw new SourceException ('Unopened { ' , $ oParserState ->currentLine ());
138
+ throw new SourceException ('Unopened { ' , $ parserState ->currentLine ());
139
139
}
140
140
} else {
141
141
// End of list
142
142
return null ;
143
143
}
144
144
} else {
145
- return DeclarationBlock::parse ($ oParserState , $ oList );
145
+ return DeclarationBlock::parse ($ parserState , $ oList );
146
146
}
147
147
}
148
148
149
149
/**
150
- * @param ParserState $oParserState
150
+ * @param ParserState $parserState
151
151
*
152
152
* @return AtRuleBlockList|KeyFrame|Charset|CSSNamespace|Import|AtRuleSet|null
153
153
*
154
154
* @throws SourceException
155
155
* @throws UnexpectedTokenException
156
156
* @throws UnexpectedEOFException
157
157
*/
158
- private static function parseAtRule (ParserState $ oParserState )
158
+ private static function parseAtRule (ParserState $ parserState )
159
159
{
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 ();
164
164
if ($ sIdentifier === 'import ' ) {
165
- $ oLocation = URL ::parse ($ oParserState );
166
- $ oParserState ->consumeWhiteSpace ();
165
+ $ oLocation = URL ::parse ($ parserState );
166
+ $ parserState ->consumeWhiteSpace ();
167
167
$ sMediaQuery = null ;
168
- if (!$ oParserState ->comes ('; ' )) {
169
- $ sMediaQuery = \trim ($ oParserState ->consumeUntil (['; ' , ParserState::EOF ]));
168
+ if (!$ parserState ->comes ('; ' )) {
169
+ $ sMediaQuery = \trim ($ parserState ->consumeUntil (['; ' , ParserState::EOF ]));
170
170
if ($ sMediaQuery === '' ) {
171
171
$ sMediaQuery = null ;
172
172
}
173
173
}
174
- $ oParserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
174
+ $ parserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
175
175
return new Import ($ oLocation , $ sMediaQuery , $ iIdentifierLineNum );
176
176
} 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 );
180
180
return new Charset ($ oCharsetString , $ iIdentifierLineNum );
181
181
} elseif (self ::identifierIs ($ sIdentifier , 'keyframes ' )) {
182
182
$ oResult = new KeyFrame ($ iIdentifierLineNum );
183
183
$ 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 ('} ' );
188
188
}
189
189
return $ oResult ;
190
190
} elseif ($ sIdentifier === 'namespace ' ) {
191
191
$ sPrefix = null ;
192
- $ mUrl = Value::parsePrimitiveValue ($ oParserState );
193
- if (!$ oParserState ->comes ('; ' )) {
192
+ $ mUrl = Value::parsePrimitiveValue ($ parserState );
193
+ if (!$ parserState ->comes ('; ' )) {
194
194
$ sPrefix = $ mUrl ;
195
- $ mUrl = Value::parsePrimitiveValue ($ oParserState );
195
+ $ mUrl = Value::parsePrimitiveValue ($ parserState );
196
196
}
197
- $ oParserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
197
+ $ parserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
198
198
if ($ sPrefix !== null && !\is_string ($ sPrefix )) {
199
199
throw new UnexpectedTokenException ('Wrong namespace prefix ' , $ sPrefix , 'custom ' , $ iIdentifierLineNum );
200
200
}
@@ -209,12 +209,12 @@ private static function parseAtRule(ParserState $oParserState)
209
209
return new CSSNamespace ($ mUrl , $ sPrefix , $ iIdentifierLineNum );
210
210
} else {
211
211
// Unknown other at rule (font-face or such)
212
- $ sArgs = \trim ($ oParserState ->consumeUntil ('{ ' , false , true ));
212
+ $ sArgs = \trim ($ parserState ->consumeUntil ('{ ' , false , true ));
213
213
if (\substr_count ($ sArgs , '( ' ) != \substr_count ($ sArgs , ') ' )) {
214
- if ($ oParserState ->getSettings ()->bLenientParsing ) {
214
+ if ($ parserState ->getSettings ()->bLenientParsing ) {
215
215
return null ;
216
216
} 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 ());
218
218
}
219
219
}
220
220
$ bUseRuleSet = true ;
@@ -226,12 +226,12 @@ private static function parseAtRule(ParserState $oParserState)
226
226
}
227
227
if ($ bUseRuleSet ) {
228
228
$ oAtRule = new AtRuleSet ($ sIdentifier , $ sArgs , $ iIdentifierLineNum );
229
- RuleSet::parseRuleSet ($ oParserState , $ oAtRule );
229
+ RuleSet::parseRuleSet ($ parserState , $ oAtRule );
230
230
} else {
231
231
$ 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 ('} ' );
235
235
}
236
236
}
237
237
return $ oAtRule ;
0 commit comments