|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-06-09 01:41 UTC] mail at pmmaga dot net
[2017-06-09 01:44 UTC] daverandom@php.net
-Status: Open
+Status: Not a bug
[2017-06-09 01:44 UTC] daverandom@php.net
[2017-06-09 11:12 UTC] mb at iname dot com
[2017-06-09 11:20 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 20:00:02 2026 UTC |
Description: ------------ The example below produces a fatal error: Fatal error: Call to protected b::b() from invalid context in test.php on line 17 Changing visibility of child's method to public results in b::b() being invoked twice (prints 'ChildChild'). Renaming the child class to anything but 'b' resolves the issue. Test script: --------------- <?php class a { protected function b() { echo 'Parent'; } public function test() { $this->b(); } } class b extends a { protected function b() { echo 'Child'; } } $o = new b(); $o->test(); Expected result: ---------------- The script should print "Child". Alternatively, if methods with same name as class are not allowed, the script should fail at parsing stage. Actual result: -------------- Fatal error: Call to protected b::b() from invalid context in test.php on line 17 If b::b() is set public in child, prints 'ChildChild'