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