Bug #74150 [Opn->Nab]: Passing null value and default restriction
| From: | requinix@php.net | Date: | Wed, 22 Feb 2017 16:53:32 +0000 |
| Subject: | Bug #74150 [Opn->Nab]: Passing null value and default restriction | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207510@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74150&edit=1
ID: 74150
Updated by: requinix@php.net
Reported by: aaatoja at o2 dot pl
Summary: Passing null value and default restriction
-Status: Open
+Status: Not a bug
Type: Bug
Package: Class/Object related
Operating System: Debian
PHP Version: 7.1.2
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
> The declaration can be made to accept NULL values if the default value of the
> parameter is set to NULL.
Previous Comments:
------------------------------------------------------------------------
[2017-02-22 16:12:56] aaatoja at o2 dot pl
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 this bug report at https://bugs.php.net/bug.php?id=74150&edit=1