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.
This commit is contained in:
Joe Nahmias 2023-01-11 23:43:16 -05:00 committed by Frédéric Guillot
parent 3824e6e9aa
commit 32667285a8
2 changed files with 4 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;
}
}