Bug #81147 [NEW]: getDefaultValue() throws if a mandatory parameter follows

From: Date: Wed, 16 Jun 2021 18:02:37 +0000
Subject: Bug #81147 [NEW]: getDefaultValue() throws if a mandatory parameter follows
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234439@lists.php.net to get a copy of this message
From: me at derrabus dot de Operating system: macOS 11.4, Ubuntu 20.04 PHP version: 8.1.0alpha1 Package: Reflection related Bug Type: Bug Bug description:getDefaultValue() throws if a mandatory parameter follows 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 -- Edit bug report at https://bugs.php.net/bug.php?id=81147&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81147&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81147&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81147&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81147&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81147&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81147&r=support Expected behavior: https://bugs.php.net/fix.php?id=81147&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81147&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81147&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81147&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81147&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81147&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81147&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81147&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81147&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81147&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81147&r=mysqlcfg

« previous php.bugs (#234439) next »