Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Commit

Permalink
bug #777 PHP 8.2 Compatibility DateTime::getLastErrors (PhilETaylor)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 6.1.x-dev branch.

Discussion
----------

PHP 8.2 Compatibility DateTime::getLastErrors

DateTime::getLastErrors() is documented as returning `array|false` https://www.php.net/manual/en/datetime.getlasterrors.php

As discussed here symfony/symfony#47428 (comment)

`@derickr` quoted as saying
"This is a bug fix as the new 8.2 behaviour is how it has been documented for over a decade."

Commits
-------

00f08ea PHP 8.2 Compatibility DateTime::getLastErrors
  • Loading branch information
fabpot committed Sep 5, 2022
2 parents b27b8d6 + 00f08ea commit bb962f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Request/ParamConverter/DateTimeParamConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public function apply(Request $request, ParamConverter $configuration)
if (isset($options['format'])) {
$date = $class::createFromFormat($options['format'], $value);

if (0 < \DateTime::getLastErrors()['warning_count']) {
$errors = \DateTime::getLastErrors() ?: ['warning_count' => 0];

if (0 < $errors['warning_count']) {
$date = false;
}

Expand Down

0 comments on commit bb962f8

Please sign in to comment.