|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-07-23 08:31 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2019-07-23 08:31 UTC] cmb@php.net
[2019-07-23 08:33 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 05:00:01 2025 UTC |
Description: ------------ Issues with overriding parameters of the same function with different types is causing a compilation errors that I don't know how to fix. If there is a fix, can you please let me know and put it somewhere on the Internet so Google and I can find it. Test script: --------------- class Fie{ protected $value; function copy(Fie $new) : Fie { $this->value = $new->value; return $this; } } class Foh extends Fie{ protected $field; function copy(Foh $new) : Foh { $this->field = $new->field; return parent::copy($new); } } Expected result: ---------------- Not needing to totally rewrite Fie's code in Foh. $n = new Foh(); $b = new Foh(); $b->copy($n); Actual result: -------------- PHP Fatal error: Declaration of Foh::copy(Foh $new): Foh must be compatible with Fie::copy(Fie $new): Fie in test_file.php on line 29 Fatal error: Declaration of Foh::copy(Foh $new): Foh must be compatible with Fie ::copy(Fie $new): Fie in test_file.php on line 29