|  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
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.
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: Sat Apr 13 18:01:29 2024 UTC