Skip to content

PHP8.4: Support new without parenthesis #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dantleech
Copy link
Contributor

(from Phpactor's fork - not tested extensively)

@@ -3289,6 +3290,11 @@ private function parseObjectCreationExpression($parentNode) {
$objectCreationExpression->classMembers = $this->parseClassMembers($objectCreationExpression);
}

// PHP8.4 new with no parenthesis
if ($this->getCurrentToken()->kind === TokenKind::ArrowToken) {
return $this->parsePostfixExpressionRest($objectCreationExpression);
Copy link
Contributor Author

@dantleech dantleech Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line with the rest of this libaray this should probably have a run time php_version() > 80400?

(incidentally would be good to refactor so that it didn't depend on the runtime PHP version)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for being able to configure at what PHP level the parser works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants