php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30146 ReflectionProperty->getValue() requires instance for static property
Submitted: 2004-09-19 00:26 UTC Modified: 2004-09-19 13:55 UTC
From: cellog@php.net Assigned: helly (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.0.* OS: *
Private report: No CVE-ID: None
 [2004-09-19 00:26 UTC] cellog@php.net
Description:
------------
When calling ReflectionProperty->getValue() on a public static property, getValue() requires an object instance to be passed in, even though this doesn't matter for static public properties.  It would be nice if null could be passed in addition to an instance.

Reproduce code:
---------------
<?php
class test {
  static public $a = 1;
}
$refl = new ReflectionProperty('test', 'a');
echo $refl->getValue(null);

Expected result:
----------------
1

Actual result:
--------------
Warning: getValue() expects parameter 1 to be object, null given in Command line code on line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-19 13:55 UTC] helly@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in 5.1-dev, we probably MFH it after 5.0.2 is out.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 17:01:30 2024 UTC