@@ -1417,7 +1417,7 @@ private function parseStringLiteralExpression2($parentNode): StringLiteral {
1417
1417
case TokenKind::DollarOpenBraceToken:
1418
1418
case TokenKind::OpenBraceDollarToken:
1419
1419
$ expression ->children [] = $ this ->eat (TokenKind::DollarOpenBraceToken, TokenKind::OpenBraceDollarToken);
1420
- /**
1420
+ /**
1421
1421
* @phpstan-ignore-next-line "Strict comparison using
1422
1422
* === between 403|404 and 408 will always evaluate to
1423
1423
* false" is wrong because those tokens were eaten above
@@ -2802,10 +2802,6 @@ private function parseListIntrinsicExpression($parentNode) {
2802
2802
return $ listExpression ;
2803
2803
}
2804
2804
2805
- private function isArrayElementStart ($ token ) {
2806
- return ($ this ->isArrayElementStartFn ())($ token );
2807
- }
2808
-
2809
2805
private function isArrayElementStartFn () {
2810
2806
return function ($ token ) {
2811
2807
return $ token ->kind === TokenKind::AmpersandToken || $ token ->kind === TokenKind::DotDotDotToken || $ this ->isExpressionStart ($ token );
@@ -3370,6 +3366,16 @@ private function parseClassConstDeclaration($parentNode, $modifiers) {
3370
3366
3371
3367
$ classConstDeclaration ->modifiers = $ modifiers ;
3372
3368
$ classConstDeclaration ->constKeyword = $ this ->eat1 (TokenKind::ConstKeyword);
3369
+ // Handle class constant declarations such as `const X|Y Z = 123;` or `const X = 123;`.
3370
+ // This is similar to lookahead().
3371
+ $ startPos = $ this ->lexer ->getCurrentPosition ();
3372
+ $ startToken = $ this ->token ;
3373
+ $ classConstDeclaration ->typeDeclarationList = $ this ->tryParseParameterTypeDeclarationList ($ classConstDeclaration );
3374
+ if (in_array ($ this ->token ->kind , [TokenKind::EqualsToken, TokenKind::CommaToken, TokenKind::SemicolonToken]) && $ this ->lexer ->getCurrentPosition () <= $ startPos + 1 ) {
3375
+ $ classConstDeclaration ->typeDeclarationList = null ;
3376
+ $ this ->lexer ->setCurrentPosition ($ startPos );
3377
+ $ this ->token = $ startToken ;
3378
+ }
3373
3379
$ classConstDeclaration ->constElements = $ this ->parseConstElements ($ classConstDeclaration );
3374
3380
$ classConstDeclaration ->semicolon = $ this ->eat1 (TokenKind::SemicolonToken);
3375
3381
0 commit comments