Bug #75507 [Com]: Cast in function
[email protected] ("sjon at hortensius dot net") Thu, 9 Nov 2017 14:19:32 GMT
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=75507&edit=1
ID: 75507
Comment by: sjon at hortensius dot net
Reported by: ciloe at hotmail dot fr
Summary: Cast in function
Status: Open
Type: Bug
Package: PHP Language Specification
PHP Version: 7.1.11
Block user comment: N
Private report: N
New Comment:
This is what strict-types are for - see https://3v4l.org/nUKlM and https://wiki.php.net/rfc/scalar_type_hints_v5
Previous Comments:
------------------------------------------------------------------------
[2017-11-09 14:03:43] ciloe at hotmail dot fr
Description:
------------
Hi, when you want to set an hard pypage in a function to test if you have a string/integer/float
The result of var_dump will be float(123) and not a typage error !!!
Test script:
---------------
function test (float $element)
{
var_dump($element);
}
test('123');
die;
Expected result:
----------------
Catchable fatal error: Argument 1 passed to test() must be an instance of float, instance of string given
Actual result:
--------------
float(123)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75507&edit=1