Bug report
If I array_pop on a non-empty-array, the returned value is never null, and so I should be able to array_unshift that value back onto the array (i.e. array_unshift($arr, array_pop($arr))). However, if I perform this operation in a single line, there seems to be some issue with determining the type of the array after the array_pop. If I do the array_pop on a separate line, then the error goes away.
I should note that this only seems to occur inside a class (as per my reproducer). If I have a free function and pass the same array type to it, the same error is not emitted.
This error started showing up in PHPStan 2.1.23, so I'm guessing it may be related to phpstan/phpstan-src#4294.
Code snippet that reproduces the problem
https://phpstan.org/r/69eefbd3-ef7c-43f0-894a-d8be8912e202
Expected output
No error.
Did PHPStan help you today? Did it make you happy in any way?
I haven't been able to do any PHP development for the past couple years, but I try to stay current with PHPStan versions. The work you all do is amazing, and I'm always fixing useful issues in my code as I update PHPStan!
Bug report
If I
array_popon a non-empty-array, the returned value is never null, and so I should be able toarray_unshiftthat value back onto the array (i.e.array_unshift($arr, array_pop($arr))). However, if I perform this operation in a single line, there seems to be some issue with determining the type of the array after thearray_pop. If I do thearray_popon a separate line, then the error goes away.I should note that this only seems to occur inside a class (as per my reproducer). If I have a free function and pass the same array type to it, the same error is not emitted.
This error started showing up in PHPStan 2.1.23, so I'm guessing it may be related to phpstan/phpstan-src#4294.
Code snippet that reproduces the problem
https://phpstan.org/r/69eefbd3-ef7c-43f0-894a-d8be8912e202
Expected output
No error.
Did PHPStan help you today? Did it make you happy in any way?
I haven't been able to do any PHP development for the past couple years, but I try to stay current with PHPStan versions. The work you all do is amazing, and I'm always fixing useful issues in my code as I update PHPStan!