ID:               44658
 User updated by:  mo at nevali dot net
 Reported By:      mo at nevali dot net
 Status:           Bogus
 Bug Type:         Arrays related
 Operating System: FreeBSD 6
 PHP Version:      5.2.5
 New Comment:

My apologies, in my previous follow-up, I meant to write “$foo->stuff”

where I wrote “$foo->thing2”. In my testcase, there's no such property

as $foo->thing2!


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

[2008-04-07 12:36:07] mo at nevali dot net

So, how do you explain the difference in behaviour when the (should-
be-inert) line in Foo::__construct() is removed?

Also, while I'm perfectly well aware that references are not pointers,

even calling (for example): $this->thing = array_merge($foo->thing, 
array()); in Bar::__construct() causes $bar->thing to become a 
reference.

If this report _is_ bogus, then:

a) Creating a deep reference (i.e., $this->thing2 =& $this-
>thing['stuff']: in Foo::__construct()) should have no bearing on 
anything; $foo->thing2 is not used beyond that initial assignment.

b) How is one supposed to duplicate the contents of an array given a 
reference to it? Last I heard, the use of “clone” was only supported 
for objects.

Whilst this report may be, on the face of it, bogus, there is a bug 
here in either case.

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

[2008-04-07 12:11:46] [EMAIL PROTECTED]

This is the expected and correct output:

Created foo, foo->thing['stuff'] = 1234
Creating Bar, foo->thing['stuff'] = 1234
Created bar, bar->thing2['stuff'] = ABC
Created bar, foo->thing['stuff'] = ABC

Hint: References are not pointers.

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

[2008-04-07 11:46:21] mo at nevali dot net

Description:
------------
Some circumstances involving deep references into arrays can cause 
assignment of those arrays to always assign references instead of 
values.






Reproduce code:
---------------
Please see http://nevali.net/docs/array-refs-testcase.phps

Expected result:
----------------
The code should produce the following output:

Created foo, foo->thing['stuff'] = 1234
Creating Bar, foo->thing['stuff'] = 1234
Created bar, bar->thing2['stuff'] = ABC
Created bar, foo->thing['stuff'] = 1234






Actual result:
--------------
Created foo, foo->thing['stuff'] = 1234
Creating Bar, foo->thing['stuff'] = 1234
Created bar, bar->thing2['stuff'] = ABC
Created bar, foo->thing['stuff'] = ABC

If the (marked) line in Foo's constructor:

$this->stuff =& $this->thing['stuff'];

…is removed, the output is as expected, even though this code should be

inert (Foo::stuff is not referenced from anywhere else in the test 
code).


 


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


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

Reply via email to