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

2005-06-27 Thread apann at personal dot ro
From: apann at personal dot ro
Operating system: Win/Linux
PHP version:  5.0.4
PHP Bug Type: Scripting Engine problem
Bug description:  new self should return the extended class

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 bug report at http://bugs.php.net/?id=33486edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33486r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33486r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33486r=trysnapshot51
Fixed in CVS:http://bugs.php.net/fix.php?id=33486r=fixedcvs
Fixed in release:http://bugs.php.net/fix.php?id=33486r=alreadyfixed
Need backtrace:  http://bugs.php.net/fix.php?id=33486r=needtrace
Need Reproduce Script:   http://bugs.php.net/fix.php?id=33486r=needscript
Try newer version:   http://bugs.php.net/fix.php?id=33486r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33486r=support
Expected behavior:   http://bugs.php.net/fix.php?id=33486r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=33486r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=33486r=submittedtwice
register_globals:http://bugs.php.net/fix.php?id=33486r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33486r=php3
Daylight Savings:http://bugs.php.net/fix.php?id=33486r=dst
IIS Stability:   http://bugs.php.net/fix.php?id=33486r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33486r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33486r=float
No Zend Extensions:  http://bugs.php.net/fix.php?id=33486r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33486r=mysqlcfg


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

2005-06-27 Thread apann at personal dot ro
 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=33486edit=1