Fixer for PHPStan reports by strict type rule - "PHPStan\Rules\BooleansInConditions\BooleanInTernaryOperatorRule"
final class ArrayCompare
{
public function run(array $data)
{
- return $data ? 1 : 2;
+ return $data !== [] ? 1 : 2;
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Strict\Rector\Ternary\BooleanInTernaryOperatorRuleFixerRector;
return RectorConfig::configure()
->withConfiguredRule(BooleanInTernaryOperatorRuleFixerRector::class, [
'treat_as_non_empty' => false,
]);