#42258 [Asn->Bgs]: MethodParameter::getDefaultValue() return null

From: Date: Fri, 17 Aug 2007 14:24:28 +0000
Subject: #42258 [Asn->Bgs]: MethodParameter::getDefaultValue() return null
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-116245@lists.php.net to get a copy of this message
ID: 42258 Updated by: johannes@php.net Reported By: vincent dot hoen at gmail dot com -Status: Assigned +Status: Bogus Bug Type: Class/Object related Operating System: windows xp PHP Version: 5.2.4RC1 Assigned To: johannes New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Your code is wrong. The parameter to getValue has to be an instance of the reflected class, not the reflection object. Try <?php class test{ public $test = 'aze'; static $stat = 'ic'; } $class = new ReflectionClass('test'); foreach($class->getProperties() as $k => $v){ var_dump($v->getValue(new test())); } ?> instead. Previous Comments: ------------------------------------------------------------------------ [2007-08-17 13:47:01] jani@php.net Assigned to the maintainer of reflection extension. ------------------------------------------------------------------------ [2007-08-09 15:30:58] vincent dot hoen at gmail dot com Description: ------------ ReflectionProperty::getDefaultValue() returns null only if the property is not static. Reproduce code: --------------- class test{ public $test = 'aze'; static $stat = 'ic'; } $class = new ReflectionClass('test'); foreach($class->getProperties() as $k => $v){ var_dump($v->getValue($class)); } Expected result: ---------------- string 'aze' (length=3) string 'ic' (length=2) Actual result: -------------- null string 'ic' (length=2) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42258&edit=1

« previous php.bugs (#116245) next »