@@ -33,7 +33,7 @@ class Parser {
33
33
private $ iLength ;
34
34
private $ peekCache = null ;
35
35
private $ blockRules ;
36
- private $ sizeUnits ;
36
+ private $ aSizeUnits ;
37
37
38
38
public function __construct ($ sText , Settings $ oParserSettings = null ) {
39
39
$ this ->sText = $ sText ;
@@ -45,14 +45,13 @@ public function __construct($sText, Settings $oParserSettings = null) {
45
45
$ this ->blockRules = explode ('/ ' , AtRule::BLOCK_RULES );
46
46
47
47
foreach (explode ('/ ' , Size::ABSOLUTE_SIZE_UNITS .'/ ' .Size::RELATIVE_SIZE_UNITS .'/ ' .Size::NON_SIZE_UNITS ) as $ val ) {
48
- $ size = strlen ($ val );
49
- if (isset ($ this ->sizeUnits [$ size ])) {
50
- $ this ->sizeUnits [$ size ][] = $ val ;
51
- } else {
52
- $ this ->sizeUnits [$ size ] = array ($ val );
48
+ $ iSize = strlen ($ val );
49
+ if (!isset ($ this ->aSizeUnits [$ iSize ])) {
50
+ $ this ->aSizeUnits [$ iSize ] = array ();
53
51
}
52
+ $ this ->aSizeUnits [$ iSize ][strtolower ($ val )] = $ val ;
54
53
}
55
- ksort ($ this ->sizeUnits , SORT_NUMERIC );
54
+ ksort ($ this ->aSizeUnits , SORT_NUMERIC );
56
55
}
57
56
58
57
public function setCharset ($ sCharset ) {
@@ -408,10 +407,9 @@ private function parseNumericValue($bForColor = false) {
408
407
}
409
408
410
409
$ sUnit = null ;
411
- foreach ($ this ->sizeUnits as $ len => $ val ) {
412
- if (($ pos = array_search ($ this ->peek ($ len ), $ val )) !== false ) {
413
- $ sUnit = $ val [$ pos ];
414
- $ this ->consume ($ len );
410
+ foreach ($ this ->aSizeUnits as $ iLength => &$ aValues ) {
411
+ if (($ sUnit = @$ aValues [strtolower ($ this ->peek ($ iLength ))]) !== null ) {
412
+ $ this ->consume ($ iLength );
415
413
break ;
416
414
}
417
415
}
@@ -469,11 +467,11 @@ private function identifierIs($sIdentifier, $sMatch) {
469
467
?: preg_match ("/^(- \\w+-)? $ sMatch$/i " , $ sIdentifier ) === 1 ;
470
468
}
471
469
472
- private function comes ($ sString , $ alpha = false ) {
473
- $ sPeek = $ this ->peek ($ alpha ? $ this -> strlen ( $ sString ) : strlen ($ sString ));
470
+ private function comes ($ sString , $ bCaseInsensitive = false ) {
471
+ $ sPeek = $ this ->peek (strlen ($ sString ));
474
472
return ($ sPeek == '' )
475
473
? false
476
- : $ this ->streql ($ sPeek , $ sString , $ alpha );
474
+ : $ this ->streql ($ sPeek , $ sString , $ bCaseInsensitive );
477
475
}
478
476
479
477
private function peek ($ iLength = 1 , $ iOffset = 0 ) {
0 commit comments