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

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

Open
etshy opened this issue Jul 9, 2024 · 2 comments
Open

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

etshy opened this issue Jul 9, 2024 · 2 comments

Comments

@etshy
Copy link

etshy commented Jul 9, 2024

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

@ea-inspections-team
Copy link
Collaborator

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.

@etshy
Copy link
Author

etshy commented Sep 18, 2024

A weak warning about code style seems good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants