Bug #80948 [NEW]: Optional parameter can be null oven when type hint says no

From: Date: Mon, 12 Apr 2021 08:25:56 +0000
Subject: Bug #80948 [NEW]: Optional parameter can be null oven when type hint says no
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233355@lists.php.net to get a copy of this message
From: andre at webkr dot de Operating system: PHP version: 8.0.3 Package: *General Issues Bug Type: Bug Bug description:Optional parameter can be null oven when type hint says no Description: ------------ When a function parameter has a non-nullable type hint, it is still possible to give it a default of null. Test script: --------------- function foo(string $foo = null) { var_dump($foo); } foo(); Expected result: ---------------- Fatal error: Cannot use null as default value for parameter $foo of type string Actual result: -------------- NULL -- Edit bug report at https://bugs.php.net/bug.php?id=80948&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80948&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80948&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80948&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80948&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80948&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80948&r=support Expected behavior: https://bugs.php.net/fix.php?id=80948&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80948&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80948&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80948&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80948&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80948&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80948&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80948&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80948&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80948&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80948&r=mysqlcfg

« previous php.bugs (#233355) next »