Skip to content

Commit bdbf3ee

Browse files
authored
Recommend omitting wrapping parenthesis when immediately calling a method on a new instance
1 parent 396af44 commit bdbf3ee

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

spec.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,19 @@ separated by a space. For example:
308308
class MyException extends \RuntimeException {}
309309
```
310310

311+
When calling a method immeditely after instantiating a new class, the instantiation SHOULD NOT be wrapped in
312+
parenthesis. For example:
313+
314+
```php
315+
$methodResult = new Foo()->someMethod();
316+
```
317+
318+
And the following SHOULD be avoided:
319+
320+
```php
321+
$methodResult = (new Foo())->someMethod();
322+
```
323+
311324
### 4.1 Extends and Implements
312325

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

0 commit comments

Comments
 (0)