Skip to content

Commit d77662e

Browse files
authored
[QA] Add Rector for QA (#5)
1 parent 9669dff commit d77662e

7 files changed

Lines changed: 138 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,8 @@ jobs:
4040
vendor/bin/readme-examples-sync
4141
git diff --exit-code README.md || (echo "README.md is out of sync with example files. Run 'vendor/bin/readme-examples-sync' and commit the changes." && exit 1)
4242
43+
- name: Run Rector
44+
run: vendor/bin/rector --dry-run
45+
4346
- name: Run PHP CS Fixer
4447
run: vendor/bin/php-cs-fixer check --diff

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"require-dev": {
1616
"captainhook/captainhook-phar": "^5.28",
1717
"ergebnis/composer-normalize": "^2.50",
18+
"rector/rector": "^2.3",
1819
"ruudk/readme-examples-sync-hook": "^2.0"
1920
},
2021
"autoload": {

composer.lock

Lines changed: 114 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lefthook.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ pre-commit:
2323
glob: "*.php"
2424
run: vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php -- {staged_files}
2525
stage_fixed: true
26+
27+
rector:
28+
glob: "*.php"
29+
run: vendor/bin/rector process {staged_files}
30+
stage_fixed: true

rector.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__ . '/src',
10+
])
11+
->withPhpSets();

src/Fixer/PhpdocAboveAttributeFixer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Ticketswap\PhpCsFixerConfig\Fixer;
66

7+
use Override;
78
use PhpCsFixer\AbstractFixer;
89
use PhpCsFixer\FixerDefinition\FixerDefinition;
910
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
@@ -51,6 +52,7 @@ public function isCandidate(Tokens $tokens) : bool
5152
*
5253
* Must run before NoBlankLinesAfterPhpdocFixer.
5354
*/
55+
#[Override]
5456
public function getPriority() : int
5557
{
5658
return 1;

src/RuleSet.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66

77
final readonly class RuleSet
88
{
9-
public Fixers $customFixers;
109
public Rules $rules;
1110

1211
public function __construct(
13-
Fixers $customFixers,
12+
public Fixers $customFixers,
1413
Rules $rules,
1514
) {
16-
$this->customFixers = $customFixers;
17-
1815
$enable = [];
19-
foreach ($customFixers->value as $customFixer) {
16+
foreach ($this->customFixers->value as $customFixer) {
2017
$enable[$customFixer->getName()] = true;
2118
}
2219

0 commit comments

Comments
 (0)