diff --git a/src/Console/InputOption/PhpVersionInputOption.php b/src/Console/InputOption/PhpVersionInputOption.php index 9e50389d..4bdaf55d 100644 --- a/src/Console/InputOption/PhpVersionInputOption.php +++ b/src/Console/InputOption/PhpVersionInputOption.php @@ -34,7 +34,7 @@ public static function createInputOption(): InputOption self::PHP_VERSION_OPT, null, InputOption::VALUE_REQUIRED, - 'PHP version in which the PHP parser and printer will be configured, e.g. "7.2".', + 'PHP version in which the PHP parser and printer will be configured, e.g. "7.2", or "host" for the current PHP version.', ); } @@ -44,6 +44,10 @@ public static function getPhpVersion(IO $io): ?PhpVersion ->getTypedOption(self::PHP_VERSION_OPT) ->asNullableString(); + if ('host' === $version) { + return PhpVersion::getHostVersion(); + } + return null === $version ? $version : PhpVersion::fromString($version); diff --git a/tests/Console/InputOption/PhpVersionInputOptionTest.php b/tests/Console/InputOption/PhpVersionInputOptionTest.php index 4f090d76..f30c40ce 100644 --- a/tests/Console/InputOption/PhpVersionInputOptionTest.php +++ b/tests/Console/InputOption/PhpVersionInputOptionTest.php @@ -47,6 +47,11 @@ public static function provideInput(): iterable self::createIO('8.2'), PhpVersion::fromComponents(8, 2), ]; + + yield [ + self::createIO('host'), + PhpVersion::fromComponents(PHP_MAJOR_VERSION, PHP_MINOR_VERSION), + ]; } private static function createIO(?string $value): IO