php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44571 behavior change from 5.* to 5.2.6
Submitted: 2008-03-30 15:22 UTC Modified: 2008-03-30 15:47 UTC
From: travisghansen at yahoo dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.6RC3 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: travisghansen at yahoo dot com
New email:
PHP Version: OS:

 

 [2008-03-30 15:22 UTC] 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'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-30 15:41 UTC] felipe@php.net
The old behavior was changed in Bug #44141.
 [2008-03-30 15:47 UTC] felipe@php.net
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 06:01:27 2025 UTC