|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33312 ReflectionParameter methods do not work correctly
Submitted: 2005-06-11 16:03 UTC Modified: 2005-06-13 11:41 UTC
From: sb at sebastian-bergmann dot de Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-06-11 (dev) OS: Windows XP
Private report: No CVE-ID: None
 [2005-06-11 16:03 UTC] sb at sebastian-bergmann dot de
The ReflectionParameter::isDefaultValueAvailable() and ReflectionParameter::getDefaultValue() methods only work correctly when the method only has one parameter.

When the method has more than one parameter, ReflectionParameter::isDefaultValueAvailable() returns FALSE for a parameter that has a default value and ReflectionParameter::getDefaultValue() produces an error when trying to access the default value.

The reproducing script below works fine with the current PHP_5_0 branch. With HEAD it prints nothing. Only after removing "Foo $foo, " from the method signature does it print "bar".

Reproduce code:
class Foo {
    public function bar(Foo $foo, $bar = 'bar') {

$class = new ReflectionClass('Foo');
$method = $class->getMethod('bar');

foreach ($method->getParameters() as $parameter) {
    if ($parameter->isDefaultValueAvailable()) {
        print $parameter->getDefaultValue();

Expected result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-13 10:43 UTC]
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
Thank you for the report, and for helping us make PHP better.

 [2005-06-13 11:41 UTC]
Fixed in CVS HEAD.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 08:01:25 2019 UTC