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:
@ -483,16 +483,10 @@ class RoboFile extends \Robo\Tasks {
|
||||
// temp dir
|
||||
->taskExec('mkdir -p ' . __DIR__ . '/temp')
|
||||
->taskExec('rm -rf ' . __DIR__ . '/temp/phpstan')
|
||||
// lib
|
||||
->taskExec($task)
|
||||
->arg("$dir/lib")
|
||||
->dir(__DIR__ . '/tasks/phpstan')
|
||||
|
||||
// tests
|
||||
->taskExec($task)
|
||||
->rawArg('--configuration=phpstan-tests.neon')
|
||||
->rawArg(
|
||||
implode(' ', [
|
||||
"$dir/lib",
|
||||
"$dir/tests/_support",
|
||||
"$dir/tests/DataFactories",
|
||||
"$dir/tests/acceptance",
|
||||
@ -501,7 +495,6 @@ class RoboFile extends \Robo\Tasks {
|
||||
])
|
||||
)
|
||||
->dir(__DIR__ . '/tasks/phpstan')
|
||||
|
||||
->run();
|
||||
}
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
$config = [];
|
||||
$phpVersion = (int)getenv('ANALYSIS_PHP_VERSION') ?: PHP_VERSION_ID;
|
||||
$config['parameters']['phpVersion'] = $phpVersion;
|
||||
|
||||
return $config;
|
@ -1,42 +0,0 @@
|
||||
parameters:
|
||||
level: 8
|
||||
tmpDir: ../../temp/phpstan
|
||||
bootstrapFiles:
|
||||
- ../../vendor/autoload.php
|
||||
- bootstrap.php
|
||||
- ../../vendor/codeception/codeception/autoload.php
|
||||
- ../../vendor/codeception/verify/src/Codeception/function.php
|
||||
- ../../vendor/codeception/verify/src/Codeception/Verify/Verify.php
|
||||
- ../../tests/_support/_generated/AcceptanceTesterActions.php
|
||||
- ../../tests/_support/_generated/IntegrationTesterActions.php
|
||||
- ../../tests/_support/_generated/UnitTesterActions.php
|
||||
scanDirectories:
|
||||
- ../../tests/_support
|
||||
- ../../tests/acceptance
|
||||
- ../../tests/integration
|
||||
- ../../tests/unit
|
||||
scanFiles:
|
||||
- PremiumContainerConfigurator.php
|
||||
- vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
|
||||
- custom-stubs.php
|
||||
ignoreErrors:
|
||||
- '/Parameter #1 \$cssOrXPath of method AcceptanceTester::moveMouseOver\(\) expects string\|null, array<string, string> given./'
|
||||
- '/Function expect invoked with 1 parameter, 0 required\./'
|
||||
- '/(with|has) no (return )?typehint specified/' # exclude level 6 errors
|
||||
- '/Call to method getName\(\) on an unknown class _generated\\([a-zA-Z])*Cookie/' # codeception generate incorrect return type in ../../tests/_support/_generated
|
||||
excludes_analyse:
|
||||
- ../../tests/_support/_generated
|
||||
- ../../tests/unit/Entities/SubscriberEntityTest.php
|
||||
parallel:
|
||||
processTimeout: 300.0
|
||||
maximumNumberOfProcesses: 4
|
||||
|
||||
# exclude level 6 errors
|
||||
checkMissingIterableValueType: false
|
||||
|
||||
includes:
|
||||
- vendor/phpstan/phpstan-doctrine/extension.neon
|
||||
- vendor/phpstan/phpstan-phpunit/extension.neon
|
||||
- vendor/szepeviktor/phpstan-wordpress/extension.neon
|
||||
- extensions/CodeceptionExtension/extension.neon
|
||||
- php-version-dependent-config-tests.php # PHP version detection + configuraton dependent on PHP version
|
@ -6,9 +6,22 @@ parameters:
|
||||
- bootstrap.php
|
||||
- vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
|
||||
- vendor/php-stubs/woocommerce-stubs/woocommerce-packages-stubs.php
|
||||
- ../../vendor/codeception/codeception/autoload.php
|
||||
- ../../vendor/codeception/verify/src/Codeception/function.php
|
||||
- ../../vendor/codeception/verify/src/Codeception/Verify/Verify.php
|
||||
- ../../tests/_support/_generated/AcceptanceTesterActions.php
|
||||
- ../../tests/_support/_generated/IntegrationTesterActions.php
|
||||
- ../../tests/_support/_generated/UnitTesterActions.php
|
||||
scanDirectories:
|
||||
- ../../tests/_support
|
||||
- ../../tests/acceptance
|
||||
- ../../tests/integration
|
||||
- ../../tests/unit
|
||||
scanFiles:
|
||||
- PremiumContainerConfigurator.php
|
||||
- ../../vendor-prefixed/twig/twig/src/Extension/CoreExtension.php # phpstan can't find \MailPoetVendor\twig_include function
|
||||
- vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
|
||||
- custom-stubs.php
|
||||
inferPrivatePropertyTypeFromConstructor: true
|
||||
parallel:
|
||||
processTimeout: 300.0
|
||||
@ -22,6 +35,9 @@ parameters:
|
||||
message: '#Property MailPoet\\Entities\\[a-zA-Z]+::\$[a-z]+ type mapping mismatch: property can contain MailPoet\\Entities\\[a-zA-Z]+\|null but database expects MailPoet\\Entities\\[a-zA-Z]+.#'
|
||||
path: ../../lib/Entities/ScheduledTaskSubscriberEntity.php
|
||||
count: 2
|
||||
- '/Parameter #1 \$cssOrXPath of method AcceptanceTester::moveMouseOver\(\) expects string\|null, array<string, string> given./'
|
||||
- '/Function expect invoked with 1 parameter, 0 required\./'
|
||||
- '/Call to method getName\(\) on an unknown class _generated\\([a-zA-Z])*Cookie/' # codeception generate incorrect return type in ../../tests/_support/_generated
|
||||
reportUnmatchedIgnoredErrors: true
|
||||
dynamicConstantNames:
|
||||
- MAILPOET_PREMIUM_INITIALIZED
|
||||
@ -31,11 +47,14 @@ parameters:
|
||||
# exclude level 6 errors
|
||||
checkMissingIterableValueType: false
|
||||
|
||||
# analysis of templates is extremely slow, let's skip them for now
|
||||
excludes_analyse:
|
||||
- ../../lib/Config/PopulatorData/Templates
|
||||
- ../../lib/Config/PopulatorData/Templates # analysis of templates is extremely slow, let's skip them for now
|
||||
- ../../tests/_support/_generated
|
||||
- ../../tests/unit/Entities/SubscriberEntityTest.php
|
||||
includes:
|
||||
- extensions/CodeceptionExtension/extension.neon
|
||||
- vendor/phpstan/phpstan-doctrine/extension.neon
|
||||
- vendor/phpstan/phpstan-phpunit/extension.neon
|
||||
- vendor/phpstan/phpstan-doctrine/rules.neon
|
||||
- vendor/szepeviktor/phpstan-wordpress/extension.neon
|
||||
- php-version-dependent-config-libs.php # PHP version detection + configuraton dependent on PHP version
|
||||
- php-version-dependent-config.php # PHP version detection + configuraton dependent on PHP version
|
||||
|
Reference in New Issue
Block a user