Re: protected/private function __construct() not allowed in 5.0.4?

From: Date: Wed, 20 Apr 2005 14:34:45 +0000
Subject: Re: protected/private function __construct() not allowed in 5.0.4?
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-16047@lists.php.net to get a copy of this message
On Wed, 20 Apr 2005 09:52:25 -0400 Greg Beaver <greg@chiaraquartet.net> wrote: > Antony Dovgal wrote: > > >On Tue, 19 Apr 2005 23:11:46 -0400 > >Greg Beaver <cellog@php.net> wrote: > > > > > > > >>Hi all, > >> > >>I just spent quite a while searching the archives, and can't find any > >>explanation of why this code worked in 5.0.3 but doesn't in 5.0.4: > >> > >><?php > >>class blah { > >> protected function __construct(){} > >>} > >>?> > >> > >> > > > >Works fine with HEAD, 5.0.5-dev & 5.0.4. > >Could you plz explain what did you mean when you said "doesn't work" ? > > > > I didn't read the error message closely enough - when extending the base > class, which has a public constructor, the protected keyword is no > longer allowed. > > <b>Fatal error</b>: Access level to > Chiara_PEAR_Server_Frontend_Xmlrpc5_Package > ::__construct() must be public (as in class Chiara_XML_RPC5_Server) in > <b>c:\php > 5\pear\Chiara\PEAR\Server\Frontend\Xmlrpc5.php</b> on line <b>40</b><br > /> > > Try this code (which worked in 5.0.3) > > <?php > class a { public function __construct(){}} > class b extends a { protected function __construct(){}} > ?> It doesn't work in 5.0.3 too: --------- #./sapi/cli/php -v PHP 5.0.3 (cli) (built: Apr 20 2005 18:26:52) (DEBUG) Copyright (c) 1997-2004 The PHP Group #./sapi/cli/php /www/index.php Fatal error: Access level to b::__construct() must be public (as in class a) in /www/index.php on line 4 --------- As far as I can see this change first appeared somewhere in late 2002, because this patch: http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.337&r2=1.338&ty=u fixes it. -- Wbr, Antony Dovgal aka tony2001 antony@zend.com

« previous php.internals (#16047) next »