@@ -516,11 +516,8 @@ public function parseNumber()
516516 $ state = 1 ;
517517 for (; $ this ->last < $ this ->len ; ++$ this ->last ) {
518518 if ($ state === 1 ) {
519- if ($ this ->str [$ this ->last ] === '+ ' ) {
520- // Do nothing.
521- } elseif ($ this ->str [$ this ->last ] === '- ' ) {
519+ if ($ this ->str [$ this ->last ] === '- ' ) {
522520 $ flags |= Token::FLAG_NUMBER_NEGATIVE ;
523- // Do nothing.
524521 } elseif (($ this ->str [$ this ->last ] === '0 ' ) && ($ this ->last + 1 < $ this ->len )
525522 && (($ this ->str [$ this ->last + 1 ] === 'x ' ) || ($ this ->str [$ this ->last + 1 ] === 'X ' ))
526523 ) {
@@ -530,36 +527,33 @@ public function parseNumber()
530527 $ state = 3 ;
531528 } elseif ($ this ->str [$ this ->last ] === '. ' ) {
532529 $ state = 4 ;
533- } else {
530+ } elseif ($ this ->str [$ this ->last ] !== '+ ' ) {
531+ // `+` is a valid character in a number.
534532 break ;
535533 }
536534 } elseif ($ state === 2 ) {
537535 $ flags |= Token::FLAG_NUMBER_HEX ;
538- if ((($ this ->str [$ this ->last ] >= '0 ' ) && ($ this ->str [$ this ->last ] <= '9 ' ))
536+ if (!( (($ this ->str [$ this ->last ] >= '0 ' ) && ($ this ->str [$ this ->last ] <= '9 ' ))
539537 || (($ this ->str [$ this ->last ] >= 'A ' ) && ($ this ->str [$ this ->last ] <= 'F ' ))
540- || (($ this ->str [$ this ->last ] >= 'a ' ) && ($ this ->str [$ this ->last ] <= 'f ' ))
538+ || (($ this ->str [$ this ->last ] >= 'a ' ) && ($ this ->str [$ this ->last ] <= 'f ' )))
541539 ) {
542- // Do nothing.
543- } else {
544540 break ;
545541 }
546542 } elseif ($ state === 3 ) {
547- if (($ this ->str [$ this ->last ] >= '0 ' ) && ($ this ->str [$ this ->last ] <= '9 ' )) {
548- // Do nothing.
549- } elseif ($ this ->str [$ this ->last ] === '. ' ) {
543+ if ($ this ->str [$ this ->last ] === '. ' ) {
550544 $ state = 4 ;
551545 } elseif (($ this ->str [$ this ->last ] === 'e ' ) || ($ this ->str [$ this ->last ] === 'E ' )) {
552546 $ state = 5 ;
553- } else {
547+ } elseif (($ this ->str [$ this ->last ] < '0 ' ) || ($ this ->str [$ this ->last ] > '9 ' )) {
548+ // Just digits and `.`, `e` and `E` are valid characters.
554549 break ;
555550 }
556551 } elseif ($ state === 4 ) {
557552 $ flags |= Token::FLAG_NUMBER_FLOAT ;
558- if (($ this ->str [$ this ->last ] >= '0 ' ) && ($ this ->str [$ this ->last ] <= '9 ' )) {
559- // Do nothing.
560- } elseif (($ this ->str [$ this ->last ] === 'e ' ) || ($ this ->str [$ this ->last ] === 'E ' )) {
553+ if (($ this ->str [$ this ->last ] === 'e ' ) || ($ this ->str [$ this ->last ] === 'E ' )) {
561554 $ state = 5 ;
562- } else {
555+ } elseif (($ this ->str [$ this ->last ] < '0 ' ) || ($ this ->str [$ this ->last ] > '9 ' )) {
556+ // Just digits, `e` and `E` are valid characters.
563557 break ;
564558 }
565559 } elseif ($ state === 5 ) {
@@ -572,9 +566,8 @@ public function parseNumber()
572566 break ;
573567 }
574568 } elseif ($ state === 6 ) {
575- if (($ this ->str [$ this ->last ] >= '0 ' ) && ($ this ->str [$ this ->last ] <= '9 ' )) {
576- // Do nothing.
577- } else {
569+ if (($ this ->str [$ this ->last ] < '0 ' ) || ($ this ->str [$ this ->last ] > '9 ' )) {
570+ // Just digits are valid characters.
578571 break ;
579572 }
580573 }
0 commit comments