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

Add Rector to all packages #34

Merged
merged 3 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions .build/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
->withPhpSets(php82: true)
->withPreparedSets(deadCode: true, typeDeclarations: true, earlyReturn: true, strictBooleans: true)
->withImportNames(true, true, false, true);
2 changes: 2 additions & 0 deletions .github/workflows/lint_test_pull_requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
command: analyze:php
- name: PHPUnit
command: test:php
- name: Rector
command: 'rector --dry-run'
directory: ['extension-installer', 'fractor', 'fractor-xml', 'typo3-fractor']
exclude:
- directory: extension-installer
Expand Down
2 changes: 2 additions & 0 deletions extension-installer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"composer/composer": "^2.7",
"ergebnis/composer-normalize": "^2.42",
"phpstan/phpstan": "^1.10",
"rector/rector": "^1.0",
"symplify/easy-coding-standard": "^12.1"
},
"autoload": {
Expand All @@ -36,6 +37,7 @@
},
"scripts": {
"analyze:php": "phpstan analyze",
"rector": "rector",
"style:php:check": "ecs",
"style:php:fix": "ecs --fix"
}
Expand Down
8 changes: 8 additions & 0 deletions extension-installer/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

declare(strict_types=1);

return (include __DIR__ . '/../.build/rector.php')
->withPaths([
__DIR__ . '/src',
]);
2 changes: 2 additions & 0 deletions fractor-xml/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"ergebnis/composer-normalize": "^2.42",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.5",
"rector/rector": "^1.0",
"symplify/easy-coding-standard": "^12.1"
},
"repositories": {
Expand Down Expand Up @@ -49,6 +50,7 @@
},
"scripts": {
"analyze:php": "phpstan analyze",
"rector": "rector",
"style:php:check": "ecs",
"style:php:fix": "ecs --fix",
"test:php": "phpunit"
Expand Down
10 changes: 10 additions & 0 deletions fractor-xml/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

return (include __DIR__ . '/../.build/rector.php')
->withPaths([
__DIR__ . '/config',
__DIR__ . '/src',
__DIR__ . '/tests',
]);
4 changes: 2 additions & 2 deletions fractor-xml/src/DomDocumentIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
use a9f\FractorXml\Exception\ShouldNotHappenException;
use Webmozart\Assert\Assert;

final class DomDocumentIterator
final readonly class DomDocumentIterator
{
/** @var int */
public const REMOVE_NODE = 3;

/**
* @param list<DomNodeVisitor> $visitors
*/
public function __construct(private readonly iterable $visitors)
public function __construct(private iterable $visitors)
{
Assert::allIsInstanceOf($this->visitors, DomNodeVisitor::class);
}
Expand Down
2 changes: 2 additions & 0 deletions fractor/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^10.5",
"rector/rector": "^1.0",
"symplify/easy-coding-standard": "^12.1"
},
"autoload": {
Expand All @@ -49,6 +50,7 @@
},
"scripts": {
"analyze:php": "phpstan analyze",
"rector": "rector",
"style:php:check": "ecs",
"style:php:fix": "ecs --fix",
"test:php": "phpunit"
Expand Down
10 changes: 10 additions & 0 deletions fractor/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

return (include __DIR__ . '/../.build/rector.php')
->withPaths([
__DIR__ . '/config',
__DIR__ . '/src',
__DIR__ . '/tests',
]);
4 changes: 2 additions & 2 deletions fractor/src/Differ/Formatter/ColorConsoleDiffFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Nette\Utils\Strings;
use Symfony\Component\Console\Formatter\OutputFormatter;

final class ColorConsoleDiffFormatter
final readonly class ColorConsoleDiffFormatter
{
/**
* @var string
Expand All @@ -33,7 +33,7 @@ final class ColorConsoleDiffFormatter
*/
private const NEWLINES_REGEX = "#\n\r|\n#";

private readonly string $template;
private string $template;

public function __construct()
{
Expand Down
4 changes: 2 additions & 2 deletions fractor/src/Skipper/FileSystem/FilePathHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Symfony\Component\Filesystem\Filesystem;
use Webmozart\Assert\Assert;

final class FilePathHelper
final readonly class FilePathHelper
{
/**
* @see https://regex101.com/r/d4F5Fm/1
Expand All @@ -27,7 +27,7 @@ final class FilePathHelper
*/
private const SCHEME_UNDEFINED = 'undefined';

public function __construct(private readonly Filesystem $filesystem)
public function __construct(private Filesystem $filesystem)
{
}

Expand Down
2 changes: 2 additions & 0 deletions typo3-fractor/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^10.5",
"rector/rector": "^1.0",
"symplify/easy-coding-standard": "^12.1"
},
"repositories": {
Expand Down Expand Up @@ -48,6 +49,7 @@
},
"scripts": {
"analyze:php": "phpstan analyze",
"rector": "rector",
"style:php:check": "ecs",
"style:php:fix": "ecs --fix",
"test:php": "phpunit"
Expand Down
10 changes: 10 additions & 0 deletions typo3-fractor/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

return (include __DIR__ . '/../.build/rector.php')
->withPaths([
__DIR__ . '/config',
__DIR__ . '/src',
__DIR__ . '/tests',
]);