Skip to content

Commit 6f5a635

Browse files
committed
Merge branch 2.1.x into 2.2.x
2 parents 8a281e2 + 09bd9c3 commit 6f5a635

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎src/Command/AnalyseCommand.php‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPStan\Command;
44

5+
use DateTimeImmutable;
56
use OndraM\CiDetector\CiDetector;
67
use Override;
78
use PHPStan\Analyser\InternalError;
@@ -35,6 +36,7 @@
3536
use Symfony\Component\Console\Input\InputInterface;
3637
use Symfony\Component\Console\Input\InputOption;
3738
use Symfony\Component\Console\Input\StringInput;
39+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
3840
use Symfony\Component\Console\Output\OutputInterface;
3941
use Symfony\Component\Console\Output\StreamOutput;
4042
use Throwable;
@@ -63,6 +65,7 @@
6365
use function stream_get_contents;
6466
use function strlen;
6567
use function substr;
68+
use function time;
6669
use const PATHINFO_BASENAME;
6770
use const PATHINFO_EXTENSION;
6871

@@ -140,6 +143,34 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
140143
#[Override]
141144
protected function execute(InputInterface $input, OutputInterface $output): int
142145
{
146+
if ($output instanceof ConsoleOutputInterface) {
147+
$errorOutput = $output->getErrorOutput();
148+
$errorOutput->writeln('');
149+
$errorOutput->writeln("⚠️ You're running an old version of PHPStan.️");
150+
$errorOutput->writeln('');
151+
$errorOutput->writeln('The last release in the 1.12.x series with new features');
152+
153+
$lastRelease = new DateTimeImmutable('2025-07-17 00:00:00');
154+
$daysSince = (time() - $lastRelease->getTimestamp()) / 60 / 60 / 24;
155+
$errorOutput->writeln('and bugfixes was released on <fg=red>July 17th 2025</>,');
156+
$errorOutput->writeln(sprintf('that\'s <fg=red>%d days ago.</>', (int) $daysSince));
157+
$errorOutput->writeln('');
158+
159+
$errorOutput->writeln('Since then more than <fg=cyan>65 new PHPStan versions</> were released');
160+
$errorOutput->writeln('with hundreds of new features, bugfixes, and other');
161+
$errorOutput->writeln('quality of life improvements.');
162+
$errorOutput->writeln('');
163+
164+
$errorOutput->writeln("To learn about what you're missing out on, check out");
165+
$errorOutput->writeln('this blog with articles about the latest major releases:');
166+
$errorOutput->writeln('<options=underscore>https://phpstan.org/blog</>');
167+
$errorOutput->writeln('');
168+
169+
$errorOutput->writeln('Upgrade today to <fg=green>PHPStan 2.2 or newer</> by using');
170+
$errorOutput->writeln('<fg=cyan>"phpstan/phpstan": "^2.2"</> in your <fg=cyan>composer.json</>.');
171+
$errorOutput->writeln('');
172+
}
173+
143174
$paths = $input->getArgument('paths');
144175
$memoryLimit = $input->getOption('memory-limit');
145176
$autoloadFile = $input->getOption('autoload-file');

0 commit comments

Comments
 (0)