|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-10-26 08:43 UTC] nikic@php.net
-Status: Open
+Status: Not a bug
[2020-10-26 08:43 UTC] nikic@php.net
[2020-10-26 08:59 UTC] php at kriegt dot es
[2020-10-26 11:31 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 06:00:01 2025 UTC |
Description: ------------ In PHP < 8.0 it was possible to make an argument nullable without the question mark if the default value is null. This works fine if the variable is directly null, but not when the default value is an CONST with a null value Test script: --------------- <?php declare(strict_types=1); const ALLOW_ANY = null; var_dump(ALLOW_ANY); function foo(array $baz = ALLOW_ANY) { return true; } var_dump(foo(NULL)); Expected result: ---------------- NULL bool(true) Actual result: -------------- NULL Fatal error: Uncaught TypeError: foo(): Argument #1 ($baz) must be of type array, null given, called in /in/RLUo7 on line 14 and defined in /in/RLUo7:9 Stack trace: #0 /in/RLUo7(14): foo(NULL) #1 {main} thrown in /in/RLUo7 on line 9 Process exited with code 255.