|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-06-16 18:18 UTC] krakjoe@php.net
-Package: Reflection related
+Package: Documentation problem
[2021-06-16 18:18 UTC] krakjoe@php.net
[2021-06-16 18:33 UTC] me at derrabus dot de
[2021-06-16 18:33 UTC] nikic@php.net
[2021-06-16 18:37 UTC] me at derrabus dot de
-Status: Open
+Status: Closed
[2021-06-16 18:37 UTC] me at derrabus dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 16:00:01 2025 UTC |
Description: ------------ If I reflect on a function that has an optional parameter before a mandatory one and I try to fetch the default value of the optional parameter, a ReflectionException is raised. This was not the case on PHP 8.0 and earlier. I am unsure if this is an intentional change because specifying a function where a mandatory parameter follows an optional one had already been deprecated in PHP 8.0. But I somewhat expected that the deprecation would not be turned into an error before PHP 9. Test script: --------------- <?php function myFunctionA(object $arg1 = null) { } function myFunctionB(object $arg1 = null, $arg2) { } var_dump((new ReflectionParameter('myFunctionA', 0))->getDefaultValue()); var_dump((new ReflectionParameter('myFunctionB', 0))->getDefaultValue()); Expected result: ---------------- NULL NULL Actual result: -------------- NULL Fatal error: Uncaught ReflectionException: Internal error: Failed to retrieve the default value