Edit report at https://bugs.php.net/bug.php?id=62814&edit=1
ID: 62814
Comment by: resha dot ru at gmail dot com
Reported by: resha dot ru at gmail dot com
Summary: It is possible to stiffen child class members
visibility
Status: Open
Type: Bug
Package: Class/Object related
Operating System: Linux
PHP Version: 5.3.15
Block user comment: N
Private report: N
New Comment:
Sorry, it should be:
class F extends D
{
private function test() { } // stiffen visibility from public to private
(unexpected)
}
But nevertheless.
Previous Comments:
------------------------------------------------------------------------
[2012-08-14 09:48:17] resha dot ru at gmail dot com
Description:
------------
It is possible to stiffen visibility (from public to protected, from public to
private and from protected to private) if any of parent classes has private
modifier.
Test script:
---------------
class A
{
private function test() { }
}
class B extends A
{
protected function test() { } // loosen visibility from private to
protected (expected)
}
class C extends B
{
private function test() { } // stiffen visibility from protected to
private (unexpected)
}
class D extends B
{
public function test() { } // loosen visibility from protected to public
(expected)
}
class E extends D
{
protected function test() { } // stiffen visibility from public to
protected (unexpected)
}
class F extends B
{
private function test() { } // stiffen visibility from public to private
(unexpected)
}
Expected result:
----------------
PHP Fatal error: Access level to C::test() must be protected (as in class B)
or
weaker
Actual result:
--------------
Everything is ok.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62814&edit=1