Skip to content

Commit 07f568c

Browse files
authored
Merge branch 'main' into use-this-t
2 parents 1a74c21 + 358aebb commit 07f568c

File tree

488 files changed

+10236
-8345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

488 files changed

+10236
-8345
lines changed

.editorconfig

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at https://editorconfig.org
3+
14
root = true
25

3-
# All files.
46
[*]
5-
end_of_line = LF
6-
indent_style = space
7-
indent_size = 4
87
charset = utf-8
9-
trim_trailing_whitespace = true
8+
indent_size = 4
9+
indent_style = space
10+
end_of_line = lf
1011
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
1116

1217
[composer.{json,lock}]
1318
indent_size = 4

.github/workflows/codestyle.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: php-cs-fixer
2+
3+
# This test will run on every pull request, and on every push on main branch
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
10+
jobs:
11+
php-cs-fixer:
12+
name: Codestyle checks with php-cs-fixer
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: 8.1
19+
coverage: none # disable xdebug, pcov
20+
tools: composer:v2
21+
extensions: zip
22+
# Uncomment to enable SSH access to Github Actions - https://github.com/marketplace/actions/debugging-with-tmate#getting-started
23+
# - name: Debugging with tmate
24+
# uses: mxschmitt/action-tmate@v2
25+
# END: SHARED SETUP
26+
27+
- run: composer install
28+
- run: composer check-style

.github/workflows/drupal_rector_sandbox.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/functional_test__rector_examples.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
name: functional_test__rector_examples
33

44
# This test will run on every pull request, and on every commit on any branch
5-
on: [push, pull_request]
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
schedule:
11+
# Run tests every week (to check for rector changes)
12+
- cron: '0 0 * * 0'
613

714
jobs:
815
run_functional_test:
916
name: Functional Test | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}"
1017
strategy:
18+
fail-fast: false
1119
matrix:
1220
include:
1321
- php-version: "7.4"
@@ -19,9 +27,12 @@ jobs:
1927
- php-version: "8.0"
2028
drupal: "^9.2"
2129
fixture: "d9"
30+
- php-version: "8.1"
31+
drupal: "^10.0"
32+
fixture: "d10"
2233
runs-on: ubuntu-latest
2334
steps:
24-
- uses: actions/checkout@v2
35+
- uses: actions/checkout@v3
2536
- uses: shivammathur/setup-php@v2
2637
with:
2738
php-version: "${{ matrix.php-version }}"
@@ -46,11 +57,13 @@ jobs:
4657
cd ~/drupal
4758
mkdir -p web/modules/custom
4859
cp -R vendor/palantirnet/drupal-rector/fixtures/${{ matrix.fixture }}/rector_examples web/modules/custom
49-
# dry-run is expected to return exit code 1 if there are changes, which we are expecting to happen, here.
60+
# dry-run is expected to return exit code 2 if there are changes, which we are expecting to happen, here.
61+
# an error code of 1 represents other errors.
62+
# @see \Rector\Core\Console\ExitCode::CHANGED_CODE
5063
- name: Run rector against Drupal (dry-run)
5164
run: |
5265
cd ~/drupal
53-
vendor/bin/rector process web/modules/custom/rector_examples --dry-run --debug || if (($? == 1)); then true; else false; fi
66+
vendor/bin/rector process web/modules/custom/rector_examples --dry-run --debug || if (($? == 2)); then true; else false; fi
5467
- name: Run rector against Drupal
5568
run: |
5669
cd ~/drupal

.github/workflows/phpstan.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
name: phpstan
22

33
# This test will run on every pull request, and on every commit on any branch
4-
on: [push, pull_request]
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
schedule:
10+
# Run tests every week (to check for rector changes)
11+
- cron: '0 0 * * 0'
512

613
jobs:
714
run_static_analysis_phpstan_analyze:
815
name: Static analysis with PHPStan
916
# START: SHARED SETUP
1017
runs-on: ubuntu-latest
1118
steps:
12-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
1320
- uses: shivammathur/setup-php@v2
1421
with:
1522
php-version: 8.1
@@ -21,7 +28,5 @@ jobs:
2128
# uses: mxschmitt/action-tmate@v2
2229
# END: SHARED SETUP
2330

24-
# We cannot have rector/rector in require and rector/rector-src in require-dev, they conflict.
25-
- run: composer remove rector/rector --no-update
2631
- run: composer install
27-
- run: php vendor/bin/phpstan
32+
- run: composer phpstan

.github/workflows/phpunit.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
name: phpunit
22

