-
Notifications
You must be signed in to change notification settings - Fork 26
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
New PHP 8.4 Syntax: new MyClass()->method() without parentheses #89
Comments
What should we say here? "Favor using the non-parens version if you can", or is there more to say on the matter? |
I'm of the opinion that it's simpler to see at a glance that a new instantiation is happening with wrapping parenthesis, but I don't think it's so much of an improvement that it justifies adding the wrapper in every situation. Given that this is technically existing syntax, we'd need to go to
|
As usual, I don't think "never use this fancy new syntax that was just approved" is going to fly. The RFC passed 25 to 4. :-) So let's take "MUST NOT" use it off the table, as it's clear people want to use it. The question is whether we encourage it, or stay silent. I'm leaning toward silent at the moment, but could be convinced otherwise. (We can always say something about it in a future version.) |
I agree, but I think you're misinterpreting my comment. I said "MUST NOT use parenthesis" which would mean we advocate for the thing that passed 25 to 4. I'm saying that we cannot advocate stronger than a SHOULD until 3.0 unless we advocate for the thing that requires no code change, which I agree we shouldn't do. |
Oh! I see what you mean. I'm open to a SHOULD here if the rest of the WG is. |
@Crell sounds more weighted than MUST for the case 👍 |
new Foo()->baz()
will be allowed in PHP 8.4, we should cover it in the next version of PER-CS.To me this is similar to the question of
new Foo
vsnew Foo()
where we decided the latter was better for readability: https://github.com/php-fig/per-coding-style/blob/master/spec.md#4-classes-properties-and-methodsThe text was updated successfully, but these errors were encountered: