#29523 [Csd]: ReflectionParameter::isOptional() is incorrect
| From: | helly@php.net | Date: | Wed, 04 Aug 2004 22:49:05 +0000 |
| Subject: | #29523 [Csd]: ReflectionParameter::isOptional() is incorrect | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-64099@lists.php.net to get a copy of this message | ||
ID: 29523
Updated by: helly@php.net
Reported By: Jared dot Williams1 at ntlworld dot com
Status: Closed
Bug Type: Class/Object related
Operating System: *
PHP Version: 5.1.0-dev
Assigned To: helly
New Comment:
Sorry will be fixed for 5.1.0
Previous Comments:
------------------------------------------------------------------------
[2004-08-05 00:48:10] helly@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php
------------------------------------------------------------------------
[2004-08-04 14:02:40] Jared dot Williams1 at ntlworld dot com
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 this bug report at http://bugs.php.net/?id=29523&edit=1