Add parameter for php version to static analysis command

[MAILPOET-3296]
This commit is contained in:
Rostislav Wolny
2020-12-02 13:28:37 +01:00
committed by Veljko V
parent dd3538b78d
commit 3845f400b1
5 changed files with 21 additions and 8 deletions

View File

@ -0,0 +1,38 @@
<?php
declare(strict_types = 1);
$config = [];
$phpVersion = (int)getenv('ANALYSIS_PHP_VERSION') ?: PHP_VERSION_ID;
$config['parameters']['phpVersion'] = $phpVersion;
# PHPStan gets smarter when runs on PHP8 and some type checks added because of PHP8 are reported as unnecessary when we run PHPStan on PHP7
# see https://github.com/phpstan/phpstan/issues/4060
if ($phpVersion < 80000) {
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Else branch is unreachable because ternary operator condition is always true#',
'path' => __DIR__ . '/../../lib/AdminPages/Pages/Forms.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Else branch is unreachable because ternary operator condition is always true#',
'path' => __DIR__ . '/../../lib/AdminPages/Pages/Newsletters.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Strict comparison using === between PDOStatement and false will always evaluate to false#',
'path' => __DIR__ . '/../../lib/Doctrine/Driver/PDOConnection.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Strict comparison using === between string and false will always evaluate to false#',
'path' => __DIR__ . '/../../lib/Doctrine/Driver/PDOConnection.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '#^Cannot access offset \\(int\\|string\\) on array\\|false#',
'path' => __DIR__ . '/../../lib/Features/FeatureFlagsController.php',
'count' => 1,
];
}
return $config;