From c606b4380b024e2dd1ad2a158ae1dcbe8360aeff Mon Sep 17 00:00:00 2001 From: Headgent Date: Thu, 11 Jun 2026 21:47:28 +0200 Subject: [PATCH] fix(phpstan): restructure schedule-description branching for PHPStan 2.2 (#7) PHPStan 2.2 (pulled fresh by CI, no lock tracked) flags the previous mutually exclusive if-chain as always-false/always-true via PHPDoc-certainty narrowing. Replaced with a nested decision tree that tests each cron field once per path - behavior unchanged, covered by existing Daily/Weekly/Monthly tests. --- src/Handler/DescribeExpression.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Handler/DescribeExpression.php b/src/Handler/DescribeExpression.php index a9c5c54..6871051 100644 --- a/src/Handler/DescribeExpression.php +++ b/src/Handler/DescribeExpression.php @@ -54,21 +54,21 @@ public function __invoke(): string } } - if ($minute !== null && count($minute) === 1 && $hour !== null && count($hour) === 1) { + if ($minute !== null && count($minute) === 1 && $hour !== null && count($hour) === 1 && $month === null) { $time = sprintf('%02d:%02d', $hour[0], $minute[0]); - if ($weekday !== null && count($weekday) === 1 && $day === null && $month === null) { - $dayName = self::WEEKDAY_NAMES[$weekday[0]] ?? 'Day ' . $weekday[0]; - return sprintf('Weekly on %s at %s', $dayName, $time); - } + if ($day === null) { + if ($weekday === null) { + return sprintf('Daily at %s', $time); + } - if ($day !== null && count($day) === 1 && $weekday === null && $month === null) { + if (count($weekday) === 1) { + $dayName = self::WEEKDAY_NAMES[$weekday[0]] ?? 'Day ' . $weekday[0]; + return sprintf('Weekly on %s at %s', $dayName, $time); + } + } elseif ($weekday === null && count($day) === 1) { return sprintf('Monthly on day %d at %s', $day[0], $time); } - - if ($day === null && $month === null && $weekday === null) { - return sprintf('Daily at %s', $time); - } } return 'Custom schedule';