ID:               33450
 User updated by:  arendjr at gmail dot com
 Reported By:      arendjr at gmail dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: Linux
 PHP Version:      5.0.4
 New Comment:

Just tried it, but it gives exactly the same result.


Previous Comments:
------------------------------------------------------------------------

[2005-06-23 11:41:04] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2005-06-23 11:36:09] arendjr at gmail dot com

Description:
------------
Whenever I create a class which inherits DOMElement, and I create an
instance of this class, the type of the class is "forgotten" when the
variable holding the instance goes out of scope, even though the actual
instance should still exist as it is part of the DOM tree. So, what you
get is that the inherited DOMElement still exists in the DOM tree, but
the subclass instance is gone.



Reproduce code:
---------------
<?php

class Widget extends DOMElement {
        public function __construct() {
                parent::__construct('p');
        }

        public function say() {
                echo "I am a widget!\n";
        }
}

$doc = new DOMDocument();
$doc->appendChild($html = new DOMElement('html'));
$html->appendChild($body = new DOMElement('body'));
$body->appendChild(new Widget());
$body->firstChild->say();

?>

Expected result:
----------------
It should say: "I am a widget!".

You can get this expected result by changing the line:
  $body->appendChild(new Widget());
to:
  $body->appendChild($widget = new Widget());

this way, the widget will not get out of scope and the actual class is
remembered.

Actual result:
--------------
You will get an error saying: "Fatal error: Call to undefined method
DOMElement::say() in testcase.php on line 17"


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33450&edit=1

Reply via email to