[DOC-CVS] [doc-en] master: add missing string type for $title in Asymmetric Property inheritance example (#4833)
[email protected] (Hendrik Becker via GitHub)
| Newsgroups | php.doc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: Hendrik Becker (LuckyFellow)
Committer: GitHub (web-flow)
Pusher: Crell
Date: 2025-10-03T09:40:45-05:00
Commit: https://github.com/php/doc-en/commit/5c04cf0fd637b258d2a3bf7f4b7aba1beef6d823
Raw diff: https://github.com/php/doc-en/commit/5c04cf0fd637b258d2a3bf7f4b7aba1beef6d823.diff
add missing string type for $title in Asymmetric Property inheritance example (#4833)
Add the missing string type to $title in the SpecialBook class. The parent defines $title as string; the child must not drop the declared type.
Changed paths:
M language/oop5/visibility.xml
Diff:
diff --git a/language/oop5/visibility.xml b/language/oop5/visibility.xml
index 8898d01becfd..465f7f87fe5c 100644
--- a/language/oop5/visibility.xml
+++ b/language/oop5/visibility.xml
@@ -194,7 +194,7 @@ class Book
class SpecialBook extends Book
{
- public protected(set) $title; // OK, as reading is wider and writing the same.
+ public protected(set) string $title; // OK, as reading is wider and writing the same.
public string $author; // OK, as reading is the same and writing is wider.
public protected(set) int $pubYear; // Fatal Error. private(set) properties are final.
}