#38003 [Asn->Csd]: singleton and inheritance
| From: | tony2001@php.net | Date: | Wed, 05 Jul 2006 11:49:20 +0000 |
| Subject: | #38003 [Asn->Csd]: singleton and inheritance | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-99118@lists.php.net to get a copy of this message | ||
ID: 38003
Updated by: tony2001@php.net
Reported By: pmiroslawski at gmail dot com
-Status: Assigned
+Status: Closed
Bug Type: Class/Object related
Operating System: Linux DEBIAN 3.1
PHP Version: 5.1.4
Assigned To: tony2001
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2006-07-04 12:22:16] pmiroslawski at gmail dot com
Description:
------------
Problem with create of object class then contruct is private. I use
singleton pattern and inheritance and I can create object (no error and
warning) if i didn't use inheritance was error (this behavior is ok).
Reproduce code:
---------------
<?php
class DB extends mysqli{
private static $instance;
private function __construct($hostname=DB_HOST, $username=DB_USER,
$password=DB_PASSWORD, $database=DB_DATABASE){
//parent::__construct($hostname, $username, $password,
$database);
}
public static function getInstance() {
if (!isset(self::$instance)) {
self::$instance = new DB();
}
return self::$instance;
}
}
$DB = new DB();
?>
Expected result:
----------------
Fatal error: Call to private DB::__construct()
Actual result:
--------------
Everything is ok. No error! No warning!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38003&edit=1