rector icon indicating copy to clipboard operation
rector copied to clipboard

[php 8.3] Add json_validate rule

Open TomasVotruba opened this issue 9 months ago • 1 comments

$json = '{"key": "value"}';
-if (json_decode($json, true) !== null && json_last_error() === JSON_ERROR_NONE) {
+if (json_validate($json)) {
    echo "Valid JSON";
}

TomasVotruba avatar May 06 '25 13:05 TomasVotruba

json_validate seems has flags parameter, the change seems documented at https://php.watch/versions/8.3/json_validate for the transformation needs.

samsonasik avatar May 19 '25 22:05 samsonasik

Downgrade first rule ready at:

  • https://github.com/rectorphp/rector-downgrade-php/pull/313

samsonasik avatar Sep 03 '25 10:09 samsonasik

implemented at PR

  • https://github.com/rectorphp/rector-src/pull/7213

samsonasik avatar Sep 04 '25 13:09 samsonasik