Bug #69766 [Opn]: protected property can be accesed from another class that has the same parent

From: Date: Sat, 06 Jun 2015 17:29:59 +0000
Subject: Bug #69766 [Opn]: protected property can be accesed from another class that has the same parent
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193176@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69766&edit=1 ID: 69766 User updated by: tornike dot comaia dot mail at gmail dot com Reported by: tornike dot comaia dot mail at gmail dot com Summary: protected property can be accesed from another class that has the same parent Status: Open Type: Bug Package: Scripting Engine problem Operating System: Any PHP Version: 5.5.26RC1 Block user comment: N Private report: N New Comment: It is possible to access the protected property of class A within the class B if both classes have the same parent - C, that defines the property, but it is possible unless the property is overriden in child class A or B Previous Comments: ------------------------------------------------------------------------ [2015-06-06 17:26:47] tornike dot comaia dot mail at gmail dot com Description: ------------ It is possible to access the protected property of class A within the class B if both classes have the same parent - C, that defined the property unless the property is overriden in child class A or B Test script: --------------- <?php class C { protected $data; } class A extends C { } class B extends C { public function test() { $obj = new A(); $obj->data = 'Hello world'; echo $obj->data; } } ?> Expected result: ---------------- Unless the class B is not the child of the class A, an error must be risen when trying to access the protected property of the class A within class B ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69766&edit=1

« previous php.bugs (#193176) next »