Skip to content

Commit 85565bd

Browse files
Modernize array utilities and JSON validation using PHP 8.4+ functions with polyfills (#7523)
Co-authored-by: 李铭昕 <715557344@qq.com>
1 parent 03f3222 commit 85565bd

2 files changed

Lines changed: 3 additions & 12 deletions

File tree

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"nesbot/carbon": "^2.21 || ^3.0",
2525
"psr/container": "^1.0 || ^2.0",
2626
"psr/event-dispatcher": "^1.0",
27-
"psr/http-message": "^1.0 || ^2.0"
27+
"psr/http-message": "^1.0 || ^2.0",
28+
"symfony/polyfill-php83": "^1.33"
2829
},
2930
"suggest": {
3031
"hyperf/database": "Required if you want to use the database validation rule (~3.2.0).",

src/Concerns/ValidatesAttributes.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -960,17 +960,7 @@ public function validateJson(string $attribute, $value): bool
960960
return false;
961961
}
962962

963-
if (function_exists('json_validate')) {
964-
return json_validate($value);
965-
}
966-
967-
try {
968-
json_decode($value, flags: JSON_THROW_ON_ERROR);
969-
} catch (Throwable) {
970-
return false;
971-
}
972-
973-
return true;
963+
return json_validate($value);
974964
}
975965

976966
/**

0 commit comments

Comments
 (0)