From fbe882df5d5f26e768749b22f0b0d4c7a750bf8c Mon Sep 17 00:00:00 2001 From: Rogelio Jacinto Date: Fri, 22 Dec 2023 15:55:34 -0700 Subject: [PATCH] fix: validateJson should return false when value is null Return false when $value is null. Avoid TypeError: json_validate(): Argument #1 ($json) must be of type string, null given, when using symfony/polyfill-php83 in PHP < 8.3. Avoid deprecation warning: json_validate(): Passing null to parameter #1 ($json) of type string is deprecated, when using PHP 8.3. --- src/Illuminate/Validation/Concerns/ValidatesAttributes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 312c0b71e34c..b4335fe90059 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -1430,11 +1430,11 @@ public function validateMacAddress($attribute, $value) */ public function validateJson($attribute, $value) { - if (is_array($value)) { + if (is_array($value) || is_null($value)) { return false; } - if (! is_scalar($value) && ! is_null($value) && ! method_exists($value, '__toString')) { + if (! is_scalar($value) && ! method_exists($value, '__toString')) { return false; }