Bug #62814 [Com]: It is possible to stiffen child class members visibility
| From: | resha dot ru at gmail dot com | Date: | Tue, 14 Aug 2012 09:50:47 +0000 |
| Subject: | Bug #62814 [Com]: It is possible to stiffen child class members visibility | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-172591@lists.php.net to get a copy of this message | ||
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