Bug #74932 [Opn->Nab]: ascending visibility
| From: | cmb@php.net | Date: | Fri, 21 Jul 2017 18:42:59 +0000 |
| Subject: | Bug #74932 [Opn->Nab]: ascending visibility | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210171@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74932&edit=1
ID: 74932
Updated by: cmb@php.net
Reported by: vuk dot kulvar+php at gmail dot com
Summary: ascending visibility
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: Windows 10
PHP Version: 7.1.7
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is expected, but currently undocumented[1] and maybe
undesirable behavior. I don't think we can change that in a minor
version.
Related to bug #50892.
[1]
Some stupid broke the documentation in
<http://svn.php.net/viewvc?view=revision&revision=337719>
Fixed with <http://svn.php.net/viewvc?view=revision&revision=342692>
Previous Comments:
------------------------------------------------------------------------
[2017-07-21 18:40:38] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=342692
Log: Reverted revision(s) 337719 from phpdoc/en/trunk/language/oop5/visibility.xml:
Protected members cannot be accessed by parent classes
--
Provided by anonymous 62572 (tunght13488@gmail.com)
........
If we like it or not, that's how it is. See also bug #74932.
------------------------------------------------------------------------
[2017-07-16 22:17:35] vuk dot kulvar+php at gmail dot com
Description:
------------
When a parent class has a static method.
From the static method of the parent class, you can access protected methods & properties added
from the child class.
I'm not talking about redeclaration, but methods & properties that doesn't exists in
the parent class.
Test script:
---------------
class Alpha {
public static function Render($object) {
echo $foo->property;
echo $object->method();
}
}
class Omega extends Alpha {
protected $property = 'Property';
protected function method() {
return 'Method';
}
}
Alpha::Render(new Omega());
Expected result:
----------------
Fatal error: Cannot access protected property Omega::$property
Fatal error: Call to protected method Omega::method()
Actual result:
--------------
Property
Method
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74932&edit=1