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 count after using array_push #6974

Closed
saeideng opened this issue Apr 3, 2022 · 3 comments
Closed

array count after using array_push #6974

saeideng opened this issue Apr 3, 2022 · 3 comments
Labels
Milestone

Comments

@saeideng
Copy link

saeideng commented Apr 3, 2022

Bug report

phpstan could not understand count of array after using array_push

Code snippet that reproduces the problem

https://phpstan.org/r/d5e3c533-05e0-4cae-8f2d-157de6f05717

Expected output

no error

@phpstan-bot
Copy link
Contributor

@saeideng After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet:

@@ @@
 PHP 8.0 – 8.1 (1 error)
 ==========
 
-10: Variable $a in empty() always exists and is not falsy.
+10: Variable $a in empty() always exists and is always falsy.
 
 PHP 7.1 – 7.4 (2 errors)
 ==========
 
  9: Function array_push invoked with 1 parameter, at least 2 required.
-10: Variable $a in empty() always exists and is not falsy.
+10: Variable $a in empty() always exists and is always falsy.
Full report

PHP 8.0 – 8.1 (1 error)

Line Error
10 Variable $a in empty() always exists and is always falsy.

PHP 7.1 – 7.4 (2 errors)

Line Error
9 Function array_push invoked with 1 parameter, at least 2 required.
10 Variable $a in empty() always exists and is always falsy.

@ondrejmirtes
Copy link
Member

Fixed by phpstan/phpstan-src#1210

@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 May 21, 2022
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