Skip to content

Commit

Permalink
Add configuration value auto_php_version
Browse files Browse the repository at this point in the history
We now support the new configuration option `auto_php_version`
(default: true) to automatically pass currenct PHP runtime version to
psalm via parameter `--php-version=`.
This helps to avoid issues like
vimeo/psalm#7026
  • Loading branch information
discordier committed Feb 25, 2022
1 parent 28c9464 commit 24526de
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/psalm.php
Expand Up @@ -28,6 +28,10 @@ public function describeConfiguration(PluginConfigurationBuilderInterface $confi
->withDefaultValue(false);
$configOptionsBuilder
->describeStringOption('shepherd_host', 'Override shepherd host');
$configOptionsBuilder
->describeBoolOption('auto_php_version', 'Automatically pass the current PHP version to psalm')
->isRequired()
->withDefaultValue(true);

$configOptionsBuilder
->describeStringListOption(
Expand Down Expand Up @@ -67,6 +71,11 @@ private function buildArguments(
): array {
$arguments = [];

if ($config->getBool('auto_php_version')) {
$arguments[] = '--php-version=' .
implode('.', array_slice(explode('.', PHP_VERSION), 0, 3));
}

foreach (['debug', 'debug_by_line'] as $flag) {
if ($config->getBool($flag)) {
$arguments[] = '--' . str_replace('_', '-', $flag);
Expand Down

0 comments on commit 24526de

Please sign in to comment.