Skip to content

Commit a8d1a28

Browse files
committed
Clarify abstract properties with partial implementation.
1 parent 81328ff commit a8d1a28

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

spec.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,6 @@ A function or method may be referenced in a way that creates a closure out of it
772772

773773
If so, the `...` MUST NOT include any whitespace before or after. That is, the correct format is `foo(...)`.
774774

775-
776775
### 4.9 Property Hooks
777776

778777
Object properties may also include hooks, which have a number of syntactic options.
@@ -897,10 +896,27 @@ class Example
897896
}
898897
```
899898

900-
## 4.10 Interface properties
899+
## 4.10 Interface and abstract properties
901900

902901
Abstract properties may be defined in interfaces or abstract classes, but are required to
903-
specify if they must support `get` operations, `set` operations, or both.
902+
specify if they must support `get` operations, `set` operations, or both. In the case
903+
of abstract classes, they MAY include a body for one or another hook.
904+
905+
If there is a body for any hook, then the entire hook block MUST follow
906+
the same rules as for defined hooks above. The only difference is that
907+
a hook that has no body specified have a single semicolon after the hook
908+
keyword, with no space before it.
909+
910+
```php
911+
abstract class Example {
912+
abstract public string $name {
913+
get => ucfirst($this->name);
914+
set;
915+
}
916+
}
917+
```
918+
919+
If there is no body for either hook, then the following rules apply:
904920

905921
* The operation block MUST be on the same line as the property.
906922
* There MUST be a single space between the property name and the operation block `{}`.

0 commit comments

Comments
 (0)