Doc #71363 [Opn]: No documentation on E_NOTICE for trailing characters with weak int/float hints
| From: | cmb@php.net | Date: | Mon, 08 Nov 2021 16:19:04 +0000 |
| Subject: | Doc #71363 [Opn]: No documentation on E_NOTICE for trailing characters with weak int/float hints | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-19314@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71363&edit=1
ID: 71363
Updated by: cmb@php.net
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] requinix@php.net
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