Skip to content

Update the abstract/final section to cover all modifier keywords #19

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

Merged
merged 3 commits into from
Jul 17, 2022
Merged
Changes from 2 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
25 changes: 19 additions & 6 deletions spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,19 @@ public function process(string $algorithm, &...$parts)
}
```

### 4.6 `abstract`, `final`, and `static`
### 4.6 Modifier keywords

When present, the `abstract` and `final` declarations MUST precede the
visibility declaration.
Properties and methods of a class have numerous keyword modifiers that alter how the
engine and language handles them. When present, they MUST be in the following order:

When present, the `static` declaration MUST come after the visibility
declaration.
* Inheritance modifier: `abstract` or `final`
* Visibility modifier: `public`, `protected`, or `private`
* Scope modifier: `static`
* Mutation modifier: `readonly`
* Type declaration
* Name

All keywords MUST be on a single line, and MUST be separated by a single space.

```php
<?php
Expand All @@ -594,7 +600,9 @@ namespace Vendor\Package;

abstract class ClassName
{
protected static $foo;
protected static readonly string $foo;

final protected int $beep;

abstract protected function zim();

Expand All @@ -603,6 +611,11 @@ abstract class ClassName
// method body
}
}

readonly class ValueObject
{
// ...
}
```

### 4.7 Method and Function Calls
Expand Down