Skip to content
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

[PHP 8.4] new MyClass()->method() without parentheses #8701

Open
ruudk opened this issue Jun 28, 2024 · 5 comments
Open

[PHP 8.4] new MyClass()->method() without parentheses #8701

ruudk opened this issue Jun 28, 2024 · 5 comments
Labels

Comments

@ruudk
Copy link
Contributor

ruudk commented Jun 28, 2024

Feature Request

We should create a rule for this RFC:

https://wiki.php.net/rfc/new_without_parentheses

Diff

-$request = (new Request())->withMethod('GET')->withUri('/hello-world');
+$request = new Request()->withMethod('GET')->withUri('/hello-world');
@ruudk ruudk added the feature label Jun 28, 2024
@samsonasik
Copy link
Member

I think that need to be feature request for nikic/php-parser

@TomasVotruba
Copy link
Member

I already asked in php-parser last week. This will most likely require php-paser 5, PHPStan 2 and then Rector 2 due to BC breaks.

nikic/PHP-Parser@7b0384c#commitcomment-143390979

@samsonasik
Copy link
Member

I created downgrade PR rule first:

to allow code to be downgraded on the first place.

@gnutix
Copy link
Contributor

gnutix commented Jan 13, 2025

This will most likely require php-paser 5, PHPStan 2 and then Rector 2 due to BC breaks.

@samsonasik it seems to me that these criterion are now met. Is there anything more needed to create this new rule ?

@samsonasik
Copy link
Member

The no parenthesis syntax is not only on method call, but also static call, property fetch, etc, per rfc

https://wiki.php.net/rfc/new_without_parentheses

which downgrade need to be exists first so full feature downgrade need to be exists first to avoid flip-flop lookup.

I am not fan of this syntax sugar, but feel free to create PR if you're interested, always start with improving downgrade part, there is starting point you can look:

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

No branches or pull requests

4 participants