phpinspectionsea icon indicating copy to clipboard operation
phpinspectionsea copied to clipboard

Type casting shouldn't recommend `(int) $var` over `intval($var)` anymore

Open etshy opened this issue 1 year ago • 2 comments

Description (screenshot):

image

This inspection shouldn't be as "aggessive" as stroke the function as since php8.0 (at least) intval() (and similar type casting methods) are now faster than (or on par with) (int) $var syntax.

Example

Simple benchmark on lots of iteration to make results clear : https://3v4l.org/8fXUh

etshy avatar Jul 09 '24 14:07 etshy

Thank you for reporting @etshy!

With all improvements in PHP core since inspection was introduced, we can update the reporting to weak warning and move it into code style group. We will make the necessary changes as soon as capacity allows.

ea-inspections-team avatar Sep 18 '24 15:09 ea-inspections-team

A weak warning about code style seems good to me.

etshy avatar Sep 18 '24 15:09 etshy