Bug #73380 [Opn->Nab]: Fatal error when passing function arguments with type-hinting
| From: | requinix@php.net | Date: | Mon, 24 Oct 2016 06:53:11 +0000 |
| Subject: | Bug #73380 [Opn->Nab]: Fatal error when passing function arguments with type-hinting | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204981@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73380&edit=1
ID: 73380
Updated by: requinix@php.net
Reported by: er dot haridarshan at gmail dot com
Summary: Fatal error when passing function arguments with
type-hinting
-Status: Open
+Status: Not a bug
Type: Bug
-Package: Compile Failure
+Package: Scripting Engine problem
Operating System: Fedora 24
PHP Version: 7.0.12
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
There's a big red warning in the documentation about this.
http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
Previous Comments:
------------------------------------------------------------------------
[2016-10-24 06:46:31] er dot haridarshan at gmail dot com
Description:
------------
When arguments are type-hinted in function, PHP throw fatal error when type-hint is double and
boolean. In case of boolean, if it changes to bool, It doesn't give any fatal error
Test script:
---------------
function test(array $a, string $b, int $c, float $d, double $e, boolean $f)
{
echo "ok";
}
test(["1"], "string", 1, 1.2, (double)1.2, false);
Expected result:
----------------
Simply print output as "ok"
Actual result:
--------------
PHP Fatal error: Uncaught TypeError: Argument 5 passed to test() must be an instance of double,
float given
PHP Fatal error: Uncaught TypeError: Argument 6 passed to test() must be an instance of boolean,
boolean given
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73380&edit=1