Skip to content

Commit e0fe44c

Browse files
committed
feature #37754 [FrameworkBundle] Add days before expiration in "about" command (noniagriconomie)
This PR was merged into the 5.2-dev branch. Discussion ---------- [FrameworkBundle] Add days before expiration in "about" command | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes (with RFC) | Deprecations? | no | Tickets | Slack discussion + see RFC below | License | MIT | Doc PR | Maybe this can be usefull in the `bin/console about` output. Following a small discussion on Slack <details> <summary>See discussion </summary> <img width="910" alt="sf_slack" src="https://user-images.githubusercontent.com/13205768/89516646-029dea00-d7d9-11ea-8ff5-eed5ae72fc77.png"> </details> --- Symfony 5.1 output: <img width="681" alt="sf51" src="https://user-images.githubusercontent.com/13205768/89515902-067d3c80-d7d8-11ea-8676-1f90dd0a3418.png"> --- Symfony 5.foo_bar output: With: ```php // symfony/http-kernel/Kernel.php const END_OF_MAINTENANCE = '08/2020'; // this month const END_OF_LIFE = '09/2020'; // next month ``` <img width="680" alt="sf51_fake" src="https://user-images.githubusercontent.com/13205768/89516056-375d7180-d7d8-11ea-9345-83db200a693d.png"> --- ## RFC Is there a way in Symfony land packages to have such info or/and in Composer in general? the EOL of a package version. Like for example the https://github.com/FriendsOfPHP/security-advisories `Security Advisories` feature, but for `End Of Life Advisories` where packages maintainers can add their packages, and this data can be read by `composer` or an other command ~Or maybe directly inside the `composer.json`, like an `"eol": "true"` // and `false` by default if not defined~ (not possible) Thanks Commits ------- 0b0a1f6f8e Add days before expiration in "about" command
2 parents e9083a9 + 6e2cf08 commit e0fe44c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Command/AboutCommand.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6666
new TableSeparator(),
6767
['Version', Kernel::VERSION],
6868
['Long-Term Support', 4 === Kernel::MINOR_VERSION ? 'Yes' : 'No'],
69-
['End of maintenance', Kernel::END_OF_MAINTENANCE.(self::isExpired(Kernel::END_OF_MAINTENANCE) ? ' <error>Expired</>' : '')],
70-
['End of life', Kernel::END_OF_LIFE.(self::isExpired(Kernel::END_OF_LIFE) ? ' <error>Expired</>' : '')],
69+
['End of maintenance', Kernel::END_OF_MAINTENANCE.(self::isExpired(Kernel::END_OF_MAINTENANCE) ? ' <error>Expired</>' : ' (<comment>'.self::daysBeforeExpiration(Kernel::END_OF_MAINTENANCE).'</>)')],
70+
['End of life', Kernel::END_OF_LIFE.(self::isExpired(Kernel::END_OF_LIFE) ? ' <error>Expired</>' : ' (<comment>'.self::daysBeforeExpiration(Kernel::END_OF_LIFE).'</>)')],
7171
new TableSeparator(),
7272
['<info>Kernel</>'],
7373
new TableSeparator(),
@@ -119,4 +119,11 @@ private static function isExpired(string $date): bool
119119

120120
return false !== $date && new \DateTime() > $date->modify('last day of this month 23:59:59');
121121
}
122+
123+
private static function daysBeforeExpiration(string $date): string
124+
{
125+
$date = \DateTime::createFromFormat('d/m/Y', '01/'.$date);
126+
127+
return (new \DateTime())->diff($date->modify('last day of this month 23:59:59'))->format('in %R%a days');
128+
}
122129
}

0 commit comments

Comments
 (0)