|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75693 ArrayObject does not set dynamic values up from 7.1.4
Submitted: 2017-12-15 17:12 UTC Modified: 2017-12-16 17:07 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: kodeart at gmail dot com Assigned:
Status: Verified Package: SPL related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kodeart at gmail dot com
New email:
PHP Version: OS:


 [2017-12-15 17:12 UTC] kodeart at gmail dot com
The dynamic key/values in ArrayObject are not set starting from v7.1.4 (up to 7.2.0) when the key does not exists and the value is array (nested or otherwise).

The overridden ArrayObject methods in the class exists to provide a fluid interface (for offsetSet) and return the value or NULL as a special case (for offsetGet). It's not the best logic but the behavior is expected to be consistent in all (or at least) PHP 7.1 versions.

Test script:

Expected result:
The behavior should be consistent in all versions.

Actual result:
At the time of this report the dynamic key/value is

- set in 5.6.0 - 5.6.30, 7.0.0 - 7.1.3
- not set up from 7.1.4 - 7.2.0 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-16 17:07 UTC]
-Status: Open +Status: Verified
 [2017-12-16 17:07 UTC]
This is due to the fix for bug #74058. The problem is that your offsetGet() method simply wasn't called previously (for this specific code). Now it is called, but does not work correctly, because offsetGet() needs to return by reference to support indirect array modification. You'd need something like this instead:

Unfortunately this doesn't work either, because ArrayObject::offsetGet() itself does not return by reference. We can't easily change it to return by reference, because that would require all classes extending ArrayObject to do so as well, which would be a BC break.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 21 17:01:29 2024 UTC