Skip to content

Implicit Conversion from Float to Int #197

@DudeMason

Description

@DudeMason

We get hundreds of New Relic logs every day highlighting three specific lines of code where there's an implicit conversion from float to int.
In ImageResize.php there are many properties that have the potential to be a float or an int, since their type is not explicitly declared.

In the places where a function is expecting an int, the floats should explicitly be converted to integers, since that's what is occurring on implicit conversion anyway.

The functions expecting integers and throwing the warnings:

  • imagecopyresampled()
  • imagefilledrectangle()
  • imagecreatetruecolor()

Log output:

  • Implicit conversion from float 134.03444889187813 to int loses precision in /var/www/sites/default/vendor/gumlet/php-image-resize/lib/ImageResize.php on line 335
  • Implicit conversion from float 123.84051948785782 to int loses precision in /var/www/sites/default/vendor/gumlet/php-image-resize/lib/ImageResize.php on line 246
  • Implicit conversion from float 134.03444889187813 to int loses precision in /var/www/sites/default/vendor/gumlet/php-image-resize/lib/ImageResize.php on line 244

Please help us, we're drowning in warning logs 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions