diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index af3574ca..537e5b5c 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -15,6 +15,15 @@ jobs: name: Static analysis with PHPStan # START: SHARED SETUP runs-on: ubuntu-latest + strategy: + matrix: + include: + - php-version: "8.2" + rector: "^1" + phpstan-config: phpstan-1.neon + - php-version: "8.2" + rector: "^2" + phpstan-config: phpstan.neon steps: - uses: actions/checkout@v3 - uses: shivammathur/setup-php@v2 @@ -28,5 +37,5 @@ jobs: # uses: mxschmitt/action-tmate@v2 # END: SHARED SETUP - - run: composer install - - run: composer phpstan + - run: composer require rector/rector:${{ matrix.rector }} --dev + - run: vendor/bin/phpstan analyse -c ${{ matrix.phpstan-config }} diff --git a/phpstan-1-baseline.neon b/phpstan-1-baseline.neon new file mode 100644 index 00000000..b9ccb198 --- /dev/null +++ b/phpstan-1-baseline.neon @@ -0,0 +1,159 @@ +parameters: + ignoreErrors: + - + message: "#^Access to undefined constant Rector\\\\Symfony\\\\Set\\\\TwigSetList\\:\\:TWIG_24\\.$#" + count: 1 + path: config/drupal-10/drupal-10.0-deprecations.php + + - + message: "#^Access to undefined constant Rector\\\\Symfony\\\\Set\\\\TwigSetList\\:\\:TWIG_24\\.$#" + count: 1 + path: config/drupal-9/drupal-9.0-deprecations.php + + - + message: """ + #^Call to deprecated method locateRoot\\(\\) of class DrupalFinder\\\\DrupalFinder\\: + Will be removed in v2\\. Future usage should instantiate + a new DrupalFinder object by passing the starting path to its + constructor\\.$# + """ + count: 1 + path: config/drupal-phpunit-bootstrap-file.php + + - + message: "#^Function drupal_phpunit_contrib_extension_directory_roots\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: config/drupal-phpunit-bootstrap-file.php + + - + message: "#^Function drupal_phpunit_find_extension_directories\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: config/drupal-phpunit-bootstrap-file.php + + - + message: "#^Function drupal_phpunit_get_extension_namespaces\\(\\) has parameter \\$dirs with no value type specified in iterable type array\\.$#" + count: 1 + path: config/drupal-phpunit-bootstrap-file.php + + - + message: "#^Function drupal_phpunit_get_extension_namespaces\\(\\) return type has no value type specified in iterable type array\\.$#" + count: 1 + path: config/drupal-phpunit-bootstrap-file.php + + - + message: "#^Function drupal_phpunit_populate_class_loader\\(\\) has no return type specified\\.$#" + count: 1 + path: config/drupal-phpunit-bootstrap-file.php + + - + message: "#^Function drupal_phpunit_populate_class_loader\\(\\) has parameter \\$drupalRoot with no type specified\\.$#" + count: 1 + path: config/drupal-phpunit-bootstrap-file.php + + - + message: "#^Function drupal_phpunit_populate_class_loader\\(\\) has parameter \\$vendorRoot with no type specified\\.$#" + count: 1 + path: config/drupal-phpunit-bootstrap-file.php + + - + message: """ + #^Instantiation of deprecated class DrupalFinder\\\\DrupalFinder\\: + in drupal\\-finder\\:1\\.3\\.0 and is removed from drupal\\-finder\\:2\\.0\\.0\\. + Use \\\\DrupalFinder\\\\DrupalFinderComposerRuntime instead\\.$# + """ + count: 1 + path: config/drupal-phpunit-bootstrap-file.php + + - + message: """ + #^Call to deprecated method locateRoot\\(\\) of class DrupalFinder\\\\DrupalFinder\\: + Will be removed in v2\\. Future usage should instantiate + a new DrupalFinder object by passing the starting path to its + constructor\\.$# + """ + count: 1 + path: rector.php + + - + message: """ + #^Instantiation of deprecated class DrupalFinder\\\\DrupalFinder\\: + in drupal\\-finder\\:1\\.3\\.0 and is removed from drupal\\-finder\\:2\\.0\\.0\\. + Use \\\\DrupalFinder\\\\DrupalFinderComposerRuntime instead\\.$# + """ + count: 1 + path: rector.php + + - + message: "#^Access to an undefined property PhpParser\\\\Node\\\\Expr\\:\\:\\$value\\.$#" + count: 2 + path: src/Drupal8/Rector/Deprecation/DBRector.php + + - + message: "#^Call to an undefined method PHPStan\\\\Type\\\\Type\\:\\:getValue\\(\\)\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/DrupalSetMessageRector.php + + - + message: "#^Access to an undefined property PhpParser\\\\Node\\\\Expr\\:\\:\\$expr\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/EntityLoadRector.php + + - + message: "#^Access to an undefined property PhpParser\\\\Node\\\\Expr\\:\\:\\$expr\\.$#" + count: 2 + path: src/Drupal8/Rector/Deprecation/EntityManagerRector.php + + - + message: "#^Access to an undefined property PhpParser\\\\Node\\\\Expr\\:\\:\\$name\\.$#" + count: 3 + path: src/Drupal8/Rector/Deprecation/EntityManagerRector.php + + - + message: "#^Method DrupalRector\\\\Drupal8\\\\Rector\\\\Deprecation\\\\EntityManagerRector\\:\\:getServiceByMethodName\\(\\) has no return type specified\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/EntityManagerRector.php + + - + message: "#^PHPDoc tag @param references unknown parameter\\: \\$node$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/EntityManagerRector.php + + - + message: "#^Parameter \\#1 \\$assign of method DrupalRector\\\\Drupal8\\\\Rector\\\\Deprecation\\\\EntityManagerRector\\:\\:findInstanceByNameInAssign\\(\\) expects PhpParser\\\\Node\\\\Expr\\\\Assign, PhpParser\\\\Node\\\\Expr given\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/EntityManagerRector.php + + - + message: "#^Parameter \\#1 \\$assign of method DrupalRector\\\\Drupal8\\\\Rector\\\\Deprecation\\\\EntityManagerRector\\:\\:replaceInstanceByNameInAssign\\(\\) expects PhpParser\\\\Node\\\\Expr\\\\Assign, PhpParser\\\\Node\\\\Expr given\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/EntityManagerRector.php + + - + message: "#^Parameter \\#1 \\$expr of method DrupalRector\\\\Drupal8\\\\Rector\\\\Deprecation\\\\EntityManagerRector\\:\\:refactorExpression\\(\\) expects PhpParser\\\\Node\\\\Expr\\\\MethodCall\\|PhpParser\\\\Node\\\\Expr\\\\StaticCall, PhpParser\\\\Node given\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/EntityManagerRector.php + + - + message: "#^Parameter \\#1 \\$expr of method DrupalRector\\\\Drupal8\\\\Rector\\\\Deprecation\\\\EntityManagerRector\\:\\:refactorExpression\\(\\) expects PhpParser\\\\Node\\\\Expr\\\\MethodCall\\|PhpParser\\\\Node\\\\Expr\\\\StaticCall, PhpParser\\\\Node\\\\Expr given\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/EntityManagerRector.php + + - + message: "#^Property PhpParser\\\\Node\\\\Expr\\\\Assign\\:\\:\\$expr \\(PhpParser\\\\Node\\\\Expr\\) does not accept PhpParser\\\\Node\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/EntityManagerRector.php + + - + message: "#^Calling PHPStan\\\\Php\\\\PhpVersionFactory\\:\\:create\\(\\) is not covered by backward compatibility promise\\. The method might change in a minor PHPStan version\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php + + - + message: "#^Method PHPStan\\\\Type\\\\Type\\:\\:isSmallerThanOrEqual\\(\\) invoked with 2 parameters, 1 required\\.$#" + count: 1 + path: src/Drupal8/Rector/Deprecation/FunctionalTestDefaultThemePropertyRector.php + + - + message: "#^Call to an undefined method PHPStan\\\\Type\\\\Type\\:\\:getValue\\(\\)\\.$#" + count: 1 + path: src/Drupal9/Rector/Deprecation/ExtensionPathRector.php diff --git a/phpstan-1.neon b/phpstan-1.neon new file mode 100644 index 00000000..74e16606 --- /dev/null +++ b/phpstan-1.neon @@ -0,0 +1,12 @@ +parameters: + level: 6 + paths: + - config + - src + - rector.php + bootstrapFiles: + - vendor/rector/rector/vendor/autoload.php + dynamicConstantNames: + - Drupal::VERSION +includes: + - phpstan-1-baseline.neon