Run Rector on your code to see what it can do for you:

 <?php
 
-if (json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE){
+if (json_validate($json, true)){
     echo 1;
 }
 
-if (json_decode(associative: true, json: $json) !== null && json_last_error() === JSON_ERROR_NONE){
+if (json_validate(associative: true, json: $json)){
     echo 1;
 }
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: 5b90a0 - released at 2026-01-30 23:38