-
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
fix: Unify the usage of () after class instances (including anonymous classes) #24
fix: Unify the usage of () after class instances (including anonymous classes) #24
Conversation
… classes) According to chapter 4: > ## 4. Classes, Properties, and Methods > > The term "class" refers to all classes, interfaces, and traits. > > Any closing brace MUST NOT be followed by any comment or statement on the same line. > > When instantiating a new class, parentheses MUST always be present even when there are no arguments passed to the constructor. This MR updates the spec to adhere to that rule on anonymous classes too. (taken from moved from php-fig/fig-standards#1283 but also builds upon php-fig#17)
I'm not actually sure about doing () on an anon class with no constructor. I don't see that style in practice in the wild, and I don't see how it adds much. |
I fully understand and might even agree with you but the PSR isn't clear ATM and with tools like php-cs-fixer 'interpretting' the psr as they do, it seems like it will place those parenthesis according to their interpretation. My interpretation follows their reasoning as mentioned in chapter four and without the specific changes mentioned in the closures section to which anon-classes refers. Thus confusion ;) |
see also php-fig/fig-standards#1206 which:
|
I agree with @Crell, I'd prefer seeing this go the other way with a statement allowing the parenthesis be omitted when no arguments are passed. |
I agree with @Crell and @KorvinSzanto on it. |
@fruitl00p Would you be able to adjust this PR to allow omitting parenthesis when no arguments are passed? |
Very much.. but am on vacay.. feel free to highjack and get this 'sorted' officially |
New PR filed to go the other way. |
According to chapter 4:
This MR updates the spec to adhere to that rule on anonymous classes too.
(taken from moved from php-fig/!1283)
The original MR on PHP-Fig also mentioned short closures but !17 already fixes this.