Yii2 DateValidator Warning

the following lines in datevalidator raise a PHP Warning. If $date is a proper date, then $errors is false and trying to access $errors[‘error_count’] raises a warning that you try to access a boolean like an array

private function parseDateValuePHP($value, $format)
{
$hasTimeInfo = strpbrk($format, ‘HhGgisU’) !== false;
// if no time was provided in the format string set timezone to default one to match yii\i18n\Formatter::formatDateTimeValue()
$timezone = $hasTimeInfo ? $this->timeZone : $this->defaultTimeZone;
$date = DateTime::createFromFormat($format, $value, new DateTimeZone($timezone));
$errors = DateTime::getLastErrors();
if ($date === false || $errors[‘error_count’] || $errors[‘warning_count’] || ($this->strictDateFormat && $date->format($format) !== $value)) {
return false;
}
if (!$hasTimeInfo) {
// if no time was provided in the format string set time to 0 to get a simple date timestamp
$date->setTime(0, 0, 0);
}
return $date->getTimestamp();
}