ID:               41641
 Updated by:       [EMAIL PROTECTED]
 Reported By:      asnyder at mddev dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Linux Fedora Core 4
 PHP Version:      5.2.3
 New Comment:

The __get() function returns by value, not by reference, hence the
warning.


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

[2007-06-11 14:57:33] asnyder at mddev dot com

How is this bogus? The code DOES indeed make a change. Why should one
have to call SetSomething, instead of the automatic __set triggering and
making the modification.

I don't understand your logic. I have many applications that use this
logic, and the applicatios worked properly before, with the new notice
they don't, unless I explicitly call the function.

What are your thoughts on this?

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

[2007-06-11 14:52:51] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It did not properly work in PHP 5.1.x either, now we emit this warning
so that you can deal with the broken code.

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

[2007-06-08 22:50:01] asnyder at mddev dot com

Description:
------------
Ok, the bug is as follows. If one gets an array, via the __get, and
then continues to modify the subobject properties using a __set. It will
call the __set function, but throw the 

Notice: Indirect modification of overloaded property A::$Test has no
effect in /var/www/html/Tests/PHPBug.php on line 43

In PHP 5.1.2 this process worked fine, but in 5.2.3 it causes the
notice.

Reproduce code:
---------------
class A
{
        private $Test = array("One" => null, 'Two' => null);
        
        function A()
        {
                $this->Test['One'] = new B();
        }
        function __get($val)
        {
                return $this->Test;
        }
}
class B
{
        private $SomeVariable;
        
        function GetSomething(){return $this->SomeVariable;}
        function SetSomething($bool)
        {
                $this->SomeVariable = $bool;
        }
        function __get($val)
        {
                $this->GetSomething();
        }
        function __set($part, $val)
        {
                $this->SetSomething($val);
        }
}
$tmpA = new A();


// Now in PHP 5.1.2 the following code works, in PHP 5.2.3 but throws
the notice Indirect modification of overloaded property
$tmpA->Test['One']->Something = true;
//In PHP 5.2.3 one would have to do the following for the notice not to
throw. Which is not the expected behavior
//$tmpA->Test['One']->SetSomething(true);

Expected result:
----------------
The SetSomething($val) function should be called, and it IS being
called, but with throwing a notice. It should behave like in 5.1.2 and
run the SetSomething($val) function without the notice.

One should NOT have to call $tmpA->Test['One']->SetSomething(true) to
not raise the notice.

Actual result:
--------------
Calls function and throws notice.


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


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

Reply via email to