33
# This test will run on every pull request, and on every commit on any branch
4-
on: [push, pull_request]
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
schedule:
10+
# Run tests every week (to check for rector changes)
11+
- cron: '0 0 * * 0'
512

613
jobs:
714
tests:
@@ -12,13 +19,11 @@ jobs:
1219
php-version:
1320
- "8.1"
1421
steps:
15-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
1623
- uses: shivammathur/setup-php@v2
1724
with:
1825
php-version: ${{ matrix.php-version }}
1926
coverage: none
2027
tools: composer:v2
21-
# We cannot have rector/rector in require and rector/rector-src in require-dev, they conflict.
22-
- run: composer remove rector/rector --no-update
2328
- run: composer install
24-
- run: vendor/bin/phpunit
29+
- run: composer test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Ignore all hidden files exept these.
22
.*
3+
!/.php-cs-fixer.dist.php
34
!/.github
45
!/.gitignore
56
!/.gitattributes

.php-cs-fixer.dist.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in([
5+
__DIR__.'/src',
6+
__DIR__.'/tests',
7+
__DIR__.'/config/drupal-*',
8+
])
9+
;
10+
11+
return (new PhpCsFixer\Config())
12+
->setRiskyAllowed(true)
13+
->setRules([
14+
'@Symfony' => true,
15+
'array_syntax' => ['syntax' => 'short'],
16+
'linebreak_after_opening_tag' => true,
17+
'ordered_imports' => true,
18+
'phpdoc_add_missing_param_annotation' => true,
19+
'phpdoc_order' => true,
20+
'yoda_style' => false,
21+
'no_superfluous_phpdoc_tags' => false,
22+
'declare_strict_types' => true,
23+
])
24+
->setFinder($finder)
25+
;

README-automated-testing.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ The Drupal Rector project has PHPUnit tests, extending the testing suite functio
66
the project to have confidence in the written Rector rules. To run the unit tests, there are different system requirements
77
than if you ran Drupal Rector against your Drupal site.
88

9-
The developer dependencies require `rector/rector-src` which requires PHP 8.
10-
119
To run the PHPUnit tests:
1210

1311
* Clone your fork of the repository
@@ -18,7 +16,7 @@ See the `.github/workflows/phpunit.yml` workflow for an example.
1816

1917
### Writing a PHPUnit test
2018

21-
For now, please see the example in `tests/src/Rector/Deprecation/DatetimeStorageTimezoneRector`
19+
For now, please see the example in `tests/src/Rector/Deprecation/DatetimeStorageTimezoneRector`.
2220

2321
## Installation test
2422

README.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ Automate fixing deprecated Drupal code.
44

55
## Status
66

