#44571 [Opn->Bgs]: behavior change from 5.* to 5.2.6
| From: | felipe@php.net | Date: | Sun, 30 Mar 2008 15:47:35 +0000 |
| Subject: | #44571 [Opn->Bgs]: behavior change from 5.* to 5.2.6 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-123786@lists.php.net to get a copy of this message | ||
ID: 44571
Updated by: felipe@php.net
Reported By: travisghansen at yahoo dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: linux
PHP Version: 5.2.6RC3
New Comment:
Says the documentation:
"Note: Parent constructors are not called implicitly if the child class
defines a constructor."
Then, it was really a bug, though many codes have used this old
behavior.
Previous Comments:
------------------------------------------------------------------------
[2008-03-30 15:41:47] felipe@php.net
The old behavior was changed in Bug #44141.
------------------------------------------------------------------------
[2008-03-30 15:22:50] travisghansen at yahoo dot com
Description:
------------
The code below has worked fine in all php 5 releases (that I've used
for the past year and a half anyway). It now dies with 5.2.6.
Reproduce code:
---------------
class BaseLoginDA
{
protected $dbg;
private static $instance;
private function __construct(){
echo __METHOD__;
}
}
class LoginDA extends BaseLoginDA {
private static $instance;
//implementing the singleton pattern
static function getInstance(){
if (self::$instance){
return self::$instance;
}
else {
self::$instance = new LoginDA();
return self::$instance;
}
}
}
$loginDA=LoginDA::getInstance();
Expected result:
----------------
an instantiated LoginDA object
Actual result:
--------------
Fatal error: Call to private BaseLoginDA::__construct() from context
'LoginDA'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44571&edit=1