|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73657 Reflection property can't access to ArrayObject property
Submitted: 2016-12-05 17:00 UTC Modified: 2016-12-05 19:21 UTC
From: ilya at antipenko dot pp dot ua Assigned:
Status: Verified Package: Reflection related
PHP Version: 7.0.13 OS: Any
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.
Block user comment
Status: Assign to:
Bug Type:
From: ilya at antipenko dot pp dot ua
New email:
PHP Version: OS:


 [2016-12-05 17:00 UTC] ilya at antipenko dot pp dot ua

ReflectionObject::getProperties() returns property which added to ArrayObject with offsetSet(), but this property can't be gotten by ReflectionProperty::getValue().


Test script:

class A extends \ArrayObject {}

$a = new A;
$a->offsetSet('test', 'testValue');

$reflection = new \ReflectionObject($a);
$properties = $reflection->getProperties();

$c = count($properties);

echo $c . PHP_EOL;

if ($c) {
    echo $properties[0]->getValue($a) . PHP_EOL;

Expected result:
I'm not sure what is expected behaviour, but it's strange to have abiliti get property of ArrayObject and have not ability to get value of this property.

1. Properties have not be returned by ReflectionObject::getProperties()
------ EXPECTED -----
------ EXPECTED -----

2. Property values should be accessible by ReflectionProperty::getValue()
------ EXPECTED -----
------ EXPECTED -----

Actual result:

Notice: Undefined property: A::$test in /in/FbMbQ on line 14


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-05 17:02 UTC] ilya at antipenko dot pp dot ua
Seems caused by
 [2016-12-05 19:21 UTC]
-Status: Open +Status: Verified
 [2016-12-05 19:21 UTC]
Indeed, the notice is caused by commit a1ed4ab3[1]. However, the behavior didn't make sense before that commit, because the property's value was returned as NULL[2]. It seems to me that ::getProperties() should return 0 (as done by HHVM).

[1] <;a=commit;h=a1ed4ab3>
[2] <>
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Jan 24 16:01:24 2020 UTC