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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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 20:01:29 2024 UTC