From:             timshaw at mail dot usa dot com
Operating system: Win32
PHP version:      5.2.5
PHP Bug Type:     Class/Object related
Bug description:  Bug #34396 is not fixed - unset() un-declares a property

Description:
------------
Shouldn't unset of a declared property still leave the property as a
declared property, so that the set overload will not later be used on it?

It is cool to unset things once their value becomes invalid to catch
errors using the invalid value. However, I could understand that this
overload problem is actually an undocumented feature if the person who
implemented overloads decided that everybody should be able to overload
everything, even declared properties, so this was put in to allow that....
Too bad that doesn't accomodate those of us who don't want to use overloads
for everything, just some things.


Reproduce code:
---------------
<?php
class c {
  public $x ;
  public function __set($nm, $val) { echo "overloaded __set($nm, $val)
;\n" ; }
  public function __isset($nm) { echo "overloaded __isset($nm) ;\n" ; }
  public function __unset($nm) { echo "overloaded __unset($nm) ;\n" ; }
}
$c = new c ;
echo "Does not overload, just as expected and documented, because \$x is
declared property\n" ;
echo "\$c->x = ", $c->x = 5, "\n" ;
echo "Does not overload, just as expected, because \$x is declared
property\n" ;
echo "isset(\$c->x) = ", isset($c->x)? 'True': 'False', "\n" ;
echo "Does not use overload __unset, just as expected, because \$x is
declared property\n" ;
echo "unset(\$c->x)\n" ;
unset($c->x) ;
echo "Here's the problem- \$x is declared public property, but now it's
using overloaded set!\n" ;
echo "\$c->x = 5 ...  " ; $c->x = 5 ;
?>


Expected result:
----------------
The "overloaded ..." should not appear because only the declared property
$x is used.

Actual result:
--------------
This does not call overload, just as expected and documented, because $x
is declared property
$c->x = 5
This does not call overload, just as expected, because $x is declared
property
isset($c->x) = True
This does not go though __unset, just as expected, because $x is declared
property
unset($c->x)
Here's the problem- $x is declared public property, but now it's using
overloaded set!
$c->x = 5 ...  overloaded __set(x, 5) ;

-- 
Edit bug report at http://bugs.php.net/?id=43847&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43847&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43847&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43847&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43847&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43847&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43847&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43847&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43847&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43847&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43847&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43847&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43847&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43847&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43847&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43847&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43847&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43847&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43847&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43847&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43847&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43847&r=mysqlcfg

Reply via email to