|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-10-23 16:09 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 11:00:02 2025 UTC |
Description: ------------ Availability to call protected method from outside class or its descendants. Reproduce code: --------------- <?php class a { protected function aa() { echo "a-aa\n"; } } class b extends a { protected function aa() { echo "b-aa\n"; } } // Extends is affects on the behaviour: // - When "c" extends the "a" - not correct behaviour: working as in "Actual result" // - When "c" NOT extends the "a" - correct behaviour: working as in "Expected result" class c extends a { public function cc() { $obj = new a(); $obj->aa(); $obj2 = new b(); $obj2->aa(); } } $c = new c(); $c->cc(); ?> Expected result: ---------------- Fatal error: Call to protected method a::aa() from context 'c' Actual result: -------------- a-aa b-aa