DowngradePhp73JsonConstRector
Remove Json constant that available only in php 7.3
-$json = json_encode($content, JSON_THROW_ON_ERROR);
+$json = json_encode($content);
+if (json_last_error() !== JSON_ERROR_NONE) {
+ throw new \Exception(json_last_error_msg());
+}
-$content = json_decode($json, null, 512, JSON_THROW_ON_ERROR);
+$content = json_decode($json, null, 512);
+if (json_last_error() !== JSON_ERROR_NONE) {
+ throw new \Exception(json_last_error_msg());
+}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\DowngradePhp73\Rector\ConstFetch\DowngradePhp73JsonConstRector;
return RectorConfig::configure()
->withRules([
DowngradePhp73JsonConstRector::class,
]);