From b354e017ba7255de2ca7bdb8e738c6a68bb38316 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 4 Sep 2024 16:38:48 +0800 Subject: [PATCH] Add switch-php-version specific patch version support --- src/SPC/command/SwitchPhpVersionCommand.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/command/SwitchPhpVersionCommand.php b/src/SPC/command/SwitchPhpVersionCommand.php index ac5ae01f..f0f454dd 100644 --- a/src/SPC/command/SwitchPhpVersionCommand.php +++ b/src/SPC/command/SwitchPhpVersionCommand.php @@ -32,8 +32,12 @@ class SwitchPhpVersionCommand extends BaseCommand { $php_ver = $this->input->getArgument('php-major-version'); if (!in_array($php_ver, ['7.4', '8.0', '8.1', '8.2', '8.3'])) { - $this->output->writeln('Invalid PHP major version ' . $php_ver . ' !'); - return static::FAILURE; + // match x.y.z + preg_match('/^\d+\.\d+\.\d+$/', $php_ver, $matches); + if (!$matches) { + $this->output->writeln('Invalid PHP version ' . $php_ver . ' !'); + return static::FAILURE; + } } // detect if downloads/.lock.json exists