Bug #69766 [Opn->Ver]: protected property can be accesed from another class that has the same parent
| From: | cmb@php.net | Date: | Wed, 10 Jun 2015 00:34:15 +0000 |
| Subject: | Bug #69766 [Opn->Ver]: 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-193269@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
Updated by: cmb@php.net
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
+Status: Verified
Type: Bug
Package: Scripting Engine problem
Operating System: Any
PHP Version: 5.5.26RC1
Block user comment: N
Private report: N
New Comment:
Verified: <http://3v4l.org/jhq6h>. Apparently, the
behavior has changed as of PHP 5.2.0.
Previous Comments:
------------------------------------------------------------------------
[2015-06-06 17:29:59] tornike dot comaia dot mail at gmail dot com
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
------------------------------------------------------------------------
[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