From:             foobar at dodgeit dot com
Operating system: FreeBSD 6.1
PHP version:      5.1.5
PHP Bug Type:     Scripting Engine problem
Bug description:  overloading __set changes the behavior of property access to 
call __get

Description:
------------
Consider the following code:

$foo = new A;
$foo->bar = 'bar';
echo $foo->bar;

Assume A defines __get.
Behavior of the last line is different depending on whether A defines
__set. If __set is not defined, then the last line won't call __get. If
__set is defined, __get will be called.

Reproduce code:
---------------
<?php
  class A { public function __get($prop) { echo "getting\n"; } }
  $a = new A; $a->foo = 'foo'; echo $a->foo."\n";
?>

------

<?php
  class A { public function __get($prop) { echo "getting\n"; } public
function __set($prop, $val) { echo "setting\n"; } }
  $a = new A; $a->foo = 'foo'; echo $a->foo."\n";
?>


Expected result:
----------------
The first run produces:

foo

The second run produces:

getting
setting


Actual result:
--------------
Either 'getting' should be printed in both runs, or it should be not
printed in either run.


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

Reply via email to