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

Allow abbreviated empty bodies. #44

Merged
merged 3 commits into from
Nov 10, 2022
Merged
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
31 changes: 31 additions & 0 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down