Hello Marcus,

Saturday, July 5, 2003, 4:16:03 PM, you wrote:

MB> Hello Zeev, hi Andi,

MB>   atm it is not possible to unset static members of a class which is correct
MB> since that would modify the class protocol. But it is possible to unset non
MB> dynamic properties (defined in the class). This should also be prevented as
MB> done with the attached patch.

MB> I did it by checking whether the name is part of the default properties. This
MB> works but maybe it is to slow. So perhaps it is a better solution to provide a
MB> flag in the property_info but then we#d have to do that in every class
MB> instantiation while my method would only take time when unset is used on
MB> props.

MB> Test code:
MB> <?php
MB> class u { var $x = 1; }
MB> class t extends u {}
MB> $o = new t;
$o->>y=2;
$o->>var_dump($o);
$o->>unset($o->y);
$o->>var_dump($o);
$o->>unset($o->x);
$o->>var_dump($o);'
?>>

MB> Result:
MB> object(t)#1 (2) {
MB>   ["x"]=>
MB>   int(1)
MB>   ["y"]=>
MB>   int(2)
MB> }
MB> object(t)#1 (0) {
MB> }


MB> With Patch:
MB> object(t)#1 (2) {
MB>   ["x"]=>
MB>   int(1)
MB>   ["y"]=>
MB>   int(2)
MB> }
MB> object(t)#1 (1) {
MB>   ["x"]=>
MB>   int(1)
MB> }


MB> Comments ?
  
During a nice chat with Andi both of us came to the conclusion that the user
may shoot himself in the knee if he wants to. So we allow unsetting default
properties what makes PHP objects a thing between real objects and pure
instances.

Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to