Req #64756 [Opn->Wfx]: Add constructor parameter or update docs

From: Date: Tue, 03 Aug 2021 11:34:17 +0000
Subject: Req #64756 [Opn->Wfx]: Add constructor parameter or update docs
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235548@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64756&edit=1 ID: 64756 Updated by: cmb@php.net Reported by: luke dot brown28 at gmail dot com Summary: Add constructor parameter or update docs -Status: Open +Status: Wont fix Type: Feature/Change Request Package: SPL related Operating System: Windows Server 2008 PHP Version: 5.3.24 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > I appreciate it's easy to extend the class and code in the > recursion, […] There is no need to extend the class; a simple stand-alone creation function should be sufficient. > 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. It would rather be uncommon if the constructor behaved this way, so I don't see a good reason to update the docs. Previous Comments: ------------------------------------------------------------------------ [2013-05-02 09:32:23] luke dot brown28 at gmail dot com Description: ------------ --- From manual page: http://www.php.net/arrayobject.construct#refsect1- arrayobject.construct-examples --- 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' ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64756&edit=1

« previous php.bugs (#235548) next »