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

From: Date: Wed, 20 Apr 2005 08:06:22 +0000
Subject: Re: protected/private function __construct() not allowed in 5.0.4?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-16042@lists.php.net to get a copy of this message
Hello Greg, Wednesday, April 20, 2005, 5:11:46 AM, you 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(){} > } ?>> > Could someone please enlighten me? I was using this for a singleton > pattern, and so it would be nice to know why it is so critical for the > engine to be anal retentive here. It seems to me that it should be up > to the programmer to decide how easily the object can be instantiated, > unless there is a deeper engine stability issue. > Thanks, > Greg At least it works for 5.0.5-dev: marcus@zaphod /usr/src/php-cvs $ php -r 'class T { protected function __construct() {} static function test() { return new T;} } var_dump(T::test());' make: `sapi/cli/php' is up to date. object(T)#1 (0) { } marcus@zaphod /usr/src/php-cvs $ ../PHP_5_0/sapi/cli/php -r 'class T { protected function __construct() {} static function test() { return new T;} } var_dump(T::test());' object(T)#1 (0) { } marcus@zaphod /usr/src/php-cvs $ ../PHP_5_0/sapi/cli/php -v PHP 5.0.5-dev (cli) (built: Apr 7 2005 17:24:12) (DEBUG) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies but i currently cannot reproduce it with 5.0.4, sorry. -- Best regards, Marcus mailto:mail@marcus-boerger.de

« previous php.internals (#16042) next »