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

array_splice is not seen as modifying an array's count #5017

Closed
Seldaek opened this issue May 17, 2021 · 3 comments
Closed

array_splice is not seen as modifying an array's count #5017

Seldaek opened this issue May 17, 2021 · 3 comments
Labels
Milestone

Comments

@Seldaek
Copy link
Contributor

Seldaek commented May 17, 2021

Bug report

When using array_splice, the count of an array is assumed to still be non-zero, although all items may have been consumed by ref.

Code snippet that reproduces the problem

https://phpstan.org/r/ed7751a9-537f-4855-a940-9f63de5d1c10

Expected output

No error, as per https://3v4l.org/YoPBg you can very well see that it is not always false :)

Did PHPStan help you today? Did it make you happy in any way?

Definitely, I found some bugs in my code (and yours;)

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone May 17, 2021
@phpstan-bot
Copy link
Contributor

@Seldaek After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
+5: While loop condition is always true.
 8: Negated boolean expression is always false.
Full report
Line Error
5 While loop condition is always true.
8 Negated boolean expression is always false.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@6754df5

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants