php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62662 ArrayObject applied deep inside the array
Submitted: 2012-07-25 19:10 UTC Modified: -
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: klaussantana at gmail dot com Assigned:
Status: Open Package: SPL related
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
38 - 4 = ?
Subscribe to this entry?

 
 [2012-07-25 19:10 UTC] klaussantana at gmail dot com
Description:
------------
New flag to ArrayObject: DEEP_CONVERSION.

This flag would make ArrayObject inspect the array $input indexes for others 
arrays and also instantiate an ArrayObject with the index array also with the same 
$flags and the same $iterator_class.

Test script:
---------------
<?php

$Array = array();

$Array['string'] = 'string';

$Array['array'] = array();
$Array['array'][] = 'string';
$Array['array'][] = 'string';
$Array['array'][] = 'string';

$Array['matrix'] = array();

$Array['matrix']['string1'] = 'string';
$Array['matrix']['string2'] = 'string';
$Array['matrix'][]          = 'string';
$Array['matrix'][]          = 'string';
$Array['matrix']['array1']  = array();
$Array['matrix']['array1'][]         = 'string';
$Array['matrix']['array1'][]         = $Array['array'];
$Array['matrix']['array1'][]         = 'string';
$Array['matrix']['array1']['string'] = 'string';
$Array['matrix']['array2']  = array();
$Array['matrix']['matrix']  = array();
$Array['matrix']['matrix']['array'] = $Array['matrix']['array1'];
$Array['matrix']['matrix'][]        = $Array['matrix']['matrix']['array'];
$Array['matrix']['string3'] = 'string';
$Array['matrix'][] = null;

$Array = new ArrayObject($Array, ArrayObject::ARRAY_AS_PROPS);

echo $Array->matrix->matrix[0][1][0];

?>

Expected result:
----------------
string

Actual result:
--------------
(!) Notice: Trying to get property of non-object in D:\WWW\sandbox.php on line 32

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-25 19:18 UTC] klaussantana at gmail dot com
The example above is a simple case to show that it not work.

The new flag would unleash a tons of possibilities of application like when you're 
mapping a database with object orientation.

<?php echo $MyDBMap->database->table->column; ?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 05:01:33 2024 UTC