ID: 28444
Updated by: [EMAIL PROTECTED]
Reported By: dennis at inmarket dot lviv dot ua
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: WinXP
PHP Version: 5.0.0RC2
New Comment:
Fixed in CVS (HEAD and PHP_5_0).
Previous Comments:
------------------------------------------------------------------------
[2005-01-14 10:16:38] [EMAIL PROTECTED]
I consulted with Andi and he said:
This is the way the language works. There really isn't anyway to change
this behavior. Many rely on the fact that properties can explicitly be
created/removed. Of course, I suggest that ppl don't mix between this
ability and PPP.
This should be put into the documentation though, I suggest unset().
------------------------------------------------------------------------
[2005-01-12 09:08:13] [EMAIL PROTECTED]
I think this should not happen, Andi, what to you say?
------------------------------------------------------------------------
[2005-01-12 00:49:03] keithm at aoeex dot com
Ok, just wanted to add that I figured my problem out, and you might be
able to just consider it user error. Apparently calling unset on a
property of a class makes that property no longer valid for that class,
rather than just giving it an empty value and free'ing the memory for
it's contents like I had thought. Not sure if this is intentional or
not (does kind of make sense) but anyway removing the
unset($this->minput) line from my function and it started working
again.
------------------------------------------------------------------------
[2005-01-11 08:03:24] keithm at aoeex dot com
I ran into this problem also, but slighly differently. In my case, the
first property I'm accessing is a validly declared and set property of
the class, instead of set using __set or read using __get. I've tried
to reproduce it using simpler code, but I can't seem to get it done.
The actual code I'm using is far too complex for a bug report
submission (it's a customized DOM implemtation)
I'll see if I can describe it at all. Basically I have the following
classes that are involved:
abstract class Node -- Does define __set/__get
abstract class HTMLElement extends Node -- Does define __set/__get
class HTMLInputElement extends HTMLElement -- Does define __set/__get
class FormElement extends HTMLElement -- Does NOT define __set/__get
Now, the FormElement class has variable declarations like so:
private $minput;
private $mlabel;
private $mlplacement;
private $container;
$minput is eventuall an instance of HTMLInputElement when this error
occurs. Here is the relevent part of the formElement->setInputType
function
public function setInputType($xtype){
unset($this->minput);
switch ($xtype){
......
case 'radio': case 'text': case 'entry': case
'button': case 'image': case 'submit': case 'reset': case 'checkbox':
$this->minput=$this->ownerDocument->createElement('INPUT');
/* as of this point, $this->minput is a valid HTMLInputElement
instance, verified w/ print_r */
$this->minput->type = $xtype;
break;
...
}
When that method is called, I receive the error in question on the
line: $this->minput->type = $xtype;
I'll keep trying to come up with simpler code that reproduces the bug,
but if anyone does want to view the big code (maybe for clarity) it is
available at
http://wiser.kicks-ass.org:8008/PHPDOM/PHPDOM-error.tar.gz
My PHP version is 5.0.2, and I can reproduce with both the CLI and
Apache 2 Module. Operating systems Both FreeBSD and Linux 2.6.9
------------------------------------------------------------------------
[2004-11-08 20:05:09] php at rodric dot org
I ran into this in a slightly different way -- trying to
foreach through an ArrayAccess object. Interestingly,
removing the __set from class O allows this to work.
class O
{
private $m_a = array();
function __get ($key)
{
return $this->m_a[$key];
}
function __set ($key, $val)
{
$this->m_a[$key] = $val;
}
}
class A implements ArrayAccess, IteratorAggregate
{
private $m_e = array();
function __construct ($e = NULL)
{
$this->m_e = is_null ($e) ? array() : $e;
}
function offsetSet ($key, $value)
{
$this->m_e[$key] = $value;
}
function offsetGet ($key)
{
if (isset ($this->m_e[$key]))
{
return $this->m_e[$key];
}
}
function offsetUnset ($key)
{
unset ($this->m_e[$key]);
}
function offsetExists ($key)
{
return isset ($this->m_e[$key]);
}
function getIterator ()
{
return new ArrayIterator($this->m_e);
}
}
$o = new O();
$o->a = new A(array(1, 2, 3));
foreach ($o->a as $e)
{
echo "$e ";
}
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/28444
--
Edit this bug report at http://bugs.php.net/?id=28444&edit=1