ID: 38102
User updated by: frode at coretrek dot com
Reported By: frode at coretrek dot com
-Status: Bogus
+Status: Open
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 5CVS-2006-07-14 (snap)
New Comment:
I'm taking the liberty to re-open the bug, since there has been no
explanation for why 5.2 breaks code that works in 5.1.4.
Thanks in advance to anyone that can clarify up this issue.
Previous Comments:
------------------------------------------------------------------------
[2006-07-14 10:05:17] frode at coretrek dot com
Yes, I did run php5.2-200607140630.
The error message you pasted is identical with the one I entered in
'actual results' in the original submission of this bug.
Is this is a planned language change for PHP 5.2? Because the code runs
with no errors in PHP 5.1.4.
------------------------------------------------------------------------
[2006-07-14 09:37:41] [EMAIL PROTECTED]
Did you REALLY try the latest snapshot?
This is what I get with your code:
Fatal error: Cannot use array returned from Class1::__get('property')
in write context ...
And this is well expected.
------------------------------------------------------------------------
[2006-07-14 09:12:20] frode at coretrek dot com
Old summary was for an old bug report and was incorrectly autofilled by
firefox :(
------------------------------------------------------------------------
[2006-07-14 09:10:10] frode at coretrek dot com
Description:
------------
Assigning an array to an object field and updating it through use of
__get/__set() no longer works in PHP 5.2 snapshots. This is probably
related to the fix for bug 37667.
Below is a test case based on the one in bug 37667, which is similar to
a larger real code base we have working in PHP 5.1.4.
This test case does not trigger bug 37667 because we create the array
through __set() - bug 37667 does not set the new array this way.
"Expected result" shows output in PHP 5.1.4
"Actual result" shows output in PHP5.2-200607140630
Running on apache 2.2.2.
Reproduce code:
---------------
<?
header("Content-type: text/plain");
class Class1 {
protected $property = array();
function __get($name) {
return $this->property;
}
function __set($name, $val) {
$this->$name = $val;
}
}
class Class2 {}
$r = new Class1();
$r->property = array();
$r->property["what"] = new Class2();
$r->property["who"] = new Class2();
var_dump($r);
?>
Expected result:
----------------
object(Class1)#1 (1) {
["property:protected"]=>
array(2) {
["what"]=>
object(Class2)#2 (0) {
}
["who"]=>
object(Class2)#3 (0) {
}
}
}
Actual result:
--------------
<br />
<b>Fatal error</b>: Cannot use array returned from
Class1::__get('property') in write context in
<b>/devel2/frode/www/_/test37667.php</b> on line <b>16</b><br />
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38102&edit=1