#38003 [NEW]: singleton and inheritance

From: Date: Tue, 04 Jul 2006 12:22:16 +0000
Subject: #38003 [NEW]: singleton and inheritance
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-99078@lists.php.net to get a copy of this message
From: pmiroslawski at gmail dot com Operating system: Linux DEBIAN 3.1 PHP version: 5.1.4 PHP Bug Type: Class/Object related Bug description: singleton and inheritance 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 bug report at http://bugs.php.net/?id=38003&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38003&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38003&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38003&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38003&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38003&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38003&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38003&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38003&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38003&r=support Expected behavior: http://bugs.php.net/fix.php?id=38003&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38003&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38003&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38003&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38003&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38003&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38003&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38003&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38003&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38003&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38003&r=mysqlcfg

« previous php.bugs (#99078) next »