diff --git a/src/Command/CodeCheckerCommand.php b/src/Command/CodeCheckerCommand.php index caac0f5b..f40729d5 100644 --- a/src/Command/CodeCheckerCommand.php +++ b/src/Command/CodeCheckerCommand.php @@ -39,7 +39,9 @@ protected function configure(): void ->setDescription('Run Moodle CodeSniffer standard on a plugin') ->addOption('standard', 's', InputOption::VALUE_REQUIRED, 'The name or path of the coding standard to use', 'moodle') ->addOption('max-warnings', null, InputOption::VALUE_REQUIRED, - 'Number of warnings to trigger nonzero exit code - default: -1', -1); + 'Number of warnings to trigger nonzero exit code - default: -1', -1) + ->addOption('testVersion', null, InputOption::VALUE_REQUIRED, + 'Version or range of version to test with PHPCompatibility', 0); } protected function initialize(InputInterface $input, OutputInterface $output): void @@ -82,6 +84,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $cmd[] = '--report-json=' . $this->tempFile; } + // Show PHPCompatibility backward-compatibility errors for a version or version range. + $testVersion = $input->getOption('testVersion'); + if (!empty($testVersion)) { + array_push($cmd, '--runtime-set', 'testVersion', $testVersion); + } + // Add the files to process. foreach ($files as $file) { $cmd[] = $file;