Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show runtime on version command #6222

Merged
merged 1 commit into from Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -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
SpacePossum marked this conversation as resolved.
Show resolved Hide resolved
* the command used to run PHP CS Fixer (run with `-vvv`)
* the configuration (file) you used
-->
Expand Down
3 changes: 2 additions & 1 deletion src/Console/Application.php
Expand Up @@ -122,7 +122,8 @@ public function getLongVersion(): string
$version = implode('', [
parent::getLongVersion(),
self::VERSION_CODENAME ? sprintf(' <info>%s</info>', self::VERSION_CODENAME) : '', // @phpstan-ignore-line to avoid `Ternary operator condition is always true|false.`
' by <comment>Fabien Potencier</comment> and <comment>Dariusz Ruminski</comment>',
' by <comment>Fabien Potencier</comment> and <comment>Dariusz Ruminski</comment>.',
"\nPHP runtime: <info>".PHP_VERSION.'</info>',
]);

$commit = '@git-commit@';
Expand Down
1 change: 0 additions & 1 deletion src/Console/Command/DescribeCommand.php
Expand Up @@ -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: <info>PHP %s</info>', PHP_VERSION));
}

$name = $input->getArgument('name');
Expand Down
1 change: 0 additions & 1 deletion src/Console/Command/FixCommand.php
Expand Up @@ -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: <info>PHP %s</info>', PHP_VERSION));
}

$configFile = $resolver->getConfigFile();
Expand Down
1 change: 0 additions & 1 deletion src/Console/Command/SelfUpdateCommand.php
Expand Up @@ -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: <info>PHP %s</info>', PHP_VERSION));
}

if (!$this->toolInfo->isInstalledAsPhar()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/ApplicationTest.php
Expand Up @@ -27,7 +27,7 @@ final class ApplicationTest extends TestCase
public function testApplication(): void
{
$app = new Application();
static::assertStringMatchesFormat('%s by <comment>Fabien Potencier</comment> and <comment>Dariusz Ruminski</comment>', $app->getLongVersion());
static::assertStringMatchesFormat("%s by <comment>Fabien Potencier</comment> and <comment>Dariusz Ruminski</comment>.\nPHP runtime: <info>%d.%d.%d</info>", $app->getLongVersion());
}

public function testGetMajorVersion(): void
Expand Down
7 changes: 3 additions & 4 deletions tests/Smoke/CiIntegrationTest.php
Expand Up @@ -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, '/'),
Expand Down
2 changes: 1 addition & 1 deletion tests/Smoke/PharTest.php
Expand Up @@ -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()
);
}
Expand Down