|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-06-05 09:11 UTC] daverandom@php.net
-Status: Open
+Status: Not a bug
[2018-06-05 09:11 UTC] daverandom@php.net
[2018-06-05 09:17 UTC] requinix@php.net
-Type: Feature/Change Request
+Type: Bug
-Package: PHP Language Specification
+Package: Scripting Engine problem
[2018-06-05 09:17 UTC] requinix@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 20:00:02 2026 UTC |
Description: ------------ When passing null to a optional nullable type argument, the default value is overwritten. Test script: --------------- <?php function get(string $id, ?int $limit = 1, ?string $type = 'standard', ?array $options = []){ var_dump($limit); var_dump($type); } get(1, null, 'custom'); get(1, 10, null, ['my'=>'option']); Expected result: ---------------- Since 7.1 when the nullable types could be marked as null the situation where one needs to call a function while skipping some parameters is met with overwrite of the default values of the function arguments. For the above test script, when passing null and the argument is specifically declared as a nullable type, the parser should know to take the default value instead of overriding it as NULL. feature-php.php:4: 1 feature-php.php:5: string(6) "custom" feature-php.php:4: int(10) feature-php.php:5: standard Actual result: -------------- feature-php.php:4: NULL feature-php.php:5: string(6) "custom" feature-php.php:4: int(10) feature-php.php:5: NULL