Skip to content

Commit

Permalink
Merge branch 'main' into use-this-t
Browse files Browse the repository at this point in the history
  • Loading branch information
agentrickard authored Mar 8, 2024
2 parents 1a74c21 + 358aebb commit 07f568c
Show file tree
Hide file tree
Showing 488 changed files with 10,236 additions and 8,345 deletions.
15 changes: 10 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at https://editorconfig.org

root = true

# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[composer.{json,lock}]
indent_size = 4
28 changes: 28 additions & 0 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: php-cs-fixer

# This test will run on every pull request, and on every push on main branch
on:
push:
branches:
- main
pull_request:

jobs:
php-cs-fixer:
name: Codestyle checks with php-cs-fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none # disable xdebug, pcov
tools: composer:v2
extensions: zip
# Uncomment to enable SSH access to Github Actions - https://github.com/marketplace/actions/debugging-with-tmate#getting-started
# - name: Debugging with tmate
# uses: mxschmitt/action-tmate@v2
# END: SHARED SETUP

- run: composer install
- run: composer check-style
47 changes: 0 additions & 47 deletions .github/workflows/drupal_rector_sandbox.yml

This file was deleted.

21 changes: 17 additions & 4 deletions .github/workflows/functional_test__rector_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
name: functional_test__rector_examples

# This test will run on every pull request, and on every commit on any branch
on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
schedule:
# Run tests every week (to check for rector changes)
- cron: '0 0 * * 0'

jobs:
run_functional_test:
name: Functional Test | PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal }}"
strategy:
fail-fast: false
matrix:
include:
- php-version: "7.4"
Expand All @@ -19,9 +27,12 @@ jobs:
- php-version: "8.0"
drupal: "^9.2"
fixture: "d9"
- php-version: "8.1"
drupal: "^10.0"
fixture: "d10"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
Expand All @@ -46,11 +57,13 @@ jobs:
cd ~/drupal
mkdir -p web/modules/custom
cp -R vendor/palantirnet/drupal-rector/fixtures/${{ matrix.fixture }}/rector_examples web/modules/custom
# dry-run is expected to return exit code 1 if there are changes, which we are expecting to happen, here.
# dry-run is expected to return exit code 2 if there are changes, which we are expecting to happen, here.
# an error code of 1 represents other errors.
# @see \Rector\Core\Console\ExitCode::CHANGED_CODE
- name: Run rector against Drupal (dry-run)
run: |
cd ~/drupal
vendor/bin/rector process web/modules/custom/rector_examples --dry-run --debug || if (($? == 1)); then true; else false; fi
vendor/bin/rector process web/modules/custom/rector_examples --dry-run --debug || if (($? == 2)); then true; else false; fi
- name: Run rector against Drupal
run: |
cd ~/drupal
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
name: phpstan

# This test will run on every pull request, and on every commit on any branch
on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
schedule:
# Run tests every week (to check for rector changes)
- cron: '0 0 * * 0'

jobs:
run_static_analysis_phpstan_analyze:
name: Static analysis with PHPStan
# START: SHARED SETUP
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
Expand All @@ -21,7 +28,5 @@ jobs:
# uses: mxschmitt/action-tmate@v2
# END: SHARED SETUP

# We cannot have rector/rector in require and rector/rector-src in require-dev, they conflict.
- run: composer remove rector/rector --no-update
- run: composer install
- run: php vendor/bin/phpstan
- run: composer phpstan
15 changes: 10 additions & 5 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
name: phpunit

# This test will run on every pull request, and on every commit on any branch
on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
schedule:
# Run tests every week (to check for rector changes)
- cron: '0 0 * * 0'

jobs:
tests:
Expand All @@ -12,13 +19,11 @@ jobs:
php-version:
- "8.1"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none
tools: composer:v2
# We cannot have rector/rector in require and rector/rector-src in require-dev, they conflict.
- run: composer remove rector/rector --no-update
- run: composer install
- run: vendor/bin/phpunit
- run: composer test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Ignore all hidden files exept these.
.*
!/.php-cs-fixer.dist.php
!/.github
!/.gitignore
!/.gitattributes
Expand Down
25 changes: 25 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in([
__DIR__.'/src',
__DIR__.'/tests',
__DIR__.'/config/drupal-*',
])
;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'linebreak_after_opening_tag' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'yoda_style' => false,
'no_superfluous_phpdoc_tags' => false,
'declare_strict_types' => true,
])
->setFinder($finder)
;
4 changes: 1 addition & 3 deletions README-automated-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ The Drupal Rector project has PHPUnit tests, extending the testing suite functio
the project to have confidence in the written Rector rules. To run the unit tests, there are different system requirements
than if you ran Drupal Rector against your Drupal site.

