Combine PHPStan config files into one

Before this commit, we had two different PHPStan configuration files. One
for the lib directory (phpstan.neon) and another one for the tests directory
(phpstan-tests.neon). This commit combines both files into one
(phpstan.neon) to make it easier to maintain and make changes to PHPStan
configurations.

As part of this process, it was necessary to change the Robo command
`./do qa:phpstan` to call PHPStan only once and to
combine php-version-dependent-config-tests.php and
php-version-dependent-config-libs.php in a new file called
php-version-dependent-config.php.

Another benefit of this change is that running PHPStan only once with a
single configuration file means that it runs about 20% faster than
the previous setup.

[MAILPOET-4024]
This commit is contained in:
Rodrigo Primo
2021-12-14 20:15:22 -03:00
committed by Veljko V
parent cb13830574
commit ec18076f71
5 changed files with 23 additions and 61 deletions

View File

@@ -0,0 +1,18 @@
<?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' => '#^Cannot access offset \\(int\\|string\\) on array\\<string#',
'path' => __DIR__ . '/../../lib/Features/FeatureFlagsController.php',
'count' => 1,
];
}
return $config;