PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #33312 ReflectionParameter methods do not work correctly
Submitted:11 Jun 2005 4:03pm UTC Modified: 13 Jun 2005 11:41am UTC
From:sb at sebastian-bergmann dot de Assigned to:dmitry
Status:Closed Category:Scripting Engine problem
Version:5CVS-2005-06-11 (dev) OS:Windows XP
View/Vote Developer Edit Submission

Welcome! If you don't have a SVN account, you can't do anything here. You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
SVN Username: SVN Password:
Quick Fix:
Status: Assign to:
Category:
Summary:
From: sb at sebastian-bergmann dot de
New email:
Version: OS:
New/Additional Comment:

[11 Jun 2005 4:03pm UTC] sb at sebastian-bergmann dot de
Description:
------------
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:
---------------
<?php
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:
----------------
bar

[13 Jun 2005 10:43am UTC] sniper@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.

[13 Jun 2005 11:41am UTC] dmitry@php.net
Fixed in CVS HEAD.

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC