[wp-trac] [WordPress Trac] #57205: PHP 8.1 warning : Implicit conversion from float 9.9 to int loses precision

WordPress Trac noreply at wordpress.org
Fri Jan 20 09:21:24 UTC 2023


#57205: PHP 8.1 warning : Implicit conversion from float 9.9 to int loses precision
-------------------------------------+----------------------
 Reporter:  roadlink                 |       Owner:  (none)
     Type:  defect (bug)             |      Status:  closed
 Priority:  normal                   |   Milestone:
Component:  General                  |     Version:  4.7
 Severity:  normal                   |  Resolution:  invalid
 Keywords:  php81 reporter-feedback  |     Focuses:
-------------------------------------+----------------------
Changes (by jrf):

 * status:  reopened => closed
 * resolution:   => invalid


Comment:

 Replying to [comment:5 mcaskill]:
 > I've been encountering this deprecation warning as well in recent
 projects. As mentioned already, this stems from third-party software using
 floats as a hook priority.

 Which only goes to confirm this should be **fixed** in the **third-party
 software**.


 > Since, historically, floats have been permitted...

 Historically, floats were never "permitted", they just accidentally worked
 due to a quirk in PHP. The function has always been documented to expect
 integers and this has not changed.


 > and prior to PHP 8 were implicitly converted to strings, we could
 explicitly convert them to strings in order to support PHP 8+ without
 introducing a breaking change compared to this older ticket (#30875) which
 proposed enforcing only integers.

 This would **''hide''** an error, which should be ''fixed'' (in the third
 party software) instead. We're not helping anyone by hiding away helpful
 notices/warnings. This will only cause more problems later on.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57205#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list