Add parameter for php version to static analysis command
[MAILPOET-3296]
This commit is contained in:
committed by
Veljko V
parent
dd3538b78d
commit
3845f400b1
@ -491,7 +491,7 @@ class RoboFile extends \Robo\Tasks {
|
||||
}
|
||||
}
|
||||
|
||||
public function qaPhpstan() {
|
||||
public function qaPhpstan(array $opts=['php-version' => null]) {
|
||||
$dir = __DIR__;
|
||||
$task = implode(' ', [
|
||||
'WP_ROOT="' . getenv('WP_ROOT') . '"',
|
||||
@ -499,6 +499,10 @@ class RoboFile extends \Robo\Tasks {
|
||||
"$dir/tasks/phpstan/vendor/bin/phpstan analyse ",
|
||||
]);
|
||||
|
||||
if ($opts['php-version'] !== null) {
|
||||
$task = "ANALYSIS_PHP_VERSION={$opts['php-version']} $task";
|
||||
}
|
||||
|
||||
// PHPStan must be run out of main plugin directory to avoid its autoloading
|
||||
// from vendor/autoload.php where some dev dependencies cause conflicts.
|
||||
return $this->collectionBuilder()
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?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
|
||||
$config = [];
|
||||
|
||||
$config['parameters']['phpVersion'] = 80000;
|
||||
|
||||
if (PHP_VERSION_ID < 80000) {
|
||||
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',
|
8
tasks/phpstan/php-version-dependent-config-tests.php
Normal file
8
tasks/phpstan/php-version-dependent-config-tests.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
$config = [];
|
||||
$phpVersion = (int)getenv('ANALYSIS_PHP_VERSION') ?: PHP_VERSION_ID;
|
||||
$config['parameters']['phpVersion'] = $phpVersion;
|
||||
|
||||
return $config;
|
@ -43,4 +43,4 @@ includes:
|
||||
- extensions/CodeceptionExtension/extension.neon
|
||||
- phpstan-baseline-unit-tests.neon # https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff
|
||||
- phpstan-baseline-integration-tests.neon # https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff
|
||||
|
||||
- php-version-dependent-config-tests.php # PHP version detection + configuraton dependent on PHP version
|
||||
|
@ -41,4 +41,4 @@ includes:
|
||||
- vendor/phpstan/phpstan-doctrine/extension.neon
|
||||
- vendor/phpstan/phpstan-doctrine/rules.neon
|
||||
- phpstan-baseline.neon # https://medium.com/@ondrejmirtes/phpstans-baseline-feature-lets-you-hold-new-code-to-a-higher-standard-e77d815a5dff
|
||||
- php7-ignore-errors-libs.php # Errors that are ignored when run on PHP7
|
||||
- php-version-dependent-config-libs.php # PHP version detection + configuraton dependent on PHP version
|
||||
|
Reference in New Issue
Block a user