Skip to content

Commit 5873b30

Browse files
committed
PHP8.4: Support new without parenthesis
1 parent 4fd2db9 commit 5873b30

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/Parser.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -3047,7 +3047,8 @@ private function parsePostfixExpressionRest($expression, $allowUpdateExpression
30473047
$expression instanceof SubscriptExpression ||
30483048
$expression instanceof ScopedPropertyAccessExpression ||
30493049
$expression instanceof StringLiteral ||
3050-
$expression instanceof ArrayCreationExpression
3050+
$expression instanceof ArrayCreationExpression ||
3051+
$expression instanceof ObjectCreationExpression
30513052
)) {
30523053
return $expression;
30533054
}
@@ -3289,6 +3290,11 @@ private function parseObjectCreationExpression($parentNode) {
32893290
$objectCreationExpression->classMembers = $this->parseClassMembers($objectCreationExpression);
32903291
}
32913292

3293+
// PHP8.4 new with no parenthesis
3294+
if ($this->getCurrentToken()->kind === TokenKind::ArrowToken) {
3295+
return $this->parsePostfixExpressionRest($objectCreationExpression);
3296+
}
3297+
32923298
return $objectCreationExpression;
32933299
}
32943300

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
new Foobar()->bar();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
new Foobar()->bar();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
new Foobar()->bar();

0 commit comments

Comments
 (0)