Lexer: do not use \h as it depends on locale

This commit is contained in:
Jan Tvrdik 2018-01-04 10:24:37 +01:00
parent 46fef4d36b
commit 02f909f134
2 changed files with 8 additions and 2 deletions

View File

@ -129,7 +129,7 @@ class Lexer
self::TOKEN_OPEN_PHPDOC => '/\\*\\*(?=\\s)',
self::TOKEN_CLOSE_PHPDOC => '\\*/',
self::TOKEN_PHPDOC_TAG => '@[a-z-]++',
self::TOKEN_PHPDOC_EOL => '\\r?+\\n\\h*+(?:\\*(?!/)\\h*+)?',
self::TOKEN_PHPDOC_EOL => '\\r?+\\n[\\x09\\x20]*+(?:\\*(?!/))?',
self::TOKEN_FLOAT => '(?:-?[0-9]++\\.[0-9]*+(?:e-?[0-9]++)?)|(?:-?[0-9]*+\\.[0-9]++(?:e-?[0-9]++)?)|(?:-?[0-9]++e-?[0-9]++)',
self::TOKEN_INTEGER => '-?[0-9]++',
@ -140,7 +140,7 @@ class Lexer
self::TOKEN_THIS_VARIABLE => '\\$this\\b',
self::TOKEN_VARIABLE => '\\$[a-z_\\x7F-\\xFF][0-9a-z_\\x7F-\\xFF]*+',
self::TOKEN_HORIZONTAL_WS => '\\h++',
self::TOKEN_HORIZONTAL_WS => '[\\x09\\x20]++',
// anything but TOKEN_CLOSE_PHPDOC or TOKEN_HORIZONTAL_WS or TOKEN_EOL
self::TOKEN_OTHER => '(?:(?!\\*/)[^\\s])++',

View File

@ -299,6 +299,12 @@ class TypeParserTest extends \PHPUnit\Framework\TestCase
new IdentifierTypeNode('array'),
Lexer::TOKEN_OPEN_SQUARE_BRACKET,
],
[
"?\t\xA009", // edge-case with \h
new NullableTypeNode(
new IdentifierTypeNode("\xA009")
),
],
];
}