|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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 Mar 02 04:01:28 2024 UTC