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
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: klaussantana at gmail dot com
New email:
PHP Version: OS:

 

 [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-2020 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 04:01:23 2020 UTC