#41623 [Opn->Bgs]: $this in parent::__construct refere to the subclass
| From: | tony2001@php.net | Date: | Thu, 07 Jun 2007 10:20:52 +0000 |
| Subject: | #41623 [Opn->Bgs]: $this in parent::__construct refere to the subclass | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-113532@lists.php.net to get a copy of this message | ||
ID: 41623
Updated by: tony2001@php.net
Reported By: amine dot abbes at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: windows XP
PHP Version: 5.2.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2007-06-07 10:14:58] amine dot abbes at gmail dot com
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 this bug report at http://bugs.php.net/?id=41623&edit=1