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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Apr 18 14:01:31 2024 UTC