From:             kristianoye at gmail dot com
Operating system: Windows XP
PHP version:      5.2.6
PHP Bug Type:     Class/Object related
Bug description:  Method hiding/visibility issue

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 bug report at http://bugs.php.net/?id=45334&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45334&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45334&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45334&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45334&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45334&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45334&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45334&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45334&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45334&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45334&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45334&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45334&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45334&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45334&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45334&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45334&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45334&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45334&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45334&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45334&r=mysqlcfg

Reply via email to