Skip to content

Commit 72d5ba6

Browse files
authored
feat: Allow to pass host as the used PHP version (#1052)
1 parent 631bf7a commit 72d5ba6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Console/InputOption/PhpVersionInputOption.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static function createInputOption(): InputOption
3434
self::PHP_VERSION_OPT,
3535
null,
3636
InputOption::VALUE_REQUIRED,
37-
'PHP version in which the PHP parser and printer will be configured, e.g. "7.2".',
37+
'PHP version in which the PHP parser and printer will be configured, e.g. "7.2", or "host" for the current PHP version.',
3838
);
3939
}
4040

@@ -44,6 +44,10 @@ public static function getPhpVersion(IO $io): ?PhpVersion
4444
->getTypedOption(self::PHP_VERSION_OPT)
4545
->asNullableString();
4646

47+
if ('host' === $version) {
48+
return PhpVersion::getHostVersion();
49+
}
50+
4751
return null === $version
4852
? $version
4953
: PhpVersion::fromString($version);

tests/Console/InputOption/PhpVersionInputOptionTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public static function provideInput(): iterable
4747
self::createIO('8.2'),
4848
PhpVersion::fromComponents(8, 2),
4949
];
50+
51+
yield [
52+
self::createIO('host'),
53+
PhpVersion::fromComponents(PHP_MAJOR_VERSION, PHP_MINOR_VERSION),
54+
];
5055
}
5156

5257
private static function createIO(?string $value): IO

0 commit comments

Comments
 (0)