DowngradeJsonDecodeNullAssociativeArgRector
Downgrade json_decode() with null associative argument function
function exactlyNull(string $json)
{
- $value = json_decode($json, null);
+ $value = json_decode($json, true);
}
function possiblyNull(string $json, ?bool $associative)
{
- $value = json_decode($json, $associative);
+ $value = json_decode($json, $associative === null ?: $associative);
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\DowngradePhp72\Rector\FuncCall\DowngradeJsonDecodeNullAssociativeArgRector;
return RectorConfig::configure()
->withRules([
DowngradeJsonDecodeNullAssociativeArgRector::class,
]);