@@ -33,7 +33,7 @@ class Parser {
3333 private $ iLength ;
3434 private $ peekCache = null ;
3535 private $ blockRules ;
36- private $ sizeUnits ;
36+ private $ aSizeUnits ;
3737
3838 public function __construct ($ sText , Settings $ oParserSettings = null ) {
3939 $ this ->sText = $ sText ;
@@ -45,14 +45,13 @@ public function __construct($sText, Settings $oParserSettings = null) {
4545 $ this ->blockRules = explode ('/ ' , AtRule::BLOCK_RULES );
4646
4747 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 ();
5351 }
52+ $ this ->aSizeUnits [$ iSize ][strtolower ($ val )] = $ val ;
5453 }
55- ksort ($ this ->sizeUnits , SORT_NUMERIC );
54+ ksort ($ this ->aSizeUnits , SORT_NUMERIC );
5655 }
5756
5857 public function setCharset ($ sCharset ) {
@@ -408,10 +407,9 @@ private function parseNumericValue($bForColor = false) {
408407 }
409408
410409 $ 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 );
415413 break ;
416414 }
417415 }
@@ -469,11 +467,11 @@ private function identifierIs($sIdentifier, $sMatch) {
469467 ?: preg_match ("/^(- \\w+-)? $ sMatch$/i " , $ sIdentifier ) === 1 ;
470468 }
471469
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 ));
474472 return ($ sPeek == '' )
475473 ? false
476- : $ this ->streql ($ sPeek , $ sString , $ alpha );
474+ : $ this ->streql ($ sPeek , $ sString , $ bCaseInsensitive );
477475 }
478476
479477 private function peek ($ iLength = 1 , $ iOffset = 0 ) {
0 commit comments