Files
piratepoet/mailpoet/tasks/phpstan/phpstan-baseline-fix-lib.php
Rodrigo Primo 76501d89d2 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]
2022-09-12 10:28:59 +01:00

21 lines
796 B
PHP

<?php
declare(strict_types = 1);
$config = [];
$phpVersion = (int)getenv('ANALYSIS_PHP_VERSION') ?: PHP_VERSION_ID;
$config['parameters']['phpVersion'] = $phpVersion;
# PHPStan allows us to declare the currently reported list of errors as “the baseline” and cause it not being reported in subsequent runs.
# 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 >= 70100 && $phpVersion < 80000) {
$config['includes'][] = 'phpstan-7-baseline.neon';
} elseif ($phpVersion >= 80000 && $phpVersion < 80100) {
$config['includes'][] = 'phpstan-8-baseline.neon';
} else {
$config['includes'][] = 'phpstan-8.1-baseline.neon';
}
return $config;