php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66821 stdClass properties cant be reflected
Submitted: 2014-03-04 19:02 UTC Modified: 2014-03-04 20:13 UTC
From: wjaspers4 at gmail dot com Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 5.5.9 OS: Linux 3.2.0-23-generic x86_64
Private report: No CVE-ID: None
 [2014-03-04 19:02 UTC] wjaspers4 at gmail dot com
Description:
------------
A stdClass object cannot reflect its properties correctly.
Normal objects do reflect as expected.

Test script:
---------------
https://gist.github.com/wjaspers/9353164

Expected result:
----------------
NULL
NULL

Actual result:
--------------
NULL
PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Property publicNullVar does not exist' in /test.php:19
Stack trace:
#0 /test.php(19): ReflectionClass->getProperty('publicNullVar')
#1 /test.php(49): Helper->__get('publicNullVar')
#2 {main}
  thrown in /test.php on line 19

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-04 19:39 UTC] wjaspers4 at gmail dot com
This bug also exists in PHP 5.3.9
 [2014-03-04 20:13 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-03-04 20:13 UTC] requinix@php.net
ReflectionClass works on class definitions, not object instances. Use ReflectionObject instead.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Apr 05 01:01:24 2020 UTC