|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64756 Add constructor parameter or update docs
Submitted: 2013-05-02 09:32 UTC Modified: -
From: luke dot brown28 at gmail dot com Assigned:
Status: Open Package: SPL related
PHP Version: 5.3.24 OS: Windows Server 2008
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-05-02 09:32 UTC] luke dot brown28 at gmail dot com
From manual page:

Currently when constructing an ArrayObject it isn't possible to specify whether 
or not you would like recursion to take place, thus traversing the array 
structure and creating ArrayObject instances in multi-dimensional arrays. 

Whilst I appreciate that this is standard behavior, being given the option when 
constructing would be very useful as you wouldn't then be required to extend the 
class for what is quite a common use-case. I appreciate it's easy to extend the 
class and code in the recursion, but I feel a param on construct would be 
equally as useful (perhaps even as part of the bitwise flags).

Failing this, the documentation should at the very least be updated to include 
an example of instantiating the class with a multi-dimensional array to show 
that any arrays within the one passed to the constructor will not be converted 
by ArrayObject. 

Test script:
$array = array('one' => 1, 'fruit' => array('lemon' => 'bitter', 'orange' => 'sweet'));

$obj = new ArrayObject($array);

$obj->fuit->orange; // null
$obj->fuit['orange'] // 'sweet'


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun May 09 02:01:24 2021 UTC