From:             Jared dot Williams1 at ntlworld dot com
Operating system: Windows 2000/IIS 
PHP version:      5CVS-2004-08-04 (dev)
PHP Bug Type:     Class/Object related
Bug description:  ReflectionParameter::isOptional() is incorrect

Description:
------------
ReflectionParameter::isOptional() does not return the correct optional
status of some parameters.

ReflectionFunction::getNumberOfRequiredParameters() returns the current
number of required parameters, but when iterator through the
ReflectionFunction::getParamaters() counting parameters that are not
marked as optional, the value calculated is incorrect.


Reproduce code:
---------------
class TestClass
{
}
function optionalTest(TestClass $a, TestClass $b, $c = 3)
{
}

$function = new ReflectionFunction('optionalTest'); 
$numberOfNotOptionalParameters = 0;
$numberOfOptionalParameters = 0;
foreach($function->getParameters() as $parameter)
        if ($parameter->isOptional())
                ++$numberOfOptionalParameters;
        else
                ++$numberOfNotOptionalParameters;
var_dump($function->getNumberOfRequiredParameters());
var_dump($numberOfNotOptionalParameters);

Expected result:
----------------
int(2) int(2) 

Actual result:
--------------
int(2) int(0) 

-- 
Edit bug report at http://bugs.php.net/?id=29523&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29523&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29523&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29523&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29523&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29523&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29523&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29523&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29523&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29523&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29523&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29523&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29523&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29523&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29523&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29523&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29523&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29523&r=float

Reply via email to