From d10ee6b86ac2384c36191d2a4a0953b8d28b7947 Mon Sep 17 00:00:00 2001 From: mamazu <14860264+mamazu@users.noreply.github.com> Date: Sat, 21 Mar 2026 22:01:38 +0100 Subject: [PATCH] Adding an age filter to the breakpoint command --- src/Command/BreakPointCommand.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Command/BreakPointCommand.php b/src/Command/BreakPointCommand.php index 3fae139..65ed731 100644 --- a/src/Command/BreakPointCommand.php +++ b/src/Command/BreakPointCommand.php @@ -24,9 +24,10 @@ public function __construct( /** * @param bool $dev Focus on dev packages only * @param int $limit Maximum number of outdated major version packages + * @param int $minDays Minimum number of days a release has to be old to be considered outdated * @param string[] $ignore Ignore packages by name, e.g. "symfony/" or "symfony/console" */ - public function run(bool $dev = false, int $limit = 5, array $ignore = []): int + public function run(bool $dev = false, int $limit = 5, int $minDays = 0, array $ignore = []): int { $this->outputPrinter->green('Analyzing "composer.json" for major outdated packages'); @@ -40,16 +41,26 @@ public function run(bool $dev = false, int $limit = 5, array $ignore = []): int } $composerJsonFilePath = getcwd() . '/composer.json'; + $now = new \DateTimeImmutable(); $outdatedComposer = $this->outdatedComposerFactory->createOutdatedComposer( array_filter( $responseJson[ComposerKey::INSTALLED_KEY], - static function (array $package) use ($ignore): bool { + static function (array $package) use ($ignore, $minDays, $now): bool { foreach ($ignore as $ignoredPackage) { if (str_contains((string) $package['name'], $ignoredPackage)) { return false; } } + if ($minDays === 0) { + return true; + } + + $pageAgeInDays = (new \DateTimeImmutable($package['latest-release-date']))->diff($now)->days; + if ($pageAgeInDays < $minDays) { + return false; + } + return true; } ),