phpstan icon indicating copy to clipboard operation
phpstan copied to clipboard

Bogus error when using empty in combination with ArrayObject

Open colorvamp opened this issue 3 months ago • 3 comments

Bug report

https://phpstan.org/r/26a6a63c-d15b-4e51-b4b5-17ae50979c58

When you generate an array from ArrayObject->getArrayCopy() phpstan is unable to identify emptyness

Expression in empty() is always falsy.

Code snippet that reproduces the problem

https://phpstan.org/r/26a6a63c-d15b-4e51-b4b5-17ae50979c58

Expected output

No errors

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

👍

colorvamp avatar Mar 25 '24 14:03 colorvamp

@ondrejmirtes isn't the root cause here the same as what was asked in https://github.com/phpstan/phpstan/discussions/8511#discussion-465317?

UPDATE: looks like you're normally linking to https://github.com/phpstan/phpstan/issues/6732#issuecomment-1062029088 :)

herndlm avatar Mar 25 '24 17:03 herndlm

Yes it is 😊

ondrejmirtes avatar Mar 25 '24 17:03 ondrejmirtes

So far you can do https://phpstan.org/r/6c18d3d3-e29c-41aa-b628-d826286859ec @colorvamp

VincentLanglet avatar Mar 25 '24 22:03 VincentLanglet