php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81150 Deprecated non-integer-compatible float conversions missing from UPGRADING
Submitted: 2021-06-17 04:45 UTC Modified: 2021-06-17 05:14 UTC
From: call dot user dot func at gmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 8.1.0alpha1 OS: Windows 10
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: call dot user dot func at gmail dot com
New email:
PHP Version: OS:

 

 [2021-06-17 04:45 UTC] call dot user dot func at gmail dot com
Description:
------------
Hi. The following code produces a deprecation warning in 8.1 alpha.
Is it used to be like this or is it a bug?
I can't find such information in the deprecation information of https://github.com/php/php-src/blob/php-8.1.0alpha1/UPGRADING


Test script:
---------------
$arr = [];
$cellValue = 159.6;
var_dump(isset($arr[$cellValue]));


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-17 05:06 UTC] requinix@php.net
-Summary: Deprecation: Implicit conversion from float to int with array keys +Summary: Deprecated non-integer-compatible float conversions missing from UPGRADING -Status: Open +Status: Verified
 [2021-06-17 05:14 UTC] call dot user dot func at gmail dot com
Thanks for the fast response.

I never noticed that floats implicit casted to int in array keys.
This affect so many user land code, will be a hell of a job to fix that all.
PhpSpreadsheet for example throws millions of those deprecations because it uses raw cellValues as indexes of arrays.

But i see this a good change, because many, including me, will not have noticed that php does automaticy float to int cast in array keys.
As well i never really noticed that casting float to string will also result in that precision lost.

Thanks.
 [2021-06-17 07:52 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/deb7955bf44cb687419582e0ea58ff259c1952d5
Log: Fix #81150 Add UPGRADING note for float to int deprecation
 [2021-06-17 07:52 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 21:01:28 2024 UTC