Skip to content

Commit 6d3a501

Browse files
authored
Drop Drupal 8 support (#311)
* fix: codestyle fix for EntityManagerRector.php * Fix DrupalFinder deprecation * Add SetListInterface deprecation to phpstan-baseline.neon * Generate missing rule doc * Since we need to support old drupal versions still we cannot get rid of drupalfinders old pattern * Try with differernt whitespace * Another try with finder for older drupal versions * feat: drop d8 support and testing on php 7.4 * feat: Try if we can test old fixtures/rules on next Drupal version * feat: add fixture to job name * feat: remove old fixtures since that will not work. * feat: remove Drupal 8 rules from default set * feat: reenable d8 rules. * fix: remove fixture from job titles
1 parent 50c742a commit 6d3a501

File tree

7 files changed

+100
-22
lines changed

7 files changed

+100
-22
lines changed

.github/workflows/functional_test__rector_examples.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,18 @@ on:
1313

1414
jobs:
1515
run_functional_test:
16-
name: Functional Test | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}"
16+
name: Functional | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}"
1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
include:
21-
- php-version: "7.4"
22-
drupal: "^8.9"
23-
fixture: "d8"
24-
- php-version: "7.4"
25-
drupal: "^9.2"
26-
fixture: "d9"
2721
- php-version: "8.0"
2822
drupal: "^9.2"
2923
fixture: "d9"
3024
- php-version: "8.1"
3125
drupal: "^10.0"
3226
fixture: "d10"
33-
- php-version: "8.2"
27+
- php-version: "8.3"
3428
drupal: "^10.0"
3529
fixture: "d10"
3630
runs-on: ubuntu-latest

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"keywords": [
66
"code style",
77
"rector",
8-
"drupal 8",
9-
"drupal 9",
8+
"drupal",
109
"ast"
1110
],
1211
"require": {

config/drupal-phpunit-bootstrap-file.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
* This fixes Drupal testing namespace autoloading and PHPUnit compatibility.
77
*/
88

9-
use DrupalFinder\DrupalFinder;
109
use Rector\Core\Autoloading\BootstrapFilesIncluder;
1110
use Rector\Core\Exception\ShouldNotHappenException;
1211

13-
$drupalFinder = new DrupalFinder();
14-
$drupalFinder->locateRoot(__DIR__);
12+
13+
if (class_exists('DrupalFinder\DrupalFinderComposerRuntime')) {
14+
$drupalFinder = new DrupalFinder\DrupalFinderComposerRuntime();
15+
} else {
16+
$drupalFinder = new DrupalFinder\DrupalFinder();
17+
$drupalFinder->locateRoot(__DIR__);
18+
}
19+
1520
$drupalRoot = $drupalFinder->getDrupalRoot();
1621
$drupalVendorRoot = $drupalFinder->getVendorDir();
1722

docs/rules_overview.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# 54 Rules Overview
1+
# 55 Rules Overview
22

33
<br>
44

55
## Categories
66

7-
- [Drupal10](#drupal10) (3)
7+
- [Drupal10](#drupal10) (4)
88

99
- [Drupal8](#drupal8) (18)
1010

@@ -72,6 +72,21 @@ Fixes deprecated `system_time_zones()` calls
7272

7373
<br>
7474

75+
### VersionedFunctionToServiceRector
76+
77+
Fixes deprecated function to service calls, used in Drupal 8 and 9 deprecations
78+
79+
:wrench: **configure it!**
80+
81+
- class: [`DrupalRector\Drupal10\Rector\Deprecation\VersionedFunctionToServiceRector`](../src/Drupal10/Rector/Deprecation/VersionedFunctionToServiceRector.php)
82+
83+
```diff
84+
-_drupal_flush_css_js();
85+
+\Drupal::service('asset.query_string')->reset();
86+
```
87+
88+
<br>
89+
7590
### WatchdogExceptionRector
7691

7792
Fixes deprecated watchdog_exception('update', `$exception)` calls

phpstan-baseline.neon

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
parameters:
22
ignoreErrors:
3+
-
4+
message: """
5+
#^Call to deprecated method locateRoot\\(\\) of class DrupalFinder\\\\DrupalFinder\\:
6+
Will be removed in v2\\. Future usage should instantiate
7+
a new DrupalFinder object by passing the starting path to its
8+
constructor\\.$#
9+
"""
10+
count: 1
11+
path: config/drupal-phpunit-bootstrap-file.php
12+
313
-
414
message: "#^Function drupal_phpunit_contrib_extension_directory_roots\\(\\) return type has no value type specified in iterable type array\\.$#"
515
count: 1
@@ -35,6 +45,34 @@ parameters:
3545
count: 1
3646
path: config/drupal-phpunit-bootstrap-file.php
3747

48+
-
49+
message: """
50+
#^Instantiation of deprecated class DrupalFinder\\\\DrupalFinder\\:
51+
in drupal\\-finder\\:1\\.3\\.0 and is removed from drupal\\-finder\\:2\\.0\\.0\\.
52+
Use \\\\DrupalFinder\\\\DrupalFinderComposerRuntime instead\\.$#
53+
"""
54+
count: 1
55+
path: config/drupal-phpunit-bootstrap-file.php
56+
57+
-
58+
message: """
59+
#^Call to deprecated method locateRoot\\(\\) of class DrupalFinder\\\\DrupalFinder\\:
60+
Will be removed in v2\\. Future usage should instantiate
61+
a new DrupalFinder object by passing the starting path to its
62+
constructor\\.$#
63+
"""
64+
count: 1
65+
path: rector.php
66+
67+
-
68+
message: """
69+
#^Instantiation of deprecated class DrupalFinder\\\\DrupalFinder\\:
70+
in drupal\\-finder\\:1\\.3\\.0 and is removed from drupal\\-finder\\:2\\.0\\.0\\.
71+
Use \\\\DrupalFinder\\\\DrupalFinderComposerRuntime instead\\.$#
72+
"""
73+
count: 1
74+
path: rector.php
75+
3876
-
3977
message: "#^Access to an undefined property PhpParser\\\\Node\\\\Expr\\:\\:\\$value\\.$#"
4078
count: 2
@@ -117,3 +155,27 @@ parameters:
117155
"""
118156
count: 1
119157
path: src/Drupal9/Rector/Deprecation/PassRector.php
158+
159+
-
160+
message: """
161+
#^Class DrupalRector\\\\Set\\\\Drupal10SetList implements deprecated interface Rector\\\\Set\\\\Contract\\\\SetListInterface\\:
162+
This interface needs a reflection to load and uses constant links\\. Now we changed to services provider architecture that can be used and registerd easily\\. Use$#
163+
"""
164+
count: 1
165+
path: src/Set/Drupal10SetList.php
166+
167+
-
168+
message: """
169+
#^Class DrupalRector\\\\Set\\\\Drupal8SetList implements deprecated interface Rector\\\\Set\\\\Contract\\\\SetListInterface\\:
170+
This interface needs a reflection to load and uses constant links\\. Now we changed to services provider architecture that can be used and registerd easily\\. Use$#
171+
"""
172+
count: 1
173+
path: src/Set/Drupal8SetList.php
174+
175+
-
176+
message: """
177+
#^Class DrupalRector\\\\Set\\\\Drupal9SetList implements deprecated interface Rector\\\\Set\\\\Contract\\\\SetListInterface\\:
178+
This interface needs a reflection to load and uses constant links\\. Now we changed to services provider architecture that can be used and registerd easily\\. Use$#
179+
"""
180+
count: 1
181+
path: src/Set/Drupal9SetList.php

rector.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
declare(strict_types=1);
44

5-
use DrupalFinder\DrupalFinder;
65
use DrupalRector\Set\Drupal10SetList;
76
use DrupalRector\Set\Drupal8SetList;
87
use DrupalRector\Set\Drupal9SetList;
@@ -12,14 +11,20 @@
1211
// Adjust the set lists to be more granular to your Drupal requirements.
1312
// @todo find out how to only load the relevant rector rules.
1413
// Should we try and load \Drupal::VERSION and check?
14+
// new possible option with ComposerTriggeredSet
15+
// https://github.com/rectorphp/rector-src/blob/b5a5739b7d7dde621053adff113449860ed5331f/src/Set/ValueObject/ComposerTriggeredSet.php
1516
$rectorConfig->sets([
1617
Drupal8SetList::DRUPAL_8,
1718
Drupal9SetList::DRUPAL_9,
1819
Drupal10SetList::DRUPAL_10,
1920
]);
2021

21-
$drupalFinder = new DrupalFinder();
22-
$drupalFinder->locateRoot(__DIR__);
22+
if (class_exists('DrupalFinder\DrupalFinderComposerRuntime')) {
23+
$drupalFinder = new DrupalFinder\DrupalFinderComposerRuntime();
24+
} else {
25+
$drupalFinder = new DrupalFinder\DrupalFinder();
26+
$drupalFinder->locateRoot(__DIR__);
27+
}
2328
$drupalRoot = $drupalFinder->getDrupalRoot();
2429
$rectorConfig->autoloadPaths([
2530
$drupalRoot . '/core',

src/Drupal8/Rector/Deprecation/EntityManagerRector.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ final class EntityManagerRector extends AbstractRector
4545
*/
4646
private AddCommentService $commentService;
4747

48-
public function __construct(
49-
ParentClassScopeResolver $parentClassScopeResolver,
50-
AddCommentService $commentService
51-
) {
48+
public function __construct(ParentClassScopeResolver $parentClassScopeResolver, AddCommentService $commentService)
49+
{
5250
$this->parentClassScopeResolver = $parentClassScopeResolver;
5351
$this->commentService = $commentService;
5452
}

0 commit comments

Comments
 (0)