Skip to content

Commit 2441346

Browse files
committed
Allow abbreviated empty bodies.
1 parent 9dc210d commit 2441346

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

spec.md

+23
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,29 @@ function fooBarBaz($arg1, &$arg2, $arg3 = [])
513513
}
514514
```
515515

516+
If a function or method contains no statements (such as a no-op implementation or when using
517+
constructor property promotion), then the body SHOULD be abbreviated as `{}` and placed on the same
518+
line as the previous symbol, separated by a space. For example:
519+
520+
```php
521+
class Point
522+
{
523+
public function __construct(private int $x, private int $y) {}
524+
525+
// ...
526+
}
527+
```
528+
529+
```php
530+
class Point
531+
{
532+
public function __construct(
533+
public readonly int $x,
534+
public readonly int $y,
535+
) {}
536+
}
537+
```
538+
516539
### 4.5 Method and Function Arguments
517540

518541
In the argument list, there MUST NOT be a space before each comma, and there

0 commit comments

Comments
 (0)