diff --git a/spec.md b/spec.md index 761d008..2d8f086 100644 --- a/spec.md +++ b/spec.md @@ -297,6 +297,14 @@ there are no arguments passed to the constructor. new Foo(); ``` +If class contains no additional declarations (such as an exception that exists only extend another exception with a new type), +then the body of the class SHOULD be abbreviated as `{}` and placed on the same line as the previous symbol, +separated by a space. For example: + +```php +class MyException extends \RuntimeException {} +``` + ### 4.1 Extends and Implements The `extends` and `implements` keywords MUST be declared on the same line as @@ -513,6 +521,29 @@ function fooBarBaz($arg1, &$arg2, $arg3 = []) } ``` +If a function or method contains no statements (such as a no-op implementation or when using +constructor property promotion), then the body SHOULD be abbreviated as `{}` and placed on the same +line as the previous symbol, separated by a space. For example: + +```php +class Point +{ + public function __construct(private int $x, private int $y) {} + + // ... +} +``` + +```php +class Point +{ + public function __construct( + public readonly int $x, + public readonly int $y, + ) {} +} +``` + ### 4.5 Method and Function Parameters In the argument list, there MUST NOT be a space before each comma, and there