php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73380 Fatal error when passing function arguments with type-hinting
Submitted: 2016-10-24 06:46 UTC Modified: 2016-10-24 06:53 UTC
From: er dot haridarshan at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0.12 OS: Fedora 24
Private report: No CVE-ID: None
 [2016-10-24 06:46 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-24 06:53 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: Compile Failure +Package: Scripting Engine problem
 [2016-10-24 06:53 UTC] requinix@php.net
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
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Oct 11 13:00:01 2026 UTC