Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to PHPstan 2 and Rector 2 #312

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2208f50
update to rector 2.0-rc2 and bump phpstan dependencies to 2.x
ptmkenny Dec 12, 2024
5148bed
use rc3
ptmkenny Dec 12, 2024
d83f9ec
rector 2.0.0-rc3 requires phpstan 2.0.1
ptmkenny Dec 12, 2024
1e5a085
remove functional tests for Drupal 9 because PHP 8.0 is not supported…
ptmkenny Dec 12, 2024
8c434cf
require rector 2.0 final
ptmkenny Jan 6, 2025
b3b823c
fix: remove deprecated SetInterface
bbrala Jan 24, 2025
6afdd39
build: fix codestyle
bbrala Jan 24, 2025
9bda6bf
Merge remote-tracking branch 'origin/feature/deprecated-setinterface'…
bbrala Jan 24, 2025
3b2eb98
fix: BC twig setlist
bbrala Jan 24, 2025
9a67073
fix: narrow return
bbrala Jan 24, 2025
62678b9
fix: remove unneeded assert
bbrala Jan 24, 2025
95a6cff
fix: remove unneeded assert
bbrala Jan 24, 2025
5d00610
fix: remove unneeded instanceof check
bbrala Jan 24, 2025
992a2ba
fix: remove unneeded instanceof check
bbrala Jan 24, 2025
114657c
fix: remove extra ctype cheks
bbrala Jan 24, 2025
daf3496
fix: REMOVE_NODE constant has moved
bbrala Jan 24, 2025
5cde781
Merge remote-tracking branch 'refs/remotes/origin/feature/remove-depr…
bbrala Jan 24, 2025
c00a3fb
fix: small type
bbrala Jan 24, 2025
48ec445
build: fix codestlye
bbrala Jan 24, 2025
ca9fcbe
fix: fix types for EntityManagerRector.php
bbrala Jan 24, 2025
3ad8fc8
fix: fix unit tests with check for consstant
bbrala Jan 24, 2025
4e87ead
Merge remote-tracking branch 'origin/feature/remove-deprecations' int…
bbrala Jan 24, 2025
26f94eb
fix: remove scope aware rector as per upgrade notes
bbrala Jan 24, 2025
634e415
build: codestyle passrector
bbrala Jan 24, 2025
a795d2b
fix: fix return types for AssertFieldByIdRector.php
bbrala Jan 24, 2025
d0cd957
fix: AssertFieldByNameRector.php return type
bbrala Jan 24, 2025
6198c0c
fix: PassRector.php return type
bbrala Jan 24, 2025
cc67b8f
fix: isSmallerThanOrEqual now requires phpversion as paramter
bbrala Jan 24, 2025
70eaed8
fix: BC for scopefetcher for phpstan 1
bbrala Jan 24, 2025
988ba9c
buid: add phpunit tests on phpstan 1 and 2
bbrala Jan 24, 2025
f34bc0d
build: allow phpstan 1 and 2
bbrala Jan 24, 2025
1c3fc2d
build: fix codestyle
bbrala Jan 24, 2025
26d0d75
build: fix unit tests workflow
bbrala Jan 24, 2025
8870411
build: fix unit tests workflow name
bbrala Jan 24, 2025
af3ff27
build: fix unit tests workflow require
bbrala Jan 24, 2025
4f4760c
build: fix phpunit naming, do rector not phpstan.
bbrala Jan 24, 2025
a4dc6d7
build: fix a few phpstan erros
bbrala Jan 24, 2025
14c08eb
build: remove error from baseline
bbrala Jan 24, 2025
23dd177
build: composer.json update formatting for rector requirement
bbrala Jan 24, 2025
e965770
build: fix codestyle for PassRector.php
bbrala Jan 24, 2025
7878d2f
Merge remote-tracking branch 'origin/feature/remove-deprecations' int…
bbrala Jan 24, 2025
f66b276
build: typo in phpstan ignore
bbrala Jan 24, 2025
d02c8b3
Merge remote-tracking branch 'refs/remotes/origin/feature/remove-depr…
bbrala Jan 24, 2025
d5cf117
build: update baseline to add the BC promise stuff
bbrala Jan 24, 2025
afcbdb0
fix: enhance AnnotationToAttributeRector to handle Doctrine annotatio…
bbrala Jan 31, 2025
024b06d
build: add phpstan 1 check also for if we are gonna support both vers…
bbrala Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/functional_test__rector_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: "8.0"
drupal: "^9.2"
fixture: "d9"
- php-version: "8.1"
drupal: "^10.0"
fixture: "d10"
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
11 changes: 7 additions & 4 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ on:

jobs:
tests:
name: 'PHPUnit | PHP ${{ matrix.php-version }}'
name: 'PHPUnit | rector/rector:${{ matrix.rector }}'
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "8.2"
include:
- php-version: "8.2"
rector: "^1"
- php-version: "8.2"
rector: "^2"
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none
tools: composer:v2
- run: composer install
- run: composer require rector/rector:${{ matrix.rector }} --dev
- run: composer test
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"ast"
],
"require": {
"rector/rector": "^1.0",
"rector/rector": "^1 || ^2",
"webflo/drupal-finder": "^1.2"
},
"license": "MIT",
Expand Down Expand Up @@ -76,9 +76,9 @@
"php": "^8.2",
"cweagans/composer-patches": "^1.7.2",
"friendsofphp/php-cs-fixer": "^3.58",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^1.12 || ^2.0",
"phpstan/phpstan-deprecation-rules": "^1.2 || ^2.0",
"phpunit/phpunit": "^10.0",
"symfony/yaml": "^5 || ^6 || ^7",
"symplify/vendor-patches": "^11.0"
Expand Down
8 changes: 7 additions & 1 deletion config/drupal-10/drupal-10.0-deprecations.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
use Rector\Symfony\Set\TwigSetList;

return static function (RectorConfig $rectorConfig): void {
if (defined('TwigSetList::TWIG_24')) {
$twigSet = TwigSetList::TWIG_24;
} else {
$twigSet = TwigSetList::TWIG_240;
}

$rectorConfig->sets([
PHPUnitSetList::PHPUNIT_90,
SymfonySetList::SYMFONY_50,
Expand All @@ -19,7 +25,7 @@
SymfonySetList::SYMFONY_60,
SymfonySetList::SYMFONY_61,
SymfonySetList::SYMFONY_62,
TwigSetList::TWIG_240,
$twigSet,
]);

$rectorConfig->rule(ShouldCallParentMethodsRector::class);
Expand Down
8 changes: 7 additions & 1 deletion config/drupal-9/drupal-9.0-deprecations.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@
return new AddCommentService();
});

if (defined('TwigSetList::TWIG_24')) {
$twigSet = TwigSetList::TWIG_24;
} else {
$twigSet = TwigSetList::TWIG_240;
}

$rectorConfig->sets([
PHPUnitSetList::PHPUNIT_80,
SymfonySetList::SYMFONY_40,
SymfonySetList::SYMFONY_41,
SymfonySetList::SYMFONY_42,
SymfonySetList::SYMFONY_43,
SymfonySetList::SYMFONY_44,
TwigSetList::TWIG_240,
$twigSet,
]);
$rectorConfig->rule(ProtectedStaticModulesPropertyRector::class);

Expand Down
159 changes: 159 additions & 0 deletions phpstan-1-baseline.neon
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions phpstan-1.neon
Original file line number Diff line number Diff line change
@@ -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
Loading