Bug #74150 [NEW]: Passing null value and default restriction

From: Date: Wed, 22 Feb 2017 16:12:57 +0000
Subject: Bug #74150 [NEW]: Passing null value and default restriction
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207509@lists.php.net to get a copy of this message
From: aaatoja at o2 dot pl Operating system: Debian PHP version: 7.1.2 Package: Class/Object related Bug Type: Bug Bug description:Passing null value and default restriction Description: ------------ Shouldn't code below throw TypeError exception: Argument 1 passed to test::a() must be of the type string, null given? Nullable type is not allowed here. This should work only with a(?string $x=null) Test script: --------------- class test { public function a(string $x=null) { echo 'a'; } } $x = new test; $x->a(null); Expected result: ---------------- TypeError exception Actual result: -------------- Null value as an argument is accepted. -- Edit bug report at https://bugs.php.net/bug.php?id=74150&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74150&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74150&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74150&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74150&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74150&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74150&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74150&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74150&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74150&r=support Expected behavior: https://bugs.php.net/fix.php?id=74150&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74150&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74150&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74150&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74150&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74150&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74150&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74150&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74150&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74150&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74150&r=mysqlcfg

« previous php.bugs (#207509) next »