Skip to content

Commit 6768e3e

Browse files
authored
Merge pull request #19 from Crell/modifier-keywords
Update the abstract/final section to cover all modifier keywords
2 parents 843d379 + 2a5bed5 commit 6768e3e

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

spec.md

+19-6
Original file line numberDiff line numberDiff line change
@@ -620,13 +620,19 @@ public function process(string $algorithm, &...$parts)
620620
}
621621
```
622622

623-
### 4.6 `abstract`, `final`, and `static`
623+
### 4.6 Modifier Keywords
624624

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

628-
When present, the `static` declaration MUST come after the visibility
629-
declaration.
628+
* Inheritance modifier: `abstract` or `final`
629+
* Visibility modifier: `public`, `protected`, or `private`
630+
* Scope modifier: `static`
631+
* Mutation modifier: `readonly`
632+
* Type declaration
633+
* Name
634+
635+
All keywords MUST be on a single line, and MUST be separated by a single space.
630636

631637
```php
632638
<?php
@@ -635,7 +641,9 @@ namespace Vendor\Package;
635641

636642
abstract class ClassName
637643
{
638-
protected static $foo;
644+
protected static readonly string $foo;
645+
646+
final protected int $beep;
639647

640648
abstract protected function zim();
641649

@@ -644,6 +652,11 @@ abstract class ClassName
644652
// method body
645653
}
646654
}
655+
656+
readonly class ValueObject
657+
{
658+
// ...
659+
}
647660
```
648661

649662
### 4.7 Method and Function Calls

0 commit comments

Comments
 (0)