#41623 [NEW]: $this in parent::__construct refere to the subclass

From: Date: Thu, 07 Jun 2007 10:14:58 +0000
Subject: #41623 [NEW]: $this in parent::__construct refere to the subclass
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-113529@lists.php.net to get a copy of this message
From: amine dot abbes at gmail dot com Operating system: windows XP PHP version: 5.2.3 PHP Bug Type: Class/Object related Bug description: $this in parent::__construct refere to the subclass Description: ------------ When calling parent::__construct() in the subclass constructor, $this will refere to the subclass instance. Reproduce code: --------------- <?php class MyParent{ function __construct(){ echo (($this instanceof MyClass)?"Yes":"No") . "<br>" ; self::myfunction(); $this->myfunction(); } function myfunction(){ echo __METHOD__ . "<br>"; } } class MyClass extends MyParent{ function __construct(){ parent::__construct(); } function myfunction(){ echo __METHOD__ . "<br>"; } } new MyClass(); ?> Expected result: ---------------- No MyParent::myfunction MyParent::myfunction Actual result: -------------- Yes MyParent::myfunction MyClass::myfunction -- Edit bug report at http://bugs.php.net/?id=41623&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41623&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41623&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41623&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41623&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41623&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41623&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41623&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41623&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41623&r=support Expected behavior: http://bugs.php.net/fix.php?id=41623&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41623&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41623&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41623&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41623&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41623&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41623&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41623&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41623&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41623&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41623&r=mysqlcfg

« previous php.bugs (#113529) next »