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

Recommend omitting wrapping parenthesis when immediately calling a method on a new instance #110

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,23 @@ separated by a space. For example:
class MyException extends \RuntimeException {}
```

When accessing a class member immeditely after instantiating a new class, the instantiation SHOULD NOT be wrapped in
parenthesis. For example:

```php
new Foo()->someMethod();
new Foo()->someStaticMethod();
new Foo()->someProperty;
new Foo()::someStaticProperty;
new Foo()::SOME_CONSTANT;
```

And the following SHOULD be avoided:

```php
(new Foo())->someMethod();
```

### 4.1 Extends and Implements

The `extends` and `implements` keywords MUST be declared on the same line as
Expand Down