Skip to content

PHP 8.1 deprecation notice while generating running time value #3448

@andypost

Description

@andypost

Describe the bug
Running sniffer on Drupal core I'm getting

PHP Deprecated:  Implicit conversion from float 235309.85403060913 to int loses precision in /var/www/html/web/vendor/squizlabs/php_codesniffer/src/Util/Timing.php on line 67

Deprecated: Implicit conversion from float 235309.85403060913 to int loses precision in /var/www/html/web/vendor/squizlabs/php_codesniffer/src/Util/Timing.php on line 67
Time: 3 mins, 55.31 secs; Memory: 158MB

Code sample
No idea, just a precision https://php.watch/versions/8.1/deprecate-implicit-conversion-incompatible-float-string

$t=152815.288066864; 
var_dump(((int)$t % 60000));
var_dump(($t % 60000));

To reproduce
Steps to reproduce the behavior:

  1. Sniffers should run longer 60 seconds
  2. https://3v4l.org/flZrS
  3. See error message displayed
Deprecated: Implicit conversion from float 152815.288066864 to int loses precision in .../vendor/squizlabs/php_codesniffer/src/Util/Timing.php on line 67

Expected behavior
Clean output

Versions (please complete the following information):

  • OS: Ubuntu 21.10
  • PHP: 8.1.0 rc3
  • PHPCS: 3.6.1
  • Standard: few sets

Additional context
I think this just needs to use different method to get integer part of timings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions