Bug report
I've just run pint against our repository and was surprised by our PHPStan errors increasing.
This mainly turned out to be because we had a baseline for this pattern that existed in the codebase
if (isset($searchParams['key']) && $searchParams['key'] && is_array($searchParams['key'])) {
if (count($searchParams['key']) > 0) {
// do query things here
}
}
PHPStan correctly infers that $searchParams['key'] must be a non-empty array because of the $searchParams['key'] in the if statement.
However, our error count raised because pint rationalised everything to using single quotes and it turns out that using single and double quotes treats the array keys differently. See the attached code snippet
Code snippet that reproduces the problem
https://phpstan.org/r/62bbf8b9-1d65-46d9-8211-7e3f132d2e86
Expected output
PHPStan should have errored on both single and double
Did PHPStan help you today? Did it make you happy in any way?
No response
Bug report
I've just run
pintagainst our repository and was surprised by our PHPStan errors increasing.This mainly turned out to be because we had a baseline for this pattern that existed in the codebase
PHPStan correctly infers that
$searchParams['key']must be a non-empty array because of the$searchParams['key']in theifstatement.However, our error count raised because
pintrationalised everything to using single quotes and it turns out that using single and double quotes treats the array keys differently. See the attached code snippetCode snippet that reproduces the problem
https://phpstan.org/r/62bbf8b9-1d65-46d9-8211-7e3f132d2e86
Expected output
PHPStan should have errored on both
singleanddoubleDid PHPStan help you today? Did it make you happy in any way?
No response