Edit report at https://bugs.php.net/bug.php?id=71363&edit=1
ID: 71363
Updated by: [email protected]
Reported by: benjamin dot morel at gmail dot com
Summary: No documentation on E_NOTICE for trailing characters
with weak int/float hints
Status: Open
Type: Documentation Problem
Package: Scripting Engine problem
Operating System: Fedora 23
PHP Version: 7.0.2
Block user comment: N
Private report: N
New Comment:
The behavior is now precisely documented[1]. The type
declarations section[2] could link to that, and should likely have
a general subsection about "coercive typing".
[1] <https://www.php.net/manual/en/language.types.numeric-strings.php>
[2] <https://www.php.net/manual/en/language.types.declarations.php>
Previous Comments:
------------------------------------------------------------------------
[2016-01-13 23:58:45] [email protected]
See https://wiki.php.net/rfc/scalar_type_hints#behaviour_of_weak_type_checks
I don't see any mention of the potential for notices on the function arguments page...
http://php.net/manual/en/functions.arguments.php
------------------------------------------------------------------------
[2016-01-13 23:44:21] benjamin dot morel at gmail dot com
Description:
------------
When using scalar type hinting, some malformed integers report a TypeError, while others raise a E_NOTICE.
Test script:
---------------
function test(int $a) {}
test(null); // TypeError
test("x"); // TypeError
test("x1"); // TypeError
test("1x"); // E_NOTICE
Expected result:
----------------
test("1x"); // TypeError
Actual result:
--------------
test("1x"); // E_NOTICE
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71363&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.