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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
8 - 2 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 03:01:31 2024 UTC