#32188 [Com]: Problem when extending a standard class

From: Date: Wed, 13 Jun 2007 19:48:40 +0000
Subject: #32188 [Com]: Problem when extending a standard class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-113749@lists.php.net to get a copy of this message
ID: 32188 Comment by: ads at tristanleboss dot net Reported By: manu at manucorp dot com Status: No Feedback Bug Type: SimpleXML related Operating System: Linux PHP Version: 5.0.3 New Comment: We are still unable to access properties of a class which extends SimpleXMLElement. class SubClass extends SimpleXMLElement { var $Layers; /* Fatal error: Cannot override final method SimpleXMLElement::__construct() */ # function __construct() # { # parent::__construct(); # $this->Layers = array(); # } function __destruct() { parent::__destruct(); unset($this->Layers); } function updateID() { if (!is_array($this->Layers)) $this->Layers = array(); /* Warning: array_push(): First argument should be an array */ array_push($this->Layers, $this->attributes()->id); /* Fatal error: SubClass::updateID(): Cannot create unnamed attribute */ $this->Layers[] = $this->attributes()->id; } } and $class_vars = get_class_vars(get_class($obj)); var_dump($class_vars); output: array(1) { ["Layers"]=> NULL } The problem comes from the fact that when you type $this->Layers, SimpleXML wants to return the node 'Layers'. Tristan Previous Comments: ------------------------------------------------------------------------ [2005-03-20 18:11:30] sniper@php.net No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. ------------------------------------------------------------------------ [2005-03-04 16:52:51] sniper@php.net 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-03-04 11:07:32] manu at manucorp dot com Description: ------------ When i extend SimpleXMLElement there is some weird issue on accessing variable of the class. (perhaps related to bug #28817, i'm not completely sure) Reproduce code: --------------- <?php class Reader extends SimpleXMLElement { public $test; public function extract() { $this->test=array(); var_dump(is_array($this->test)); } } $uploadfile="file.xml"; $rs=simplexml_load_file($uploadfile,"Reader"); $rs->extract(); ?> Expected result: ---------------- bool(true) Actual result: -------------- bool(false) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32188&edit=1

« previous php.bugs (#113749) next »