From 32667285a8942a5c147ce308a8635fcdc84ce6b9 Mon Sep 17 00:00:00 2001 From: Joe Nahmias Date: Wed, 11 Jan 2023 23:43:16 -0500 Subject: [PATCH] fix: update test for DateTime parse errors to work in php8.2 check if getLastErrors() returns a false bool, rather than specific array elements, as this throws an error in php8.2 if there are no errors returned. --- app/Core/DateParser.php | 3 ++- libs/SimpleValidator/Validators/Date.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Core/DateParser.php b/app/Core/DateParser.php index 31528a11a..26cfaa844 100644 --- a/app/Core/DateParser.php +++ b/app/Core/DateParser.php @@ -204,7 +204,8 @@ class DateParser extends Base if ($date !== false) { $errors = DateTime::getLastErrors(); - if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) { + if ($errors === false || + $errors['error_count'] === 0 && $errors['warning_count'] === 0) { $timestamp = $date->getTimestamp(); return $timestamp > 0 ? $timestamp : 0; } diff --git a/libs/SimpleValidator/Validators/Date.php b/libs/SimpleValidator/Validators/Date.php index 4ec4b7fd3..b01d82f49 100644 --- a/libs/SimpleValidator/Validators/Date.php +++ b/libs/SimpleValidator/Validators/Date.php @@ -35,7 +35,8 @@ class Date extends Base if ($date !== false) { $errors = DateTime::getLastErrors(); - if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) { + if ($errors === false || + $errors['error_count'] === 0 && $errors['warning_count'] === 0) { return $date->getTimestamp() > 0; } }