|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79694 Coercion of ints to floats with return types even in strict mode not documented
Submitted: 2020-06-12 01:28 UTC Modified: 2020-06-12 03:34 UTC
From: cxlblm at gmail dot com Assigned:
Status: Verified Package: Scripting Engine problem
PHP Version: 7.4.7 OS: macos 10.15.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cxlblm at gmail dot com
New email:
PHP Version: OS:


 [2020-06-12 01:28 UTC] cxlblm at gmail dot com
We can see 
What is the type of numeric constant

Test script:

function testFloat(): float
    return 1;


function testInteger(): int
    return 1;



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-06-12 03:34 UTC]
-Summary: Whether a numeric constant needs to be an integer +Summary: Coercion of ints to floats with return types even in strict mode not documented -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem -Package: *General Issues +Package: Scripting Engine problem
 [2020-06-12 03:34 UTC]
The type is exactly what it looks like. No tricks.

integers may always be coerced to floats, even with strict_types=1. This is covered in the original RFC but not in the online docs for return types.

Note that section does mention return typing works like argument typing does, and their docs do mention the int->float exception.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 19:01:28 2024 UTC