ID:               50355
 Updated by:       j...@php.net
 Reported By:      oorza2k5 at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         *General Issues
 Operating System: *
 PHP Version:      5.3.1
 New Comment:

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.




Previous Comments:
------------------------------------------------------------------------

[2009-12-01 19:20:51] oorza2k5 at gmail dot com

Description:
------------
When trying to access a magically returned (via __get()) property of a
class, only an E_NOTICE is raised.  

While a function like array_pop will return a value (without modifying
the overloaded property), some other operations will have less
predictable results, such as array access via the "[]" syntax.  Because
a lot of distributions ship with a "$something | ~E_NOTICE" level of
error reporting, and the "black box" ideas of object oriented
programming (a developer trying to push an element onto a member array
in an API class, for instance), this could be a very hard circumstance
to debug.  Furthermore, any case I can think of where this notice will
be raised will never perform as expected, it will force the developer to
re-engineer his solution.  Because any case where this error would be
raised will force a rewrite, I think that this circumstance should raise
a fatal error instead.

The fix is trivial enough that I did not attach a patch, but would be
glad to in the future, if necessary.

Reproduce code:
---------------
<?php

class foo {
        private $bar = array('1', '2', '3');
        public function __get($var) {
                return $this->$var;
        }
}

$inst = new foo();
var_dump(array_pop($inst->bar));


Expected result:
----------------
PHP Fatal Error:  Indirect modification of overloaded property
foo::$bar has no effect in /home/blahblah/test.php on line 10


Actual result:
--------------
PHP Notice:  Indirect modification of overloaded property foo::$bar has
no effect in /home/blahblah/test.php on line 10



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=50355&edit=1

Reply via email to