note 129990 added to language.oop5.inheritance
| From: | ignacio@inek.com.ar | Date: | Tue, 21 Jan 2025 15:36:26 +0000 |
| Subject: | note 129990 added to language.oop5.inheritance | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221806@lists.php.net to get a copy of this message | ||
In case you have a public readonly property in a class you need to extend, adding other properties,
this can be a way to do it:
<?php
class A {
public function __construct(
public readonly int $prop
) {}
}
class B extends A {
public function __construct(
int $prop,
public readonly int $prop2
) {
parent::__construct($prop);
}
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 181.228.58.62)
----
Manual Page -- https://php.net/manual/en/language.oop5.inheritance.php
Edit -- https://main.php.net/note/edit/129990
Del: integrated -- https://main.php.net/note/delete/129990/integrated
Del: useless -- https://main.php.net/note/delete/129990/useless
Del: bad code -- https://main.php.net/note/delete/129990/bad+code
Del: spam -- https://main.php.net/note/delete/129990/spam
Del: non-english -- https://main.php.net/note/delete/129990/non-english
Del: in docs -- https://main.php.net/note/delete/129990/in+docs
Del: other reasons-- https://main.php.net/note/delete/129990
Reject -- https://main.php.net/note/reject/129990
Search -- https://main.php.net/manage/user-notes.php