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