Doc #65241 [Com]: ReflectionProperty::getValue(void) is not a valid documentation

From: Date: Fri, 02 Aug 2013 05:55:52 +0000
Subject: Doc #65241 [Com]: ReflectionProperty::getValue(void) is not a valid documentation
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-10132@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65241&edit=1

 ID:                 65241
 Comment by:         logan at logansbailey dot com
 Reported by:        toycat at toycat dot eu
 Summary:            ReflectionProperty::getValue(void) is not a valid
                     documentation
 Status:             Open
 Type:               Documentation Problem
 Package:            Documentation problem
 Operating System:   MacOS X 10.8.4
 PHP Version:        5.4.17
 Block user comment: N
 Private report:     N

 New Comment:

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());


Previous Comments:
------------------------------------------------------------------------
[2013-07-11 09:01:50] 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



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65241&edit=1


Thread (3 messages)

« previous php.doc.bugs (#10132) next »