|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-01-04 19:05 UTC] after89 at gmail dot com
Description: ------------ Accessing protected property defined in superclass of current context on object that is sibling of current context class (extends one of the base class) is not possible (https://3v4l.org/BODds). Althrough accessing method in the same manner is valid (https://3v4l.org/8DNBa). Both of this behaviours should be consistent. Test script: --------------- <?php class Base { protected $foo = 'Base'; } class Other extends Base { protected $foo = 'Other'; } class Child extends Base { public function bar() { $otherBase = new Other(); echo $otherBase->foo; } } $child = new Child(); $child->bar(); PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 20 03:00:01 2025 UTC |
Valid code for method: <?php class Base { protected function foo() {} } class Other extends Base { protected function foo() { echo "OK"; } } class Child extends Base { public function bar() { $otherBase = new Other(); $otherBase->foo(); } } $child = new Child(); $child->bar();