Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1 deprecation notice while generating running time value #3448

Closed
andypost opened this issue Oct 12, 2021 · 5 comments · Fixed by #3449
Closed

PHP 8.1 deprecation notice while generating running time value #3448

andypost opened this issue Oct 12, 2021 · 5 comments · Fixed by #3449

Comments

@andypost
Copy link
Contributor

andypost commented Oct 12, 2021

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

@andypost
Copy link
Contributor Author

#3182 (comment) said to file new issue

@andypost
Copy link
Contributor Author

steps to reproduce https://3v4l.org/flZrS

andypost added a commit to andypost/PHP_CodeSniffer that referenced this issue Oct 12, 2021
@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Oct 12, 2021
@gsherwood gsherwood added this to the 3.6.2 milestone Oct 12, 2021
@jrfnl
Copy link
Contributor

jrfnl commented Oct 12, 2021

@andypost Thanks for reporting this and for the PR.

I've had a look at your fix, but that fix has me scratching my head as round() accepts floats (or at least should) and arithmetic division with floats should also not be problematic. I'll need to take a closer look.

@andypost
Copy link
Contributor Author

Yes, the round() is fine but math inside of it throws.

@jrfnl
Copy link
Contributor

jrfnl commented Oct 31, 2021

@andypost Sorry for the delay, had a closer look now and left a review. The fix you pulled is incorrect and needs changing.

@gsherwood gsherwood changed the title PHP 8.1rc3 deprecation PHP 8.1 deprecation notice while generating running time value Nov 1, 2021
gsherwood pushed a commit that referenced this issue Nov 1, 2021
gsherwood added a commit that referenced this issue Nov 1, 2021
PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
PHPCS v3 Development
Ready for Release
3 participants