Fix logic to decide which PHPStan baseline file to use

There was a bug in the code that is used to decide which version of
the PHPStan baseline file should be loaded depending on the PHP
version that is being used.

The if condition for PHP 8.1 was `$phpVersion == 80100` which means
that it matched only PHP 8.1.0 and not any of the 8.1 patch
versions (like 8.1.1 and 8.1.2).

This commit fixes this problem and it also changes the order of the
checks so that they follow the version numbers in ascending order.
Before the checks where unordered.

[MAILPOET-4626]
This commit is contained in:
Rodrigo Primo
2022-09-08 17:10:26 -03:00
committed by Oluwaseun Olorunsola
parent f62229eff4
commit 76501d89d2

View File

@ -9,12 +9,12 @@ $config['parameters']['phpVersion'] = $phpVersion;
# PHPStan will throw violations only in new and changed code.
# read more here: https://phpstan.org/user-guide/baseline
# we need to load different baseline file based on the php version
if ($phpVersion == 80100) {
$config['includes'][] = 'phpstan-8.1-baseline.neon';
} elseif ($phpVersion == 70100 || $phpVersion < 80000) {
if ($phpVersion >= 70100 && $phpVersion < 80000) {
$config['includes'][] = 'phpstan-7-baseline.neon';
} else {
} elseif ($phpVersion >= 80000 && $phpVersion < 80100) {
$config['includes'][] = 'phpstan-8-baseline.neon';
} else {
$config['includes'][] = 'phpstan-8.1-baseline.neon';
}
return $config;