Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/grammars/lexemes.pp3
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
// Literals and names
// -----------------------------------------------------------------------------

%token T_FLOAT [+\-]?(?:(?:[0-9]++(_[0-9]++)*\.[0-9]*+(_[0-9]++)*(?:e[+\-]?[0-9]++(_[0-9]++)*)?)|(?:[0-9]*+(_[0-9]++)*\.[0-9]++(_[0-9]++)*(?:e[+\-]?[0-9]++(_[0-9]++)*)?)|(?:[0-9]++(_[0-9]++)*e[+\-]?[0-9]++(_[0-9]++)*))
%token T_FLOAT [+\-]?(?:(?:[0-9]++(_[0-9]++)*\.(?:[0-9]++(_[0-9]++)*)?(?:e[+\-]?[0-9]++(_[0-9]++)*)?)|(?:[0-9]*+(_[0-9]++)*\.[0-9]++(_[0-9]++)*(?:e[+\-]?[0-9]++(_[0-9]++)*)?)|(?:[0-9]++(_[0-9]++)*e[+\-]?[0-9]++(_[0-9]++)*))
%token T_INTEGER [+\-]?(?:(?:0b[0-1]++(_[0-1]++)*)|(?:0o[0-7]++(_[0-7]++)*)|(?:0x[0-9a-f]++(_[0-9a-f]++)*)|(?:[0-9]++(_[0-9]++)*))
%token T_SINGLE_QUOTED_STRING '(?:\\[^\r\n]|[^'\r\n\\])*+'
%token T_DOUBLE_QUOTED_STRING "(?:\\[^\r\n]|[^"\r\n\\])*+"
Expand Down
2 changes: 1 addition & 1 deletion src/Lexer/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private function generateRegexp(): string
self::TOKEN_DOCTRINE_TAG => '@[a-z_\\\\][a-z0-9_\:\\\\]*[a-z_][a-z0-9_]*',
self::TOKEN_PHPDOC_EOL => '\\r?+\\n[\\x09\\x20]*+(?:\\*(?!/)\\x20?+)?',

self::TOKEN_FLOAT => '[+\-]?(?:(?:[0-9]++(?:_[0-9]++)*\\.[0-9]*+(?:_[0-9]++)*(?:e[+\-]?[0-9]++(?:_[0-9]++)*)?)|(?:[0-9]*+(?:_[0-9]++)*\\.[0-9]++(?:_[0-9]++)*(?:e[+\-]?[0-9]++(?:_[0-9]++)*)?)|(?:[0-9]++(?:_[0-9]++)*e[+\-]?[0-9]++(?:_[0-9]++)*))',
self::TOKEN_FLOAT => '[+\-]?(?:(?:[0-9]++(?:_[0-9]++)*\\.(?:[0-9]++(?:_[0-9]++)*)?(?:e[+\-]?[0-9]++(?:_[0-9]++)*)?)|(?:[0-9]*+(?:_[0-9]++)*\\.[0-9]++(?:_[0-9]++)*(?:e[+\-]?[0-9]++(?:_[0-9]++)*)?)|(?:[0-9]++(?:_[0-9]++)*e[+\-]?[0-9]++(?:_[0-9]++)*))',
self::TOKEN_INTEGER => '[+\-]?(?:(?:0b[0-1]++(?:_[0-1]++)*)|(?:0o[0-7]++(?:_[0-7]++)*)|(?:0x[0-9a-f]++(?:_[0-9a-f]++)*)|(?:[0-9]++(?:_[0-9]++)*))',
self::TOKEN_SINGLE_QUOTED_STRING => '\'(?:\\\\[^\\r\\n]|[^\'\\r\\n\\\\])*+\'',
self::TOKEN_DOUBLE_QUOTED_STRING => '"(?:\\\\[^\\r\\n]|[^"\\r\\n\\\\])*+"',
Expand Down
18 changes: 18 additions & 0 deletions tests/PHPStan/Parser/TypeParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1976,6 +1976,24 @@ public function provideParseData(): array
'123_456.789_012',
new ConstTypeNode(new ConstExprFloatNode('123456.789012')),
],
[
'1.',
new ConstTypeNode(new ConstExprFloatNode('1.')),
],
[
'1.e2',
new ConstTypeNode(new ConstExprFloatNode('1.e2')),
],
[
'1._5',
new ConstTypeNode(new ConstExprFloatNode('1.')),
Lexer::TOKEN_IDENTIFIER,
],
[
'0._1e+7',
new ConstTypeNode(new ConstExprFloatNode('0.')),
Lexer::TOKEN_IDENTIFIER,
],
[
'+0x10_20|+8e+2 | -0b11',
new UnionTypeNode([
Expand Down
Loading