| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
The magic method __construct() can't be marked with Override attribute.
For example:
class Base {
public $val;
public function __construct() {
$this->val = 0;
}
}
class Derived extends Base {
#[\Override]
public function __construct() {
parent::__construct();
++$this->val;
}
}
In PHP 8.3 this example raises an error message
Fatal error: Derived::__construct() has #[\Override] attribute, but no matching parent method exists
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 194.44.56.106)
----
Manual Page -- https://php.net/manual/en/class.override.php
Edit -- https://main.php.net/note/edit/130361
Del: integrated -- https://main.php.net/note/delete/130361/integrated
Del: useless -- https://main.php.net/note/delete/130361/useless
Del: bad code -- https://main.php.net/note/delete/130361/bad+code
Del: spam -- https://main.php.net/note/delete/130361/spam
Del: non-english -- https://main.php.net/note/delete/130361/non-english
Del: in docs -- https://main.php.net/note/delete/130361/in+docs
Del: other reasons-- https://main.php.net/note/delete/130361
Reject -- https://main.php.net/note/reject/130361
Search -- https://main.php.net/manage/user-notes.php