|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-03-27 17:42 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2017-03-27 17:42 UTC] cmb@php.net
[2017-03-27 17:47 UTC] spam2 at rhsoft dot net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 10:00:01 2025 UTC |
Description: ------------ it's annoying enough at all that you get warnings when method declarations are not 100% identical in case of adding param-type-hints in the underlying classes without change all extended classes at the same time but in case of return types a fatal error is just unacceptable (and no it also don't make sense that you can't skip optional params in a extended class or add additional ones to change the behavior of the parent-call) ________________________________ unacceptable because you can't add them at all without hard breaking every dervied code while in case of the annoying warnings you can at least adopt the changes while watching errorlog and sites ar enot completly broken [harry@srv-rhsoft:/downloads]$ php test.php Fatal error: Declaration of test2::test() must be compatible with test1::test(): array in /mnt/data/downloads/test.php on line 2 Test script: --------------- [harry@srv-rhsoft:/downloads]$ cat test.php <?php class test2 extends test1 { public function test() { } } class test1 { public function test(): array { } } ?> Expected result: ---------------- no error and in the best case even no warning at all, extedning a class and override methods in doubt always imply changed behavior with or without changing method signatures Actual result: -------------- Fatal error: Declaration of test2::test() must be compatible with test1::test(): array in /mnt/data/downloads/test.php on line 2