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

Static analysis - avoid unnecessary counts #713

Open
norberttech opened this issue Nov 2, 2023 · 0 comments
Open

Static analysis - avoid unnecessary counts #713

norberttech opened this issue Nov 2, 2023 · 0 comments
Labels
Developer Experience Resolving this issue should improve development experience for the library users.
Milestone

Comments

@norberttech
Copy link
Member

It would be nice to have static analysis detect following scenario as invalid:

$array = [];

if (\count($array)) {
   foreach ($array as $element) {
        // some logic
   }
}

Since the array is not nullable foreach would do nothing, so count is unnecessary.

#Ref: #712 (comment)

@norberttech norberttech added the Developer Experience Resolving this issue should improve development experience for the library users. label Nov 2, 2023
@stloyd stloyd added this to the 0.6.0 milestone Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Resolving this issue should improve development experience for the library users.
Projects
None yet
Development

No branches or pull requests

2 participants