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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Sun Dec 08 06:01:28 2024 UTC