Change array_key_exists() ternary to coalescing
class SomeClass
{
public function run($values, $keyToMatch)
{
- $result = array_key_exists($keyToMatch, $values) ? $values[$keyToMatch] : null;
+ $result = $values[$keyToMatch] ?? null;
}
}
Configure your rector.php
:
<?php
use Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
ArrayKeyExistsTernaryThenValueToCoalescingRector::class,
]);