#27193 [NEW]: the visibility of class constructor cannot be changed
| From: | andrey@php.net | Date: | Mon, 09 Feb 2004 15:22:50 +0000 |
| Subject: | #27193 [NEW]: the visibility of class constructor cannot be changed | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-54615@lists.php.net to get a copy of this message | ||
From: andrey@php.net
Operating system: linux
PHP version: 5CVS-2004-02-09 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description: the visibility of class constructor cannot be changed
Description:
------------
While it's no problem to change the visibility of a constructor (limit the
visibility) when using the old way of declaring a constructor (function
with the same name as the class), it's not possible to lower the
visibility in a hierarchy where the constructors are named after the new
standard : __construct() .
The engine have to check whether the name is __construct() (what about
__destruct()? ), and not to complain in this case that the visibility is
lowered.
The first example emits a fatal error. The second is perfectly valid.
Reproduce code:
---------------
php -r 'class a{public function __construct() {}} class b extends a
{private function __construct(){}}'
php -r 'class a{public function a() {}} class b extends a {private
function b(){}}'
Actual result:
--------------
PHP Fatal error: Access level to b::__construct() must be public (as in
class a) in Command line code on line 1
--
Edit bug report at http://bugs.php.net/?id=27193&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27193&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27193&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27193&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27193&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27193&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27193&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27193&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27193&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27193&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27193&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27193&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27193&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27193&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27193&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27193&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27193&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27193&r=float