#45334 [Opn->Bgs]: Method hiding/visibility issue
ID: 45334
Updated by: johannes@php.net
Reported By: kristianoye at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Windows XP
PHP Version: 5.2.6
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
These rules are a central part of the object model, it was designed to
work that way and we don't want to change it.
Previous Comments:
------------------------------------------------------------------------
[2008-06-23 09:02:45] kristianoye at gmail dot com
Description:
------------
This issue was brought up in Bug #42830 but the bug was closed as
'Bogus' but to me it seems to be a valid issue:
I am working on a small framework of my own and all objects share a
common ancestor (base object) that defines __construct as public. I
cannot redefine the visibility of __construct in the base without
breaking other classes, yet I still want this derived, singleton to
share the relation.
Addendum: This seems to be the case with any method, actually, not
specific to __construct(). I tried defining a 'GetMessage()' method in
the same class structure.
Reproduce code:
---------------
class BaseObject
{
public function GetMessage() { return "foo1"; }
}
class RequestObject extends BaseObject
{
public function GetMessage() { return "foo2"; }
}
class CurrentRequest extends RequestObject
{
private function GetMessage() { return "top secret"; }
}
Expected result:
----------------
No errors for restricting visibility of methods in derived classes (I
can understand not letting you *increase* visibility of derived methods,
but not the other way around).
Actual result:
--------------
PHP Fatal error: Access level to CurrentRequest::GetMessage() must be
public (as in class RequestObject) in
C:\kristian\workspace\guild\foo.php on line 15
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45334&edit=1
Thread (2 messages)