From 85bf144fd5a0856f5c9f3c0b4bdd7ce629b79f99 Mon Sep 17 00:00:00 2001 From: SpacePossum Date: Tue, 4 Jan 2022 19:20:30 +0000 Subject: [PATCH] Show runtime on version command --- .github/ISSUE_TEMPLATE/bug_report.md | 3 +-- src/Console/Application.php | 3 ++- src/Console/Command/DescribeCommand.php | 1 - src/Console/Command/FixCommand.php | 1 - src/Console/Command/SelfUpdateCommand.php | 1 - tests/Console/ApplicationTest.php | 2 +- tests/Smoke/CiIntegrationTest.php | 7 +++---- tests/Smoke/PharTest.php | 2 +- 8 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e7543950c16..b5404c7f53a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -10,8 +10,7 @@ labels: kind/bug Before reporting a bug, make sure PHP CS Fixer is up-to-date. Please describe the problem and provide technical details such as: - * PHP version: php -v - * PHP CS Fixer version: php-cs-fixer -V + * PHP CS Fixer version and PHP runtime: php-cs-fixer -V * the command used to run PHP CS Fixer (run with `-vvv`) * the configuration (file) you used --> diff --git a/src/Console/Application.php b/src/Console/Application.php index fcd9d4e48fd..e94fb821ff4 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -122,7 +122,8 @@ public function getLongVersion(): string $version = implode('', [ parent::getLongVersion(), self::VERSION_CODENAME ? sprintf(' %s', self::VERSION_CODENAME) : '', // @phpstan-ignore-line to avoid `Ternary operator condition is always true|false.` - ' by Fabien Potencier and Dariusz Ruminski', + ' by Fabien Potencier and Dariusz Ruminski.', + "\nPHP runtime: ".PHP_VERSION.'', ]); $commit = '@git-commit@'; diff --git a/src/Console/Command/DescribeCommand.php b/src/Console/Command/DescribeCommand.php index 23e6c561fc7..22ac8dadce6 100644 --- a/src/Console/Command/DescribeCommand.php +++ b/src/Console/Command/DescribeCommand.php @@ -101,7 +101,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity() && $output instanceof ConsoleOutputInterface) { $stdErr = $output->getErrorOutput(); $stdErr->writeln($this->getApplication()->getLongVersion()); - $stdErr->writeln(sprintf('Runtime: PHP %s', PHP_VERSION)); } $name = $input->getArgument('name'); diff --git a/src/Console/Command/FixCommand.php b/src/Console/Command/FixCommand.php index a2b96cf1d69..62c0778bbcb 100644 --- a/src/Console/Command/FixCommand.php +++ b/src/Console/Command/FixCommand.php @@ -268,7 +268,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (null !== $stdErr) { if (OutputInterface::VERBOSITY_VERBOSE <= $verbosity) { $stdErr->writeln($this->getApplication()->getLongVersion()); - $stdErr->writeln(sprintf('Runtime: PHP %s', PHP_VERSION)); } $configFile = $resolver->getConfigFile(); diff --git a/src/Console/Command/SelfUpdateCommand.php b/src/Console/Command/SelfUpdateCommand.php index d566a8c8a9c..6e3eb84285a 100644 --- a/src/Console/Command/SelfUpdateCommand.php +++ b/src/Console/Command/SelfUpdateCommand.php @@ -100,7 +100,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity() && $output instanceof ConsoleOutputInterface) { $stdErr = $output->getErrorOutput(); $stdErr->writeln($this->getApplication()->getLongVersion()); - $stdErr->writeln(sprintf('Runtime: PHP %s', PHP_VERSION)); } if (!$this->toolInfo->isInstalledAsPhar()) { diff --git a/tests/Console/ApplicationTest.php b/tests/Console/ApplicationTest.php index 5939b348e7c..dfaad1c034e 100644 --- a/tests/Console/ApplicationTest.php +++ b/tests/Console/ApplicationTest.php @@ -27,7 +27,7 @@ final class ApplicationTest extends TestCase public function testApplication(): void { $app = new Application(); - static::assertStringMatchesFormat('%s by Fabien Potencier and Dariusz Ruminski', $app->getLongVersion()); + static::assertStringMatchesFormat("%s by Fabien Potencier and Dariusz Ruminski.\nPHP runtime: %d.%d.%d", $app->getLongVersion()); } public function testGetMajorVersion(): void diff --git a/tests/Smoke/CiIntegrationTest.php b/tests/Smoke/CiIntegrationTest.php index f1cf541be67..566afd0b90d 100644 --- a/tests/Smoke/CiIntegrationTest.php +++ b/tests/Smoke/CiIntegrationTest.php @@ -166,17 +166,16 @@ public function testIntegration( /** @phpstan-ignore-next-line to avoid `Ternary operator condition is always true|false.` */ $aboutSubpattern = Application::VERSION_CODENAME - ? 'PHP CS Fixer '.preg_quote(Application::VERSION, '/').' '.preg_quote(Application::VERSION_CODENAME, '/').' by Fabien Potencier and Dariusz Ruminski' - : 'PHP CS Fixer '.preg_quote(Application::VERSION, '/').' by Fabien Potencier and Dariusz Ruminski'; + ? 'PHP CS Fixer '.preg_quote(Application::VERSION, '/').' '.preg_quote(Application::VERSION_CODENAME, '/')." by Fabien Potencier and Dariusz Ruminski.\nPHP runtime: ".PHP_VERSION + : 'PHP CS Fixer '.preg_quote(Application::VERSION, '/')." by Fabien Potencier and Dariusz Ruminski.\nPHP runtime: ".PHP_VERSION; $pattern = sprintf( - '/^(?:%s)?(?:%s)?(?:%s)?(?:%s)?%s\n%s\n%s\n([\.S]{%d})%s\n%s$/', + '/^(?:%s)?(?:%s)?(?:%s)?(?:%s)?%s\n%s\n([\.S]{%d})%s\n%s$/', preg_quote($optionalDeprecatedVersionWarning, '/'), preg_quote($optionalIncompatibilityWarning, '/'), preg_quote($optionalXdebugWarning, '/'), preg_quote($optionalWarningsHelp, '/'), $aboutSubpattern, - preg_quote(sprintf('Runtime: PHP %s', PHP_VERSION), '/'), preg_quote('Loaded config default from ".php-cs-fixer.dist.php".', '/'), \strlen($expectedResult3FilesDots), preg_quote($expectedResult3FilesPercentage, '/'), diff --git a/tests/Smoke/PharTest.php b/tests/Smoke/PharTest.php index f4b8810f3c8..633c26bf52e 100644 --- a/tests/Smoke/PharTest.php +++ b/tests/Smoke/PharTest.php @@ -56,7 +56,7 @@ public static function setUpBeforeClass(): void public function testVersion(): void { static::assertMatchesRegularExpression( - '/^.* '.Application::VERSION.'(?: '.Application::VERSION_CODENAME.')? by .*$/', + sprintf("/^.* %s(?: %s)? by .*\nPHP runtime: \\d\\.\\d+\\..*\$/", Application::VERSION, Application::VERSION_CODENAME), self::executePharCommand('--version')->getOutput() ); }