#33486 [Opn]: "new self" should return the extended class

From: Date: Mon, 27 Jun 2005 06:52:01 +0000
Subject: #33486 [Opn]: "new self" should return the extended class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81061@lists.php.net to get a copy of this message
ID: 33486 User updated by: apann at personal dot ro Reported By: apann at personal dot ro Status: Open Bug Type: Scripting Engine problem Operating System: Win/Linux PHP Version: 5.0.4 New Comment: The expected result should be: Base::__construct Ext_One::__construct Base::__construct Ext_Two::__construct Previous Comments: ------------------------------------------------------------------------ [2005-06-27 08:49:52] apann at personal dot ro Description: ------------ See "reproduce code" section. The same thing happens with php version 5.0.3, 5.0.4 and 5.1.0-from_cvs. Os: Mandriva Linux/Ubuntu/Win XP/Win 2000. Reproduce code: --------------- <?php class Base { public function __construct() { echo __METHOD__ . "\n"; } public static function run() { return new self; } } class Ext_One extends Base { public function __construct() { parent::__construct(); echo __METHOD__ . "\n"; } } class Ext_Two extends Base { public function __construct() { parent::__construct(); echo __METHOD__ . "\n"; } } $o1 = Ext_One::run(); $o2 = Ext_Two::run(); Expected result: ---------------- Ext_One::__construct Base::__construct Ext_Two::__construct Base::__construct Actual result: -------------- Base::__construct Base::__construct ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33486&edit=1

« previous php.bugs (#81061) next »