The developer dependencies require `rector/rector-src` which requires PHP 8.

To run the PHPUnit tests:

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

### Writing a PHPUnit test

For now, please see the example in `tests/src/Rector/Deprecation/DatetimeStorageTimezoneRector`
For now, please see the example in `tests/src/Rector/Deprecation/DatetimeStorageTimezoneRector`.

## Installation test

Expand Down
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ Automate fixing deprecated Drupal code.

## Status

![Functional test: Rector examples](https://github.com/palantirnet/drupal-rector/workflows/functional_test__rector_examples/badge.svg)

## Latest release

[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.
[![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)

### Release notes

* 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`
* 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`.

* 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.
* 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`

*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.*

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

https://www.palantir.net/rector

List of all rules with examples:

[Rule overview in docs/rules_overview.md](docs%2Frules_overview.md)


## Scope and limitations

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.
Expand Down Expand Up @@ -123,7 +124,7 @@ Rector itself has conflicts with older versions of PhpStan.

If you are getting errors like

`[ERROR] Class "DrupalRector\Rector\Deprecation\EntityManagerRector" was not found while loading`
`[ERROR] Class "DrupalRector\Drupal8\Rector\Deprecation\EntityManagerRector" was not found while loading`

You may need to rebuild your autoload file.

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

### Development environment

We recommend using our `drupal-rector-sandbox` development environment [https://github.com/palantirnet/drupal-rector-sandbox](https://github.com/palantirnet/drupal-rector-sandbox)

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)
See the instructions in [README](https://github.com/palantirnet/drupal-rector-sandbox/blob/master/README.md#developing-with-drupal-rector)

### Adding a Rector rule

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

## Pinning dev dependencies

If there are conflicts with Rector, the package version can be conflicted with `conflict` on `rector/rector`.

For development, the `require-dev` is on `rector/rector-src` which is `dev-main` and that includes the `dev-main` of all
its packages.

To properly pin a development release of `rector-src`:
If there are conflicts with Rector, the package version can be conflicted with `conflict` on `rector/rector` and `phpstan/phpstan`.

* Set `rector/rector-src` to `dev-main#COMMIT` where `COMMIT` is the tag commit in `rector-src`
* 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)
* Use the references to pin `require-dev` dependencies.
* Use the reference to pin the `phpstan/phpstan` dependency.

## Credits

Expand Down
24 changes: 18 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ast"
],
"require": {
"rector/rector": "~0.13.8",
"rector/rector": "^1.0",
"webflo/drupal-finder": "^1.2"
},
"license": "MIT",
Expand All @@ -30,6 +30,10 @@
{
"name": "Matt Glaman",
"email": "[email protected]"
},
{
"name": "Björn Brala",
"email": "[email protected]"
}
],
"autoload": {
Expand Down Expand Up @@ -66,14 +70,22 @@
"enable-patching": true
},
"require-dev": {
"php": "^8.0",
"php": "^8.1",
"cweagans/composer-patches": "^1.7.2",
"friendsofphp/php-cs-fixer": "^3.38",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpunit/phpunit": "^9.5",
"rector/rector-src": "dev-main",
"symplify/vendor-patches": "^11.0",
"symfony/yaml": "^5 || ^6"
"phpunit/phpunit": "^10.0",
"symfony/yaml": "^5 || ^6",
"symplify/rule-doc-generator": "^12.0",
"symplify/vendor-patches": "^11.0"
},
"scripts": {
"docs": "vendor/bin/rule-doc-generator generate src/ --categorize=3",
"test": "vendor/bin/phpunit",
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2G",
"check-style": "vendor/bin/php-cs-fixer check",
"fix-style": "vendor/bin/php-cs-fixer fix"
}
}
Loading

0 comments on commit 07f568c

Please sign in to comment.