|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-08-05 00:48 UTC] helly@php.net
[2004-08-05 00:49 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 06:00:01 2025 UTC |
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)