Skip to content

Commit

Permalink
New argument "php-version" added
Browse files Browse the repository at this point in the history
--php-version allows to specify a PHP version, so PHPCS can change its behaviour accordingly to the specified PHP version.
  • Loading branch information
ᏒᏊᏀᏋᏒ ᏕξᏐ committed Sep 25, 2019
1 parent 4aedd92 commit 4b5780a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ private function parsePHPCSErrors(string $file): array
$php = $this->options['php'];
$phpcs = $this->options['phpcs'];
$warnings = $this->options['warnings'];
$execString = Util::isWindows() === true ? "$phpcs --report=json --standard=$stndr $file $warnings" :
"$php $phpcs --report=json --standard=$stndr '$file' $warnings";
$phpVersion = (empty($this->options['php-version']) === true) ? '' : "--runtime-set php_version {$this->options['php-version']}";
$execString = (Util::isWindows() === true) ? "$phpcs --report=json --standard=$stndr $file $warnings" :
"$php $phpcs --report=json --standard=$stndr '$file' $warnings $phpVersion";

$response = shell_exec($execString);
// Some encoding issues makes PHPCS return empty object, causing invalid JSON.
Expand Down
1 change: 1 addition & 0 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static function parseArgs(): array
'diff::',
'file::',
'php::',
'php-version::',
'phpcs::',
'repo::',
'standard::',
Expand Down

0 comments on commit 4b5780a

Please sign in to comment.