Skip to content

Commit 4690279

Browse files
committed
bug #6997 Fix two phpstan findings (VincentLanglet)
This PR was merged into the 4.x branch. Discussion ---------- Fix two phpstan findings Now phpstan is bumped, and I checked error from the level 7 it's easier to find bug/edge cases. I found two easy "edge cases" to fix. Commits ------- 9faa3a0 Fix phpstan findings
2 parents 69a92e3 + 9faa3a0 commit 4690279

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/Factory/ActionFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ private function processActionLabel(ActionDto $actionDto, ?EntityDto $entityDto,
184184
if ($label instanceof TranslatableInterface) {
185185
$actionDto->setLabel(TranslatableMessageBuilder::withParameters($label, $translationParameters));
186186
} else {
187-
$translatableActionLabel = (null === $label || '' === $label) ? $label : t($label, $translationParameters, $translationDomain);
187+
$translatableActionLabel = (null === $label || '' === $label || false === $label)
188+
? $label
189+
: t($label, $translationParameters, $translationDomain);
188190
$actionDto->setLabel($translatableActionLabel);
189191
}
190192
}

src/Intl/IntlFormatter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ private function createNumberFormatter(?string $locale, string $style, array $at
276276
}
277277

278278
/**
279-
* @param \DateTimeZone|string|bool|null $timezone $timezone
279+
* @param \DateTimeZone|string|bool|null $timezone
280280
*/
281281
private function convertDate(?\DateTimeInterface $date, $timezone = null): ?\DateTimeInterface
282282
{
@@ -286,8 +286,10 @@ private function convertDate(?\DateTimeInterface $date, $timezone = null): ?\Dat
286286

287287
if (null === $timezone) {
288288
$timezone = new \DateTimeZone(date_default_timezone_get());
289-
} elseif (!$timezone instanceof \DateTimeZone) {
289+
} elseif (\is_string($timezone)) {
290290
$timezone = new \DateTimeZone($timezone);
291+
} elseif (!$timezone instanceof \DateTimeZone) {
292+
return $date;
291293
}
292294

293295
if ($date instanceof \DateTimeImmutable) {

tests/Intl/IntlFormatterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ public static function provideFormatDateTime()
170170
yield ['Nov 8, 2020, 3:04:05 AM', new \DateTimeImmutable('2020-11-07 15:04:05', new \DateTimeZone('America/Montevideo')), 'medium', 'medium', '', new \DateTimeZone('Asia/Tokyo'), 'gregorian', 'en'];
171171

172172
yield ['Nov 7, 2020, 2:04:05 PM', new \DateTime('2020-11-07 15:04:05 CET'), 'medium', 'medium', '', null, 'traditional', 'en'];
173+
174+
yield ['Nov 7, 2020, 2:04:05 PM', new \DateTime('2020-11-07 14:04:05 CET'), 'medium', 'medium', '', false, 'traditional', 'en'];
173175
}
174176

175177
public static function provideFormatNumber()

0 commit comments

Comments
 (0)