From 76501d89d2cfd97e90bc3e88f16093579d3a56e9 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Thu, 8 Sep 2022 17:10:26 -0300 Subject: [PATCH] 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] --- mailpoet/tasks/phpstan/phpstan-baseline-fix-lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mailpoet/tasks/phpstan/phpstan-baseline-fix-lib.php b/mailpoet/tasks/phpstan/phpstan-baseline-fix-lib.php index 1825063f9f..674a39bb88 100644 --- a/mailpoet/tasks/phpstan/phpstan-baseline-fix-lib.php +++ b/mailpoet/tasks/phpstan/phpstan-baseline-fix-lib.php @@ -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;