|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-01-19 20:36 UTC] ondrej at mirtes dot cz
Description: ------------ ReflectionMethod::invoke accepts one required parameter (the object) and then zero or more parameters that should be passed to the invoked method as stated in the documentation: https://secure.php.net/manual/en/reflectionmethod.invoke.php But the reported parameters by reflection are not consistent with that. It does not consider the second parameter as variadic and it considers it as required. I expect the second parameter to be reported as optional and as variadic. Test script: --------------- <?php $ref = new ReflectionClass('ReflectionMethod'); foreach ($ref->getMethod('invoke')->getParameters() as $parameter) { var_dump($parameter->getName()); var_dump($parameter->isOptional()); var_dump($parameter->isVariadic()); var_dump('---'); } Expected result: ---------------- string(6) "object" bool(false) bool(false) string(3) "---" string(4) "args" bool(true) bool(true) string(3) "---" Actual result: -------------- string(6) "object" bool(false) bool(false) string(3) "---" string(4) "args" bool(false) bool(false) string(3) "---" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 03:00:01 2025 UTC |
The reflection of the ReflectionMethod::invoke is certainly NOT in keeping with the documentation. Running: php --rc ReflectionMethod and then looking at the invoke() method shows ... Method [ <internal:Reflection> public method invoke ] { - Parameters [2] { Parameter #0 [ <required> $object ] Parameter #1 [ <required> $args ] } } Not HHVM. Not any PHP script. Just PHP.