php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #71363 No documentation on E_NOTICE for trailing characters with weak int/float hints
Submitted: 2016-01-13 23:44 UTC Modified: 2021-11-08 16:19 UTC
From: benjamin dot morel at gmail dot com Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 7.0.2 OS: Fedora 23
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: benjamin dot morel at gmail dot com
New email:
PHP Version: OS:

 

 [2016-01-13 23:44 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-13 23:58 UTC] requinix@php.net
-Summary: Inconsistent handling of malformed integers +Summary: No documentation on E_NOTICE for trailing characters with weak int/float hints -Type: Bug +Type: Documentation Problem
 [2016-01-13 23:58 UTC] 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
 [2021-11-08 16:19 UTC] cmb@php.net
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>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC