Adds JSON_THROW_ON_ERROR to json_encode() and json_decode() to throw JsonException on error
-json_encode($content);
-json_decode($json);
+json_encode($content, JSON_THROW_ON_ERROR);
+json_decode($json, null, 512, JSON_THROW_ON_ERROR);
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
return RectorConfig::configure()
->withRules([
JsonThrowOnErrorRector::class,
]);