7-
![Functional test: Rector examples](https://github.com/palantirnet/drupal-rector/workflows/functional_test__rector_examples/badge.svg)
8-
9-
## Latest release
10-
11-
[Version 0.13.1 for Drupal 8.x and 9.x deprecations](https://github.com/palantirnet/drupal-rector/tree/0.13.1). Note that Drupal 9 deprecation testing recommends PHP 8.
7+
[![Packagist Version](https://img.shields.io/packagist/v/palantirnet/drupal-rector)](https://packagist.org/packages/palantirnet/drupal-rector) ![Functional test: Rector examples](https://img.shields.io/github/actions/workflow/status/palantirnet/drupal-rector/functional_test__rector_examples.yml?logo=github&label=Functional%20tests) ![Unit tests](https://img.shields.io/github/actions/workflow/status/palantirnet/drupal-rector/phpunit.yml?logo=github&label=Unit%20tests) ![PHPStan](https://img.shields.io/github/actions/workflow/status/palantirnet/drupal-rector/phpstan.yml?logo=github&label=PHPStan)
128

139
### Release notes
1410

15-
* The 0.13.0 and higher releases of drupal-rector will include Rector 0.13.8+. The upgrade path should be as simple as re-copying the configuration file. `cp vendor/palantirnet/drupal-rector/rector.php`
11+
* The 0.18.0 and higher releases of drupal-rector will include Rector 0.18+. The upgrade path should be as simple as re-copying the configuration file. `cp vendor/palantirnet/drupal-rector/rector.php`.
1612

17-
* The 0.12.4 is a stable release pinned to Rector 0.12.21. Developers should be aware that Rector 0.12.22 introduces breaking changes to how we handle Drupal configuration.
13+
* The 0.13.0 and higher releases of drupal-rector will include Rector 0.13.8+. The upgrade path should be as simple as re-copying the configuration file. `cp vendor/palantirnet/drupal-rector/rector.php`
1814

1915
*Note that GitHub does not let us have different default homepage and merge branches. If you checked out the project using packagist/composer, read the docs for your version.*
2016

@@ -30,6 +26,11 @@ Development guides, individual deprecation overviews, and other resources can be
3026

3127
https://www.palantir.net/rector
3228

29+
List of all rules with examples:
30+
31+
[Rule overview in docs/rules_overview.md](docs%2Frules_overview.md)
32+
33+
3334
## Scope and limitations
3435

3536
The development of this tool is prioritized by the perceived impact of the deprecations and updates. There are many deprecations that often involve several components and for each of these there are several ways to address the deprecation.
@@ -123,7 +124,7 @@ Rector itself has conflicts with older versions of PhpStan.
123124

124125
If you are getting errors like
125126

126-
`[ERROR] Class "DrupalRector\Rector\Deprecation\EntityManagerRector" was not found while loading`
127+
`[ERROR] Class "DrupalRector\Drupal8\Rector\Deprecation\EntityManagerRector" was not found while loading`
127128

128129
You may need to rebuild your autoload file.
129130

@@ -170,9 +171,7 @@ Our goal is to make contributing to this project easy for people. While we've ma
170171

171172
### Development environment
172173

173-
We recommend using our `drupal-rector-sandbox` development environment [https://github.com/palantirnet/drupal-rector-sandbox](https://github.com/palantirnet/drupal-rector-sandbox)
174-
175-
Alternatively, you can use your existing Drupal project and follow the instructions in [README](https://github.com/palantirnet/drupal-rector-sandbox/blob/master/README.md#developing-with-drupal-rector)
174+
See the instructions in [README](https://github.com/palantirnet/drupal-rector-sandbox/blob/master/README.md#developing-with-drupal-rector)
176175

177176
### Adding a Rector rule
178177

@@ -240,16 +239,10 @@ The index file is used in part to provide automated updates to https://dev.acqui
240239

241240
## Pinning dev dependencies
242241

243-
If there are conflicts with Rector, the package version can be conflicted with `conflict` on `rector/rector`.
244-
245-
For development, the `require-dev` is on `rector/rector-src` which is `dev-main` and that includes the `dev-main` of all
246-
its packages.
247-
248-
To properly pin a development release of `rector-src`:
242+
If there are conflicts with Rector, the package version can be conflicted with `conflict` on `rector/rector` and `phpstan/phpstan`.
249243

250-
* Set `rector/rector-src` to `dev-main#COMMIT` where `COMMIT` is the tag commit in `rector-src`
251244
* View the tree for the commit on GitHub and it's `composer/installed.json` file (example https://github.com/rectorphp/rector/blob/0.12.18/vendor/composer/installed.json)
252-
* Use the references to pin `require-dev` dependencies.
245+
* Use the reference to pin the `phpstan/phpstan` dependency.
253246

254247
## Credits
255248

composer.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"ast"
1111
],
1212
"require": {
13-
"rector/rector": "~0.13.8",
13+
"rector/rector": "^1.0",
1414
"webflo/drupal-finder": "^1.2"
1515
},
1616
"license": "MIT",
@@ -30,6 +30,10 @@
3030
{
3131
"name": "Matt Glaman",
3232
"email": "nmd.matt@gmail.com"
33+
},
34+
{
35+
"name": "Björn Brala",
36+
"email": "drupal@bjorn.dev"
3337
}
3438
],
3539
"autoload": {
@@ -66,14 +70,22 @@
6670
"enable-patching": true
6771
},
6872
"require-dev": {
69-
"php": "^8.0",
73+
"php": "^8.1",
7074
"cweagans/composer-patches": "^1.7.2",
75+
"friendsofphp/php-cs-fixer": "^3.38",
7176
"phpstan/extension-installer": "^1.1",
7277
"phpstan/phpstan": "^1.0",
7378
"phpstan/phpstan-deprecation-rules": "^1.0",
74-
"phpunit/phpunit": "^9.5",
75-
"rector/rector-src": "dev-main",
76-
"symplify/vendor-patches": "^11.0",
77-
"symfony/yaml": "^5 || ^6"
79+
"phpunit/phpunit": "^10.0",
80+
"symfony/yaml": "^5 || ^6",
81+
"symplify/rule-doc-generator": "^12.0",
82+
"symplify/vendor-patches": "^11.0"
83+
},
84+
"scripts": {
85+
"docs": "vendor/bin/rule-doc-generator generate src/ --categorize=3",
86+
"test": "vendor/bin/phpunit",
87+
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2G",
88+
"check-style": "vendor/bin/php-cs-fixer check",
89+
"fix-style": "vendor/bin/php-cs-fixer fix"
7890
}
7991
}

0 commit comments

Comments
 (0)