From a247d5851922578c182d46886f976725e961cf47 Mon Sep 17 00:00:00 2001 From: matlec Date: Sun, 29 Dec 2024 14:51:37 +0100 Subject: [PATCH] [Finder] Fix using `==` as default operator in `DateComparator` --- src/Symfony/Component/Finder/Comparator/DateComparator.php | 2 +- .../Component/Finder/Tests/Comparator/DateComparatorTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Finder/Comparator/DateComparator.php b/src/Symfony/Component/Finder/Comparator/DateComparator.php index e0c523d05523b..f7c27de677fb1 100644 --- a/src/Symfony/Component/Finder/Comparator/DateComparator.php +++ b/src/Symfony/Component/Finder/Comparator/DateComparator.php @@ -36,7 +36,7 @@ public function __construct(string $test) throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2])); } - $operator = $matches[1] ?? '=='; + $operator = $matches[1] ?: '=='; if ('since' === $operator || 'after' === $operator) { $operator = '>'; } diff --git a/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php b/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php index 47bcc4838bd26..e50b713062638 100644 --- a/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php +++ b/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php @@ -59,6 +59,7 @@ public static function getTestData() ['after 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]], ['since 2005-10-10', [strtotime('2005-10-15')], [strtotime('2005-10-09')]], ['!= 2005-10-10', [strtotime('2005-10-11')], [strtotime('2005-10-10')]], + ['2005-10-10', [strtotime('2005-10-10')], [strtotime('2005-10-11')]], ]; } }