php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65241 ReflectionProperty::getValue(void) is not a valid documentation
Submitted: 2013-07-11 09:01 UTC Modified: 2013-10-04 17:07 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: toycat at toycat dot eu Assigned: krakjoe (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.4.17 OS: MacOS X 10.8.4
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: toycat at toycat dot eu
New email:
PHP Version: OS:

 

 [2013-07-11 09:01 UTC] toycat at toycat dot eu
Description:
------------
The following is not a valid documentation (or there is a PHP bug):

public mixed ReflectionProperty::getValue ( void )

---
From manual page: http://www.php.net/reflectionproperty.getvalue#refsect1-
reflectionproperty.getvalue-description
---


Test script:
---------------
<?php
class MyClass {

    public $property = 'test';

}

$object = new MyClass();
$reflector = new \ReflectionObject($object);
var_dump($reflector->getProperty('property')->getValue());


Expected result:
----------------
Outputs:

string(4) "test"

Actual result:
--------------
Outputs:

<br />
<b>Warning</b>:  ReflectionProperty::getValue() expects exactly 1 parameter, 0 
given in <b>__FILE__</b> on line <b>10</b><br />
NULL


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-02 05:55 UTC] logan at logansbailey dot com
The definition of the parameter states:

If the property is non-static an object must be provided to fetch the property from. If you want to fetch the default property without providing an object use ReflectionClass::getDefaultProperties() instead. 

I believe that this functionality is accurately documented.

<?php
class MyClass {

    public $foo = 'test';
    public static $bar = 'test';

}

// Errors out
$fooReflector = new ReflectionProperty('MyClass', 'foo');
var_dump($fooReflector->getValue());

// Works
$staticReflector = new ReflectionProperty('MyClass', 'bar');
var_dump($staticReflector->getValue());

// Works because an instance of the object is passed in
var_dump($fooReflector->getValue(new MyClass()));

// Returns array('bar' => 'test', 'foo' => 'test')
$classReflector = new ReflectionClass('MyClass');
var_dump($classReflector->getDefaultProperties());
 [2013-10-04 17:07 UTC] krakjoe@php.net
Automatic comment from SVN on behalf of krakjoe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=331666
Log: #65241 correction to params in manual
 [2013-10-04 17:07 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2013-10-04 17:07 UTC] krakjoe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 05:00:01 2026 UTC