From f7c63e6a41d18e2e4daf1dc7f5513c9941970802 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 11 Nov 2024 17:15:15 +0300 Subject: [PATCH] Apply Rector suggestions + Improve Rector CI --- .github/workflows/rector.yml | 3 ++- composer.json | 4 ++-- rector.php | 2 +- src/Dumper.php | 2 +- src/FlattenException.php | 11 +++++++++++ tests/Support/Stub/BrokenProxyImplementation.php | 2 +- tests/Unit/FlattenExceptionTest.php | 6 +++--- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 35411d0ae..457772afa 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -1,5 +1,5 @@ on: - pull_request: + pull_request_target: paths-ignore: - 'docs/**' - 'README.md' @@ -17,6 +17,7 @@ jobs: secrets: token: ${{ secrets.YIISOFT_GITHUB_TOKEN }} with: + repository: ${{ github.event.pull_request.head.repo.full_name }} os: >- ['ubuntu-latest'] php: >- diff --git a/composer.json b/composer.json index 8537a5c3d..a6d2a54b4 100644 --- a/composer.json +++ b/composer.json @@ -55,10 +55,10 @@ "maglnet/composer-require-checker": "^4.2", "nyholm/psr7": "^1.3", "phpunit/phpunit": "^10.5", - "rector/rector": "^1.0.0", + "rector/rector": "^1.2", "roave/infection-static-analysis-plugin": "^1.16", "spatie/phpunit-watcher": "^1.23", - "vimeo/psalm": "^5.25", + "vimeo/psalm": "^5.26", "yiisoft/error-handler": "^3.0", "yiisoft/event-dispatcher": "^1.0", "yiisoft/log": "^2.0", diff --git a/rector.php b/rector.php index 5548304b4..582cc4ad5 100644 --- a/rector.php +++ b/rector.php @@ -17,7 +17,7 @@ // define sets of rules $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_80, + LevelSetList::UP_TO_PHP_81, ]); $rectorConfig->skip([ diff --git a/src/Dumper.php b/src/Dumper.php index 0fdaee87f..e76b1aca3 100644 --- a/src/Dumper.php +++ b/src/Dumper.php @@ -14,7 +14,7 @@ final class Dumper private array $objects = []; private static ?ClosureExporter $closureExporter = null; - private array $excludedClasses; + private readonly array $excludedClasses; private function __construct( private readonly mixed $variable, diff --git a/src/FlattenException.php b/src/FlattenException.php index 3e63a5331..3e6ab1c65 100644 --- a/src/FlattenException.php +++ b/src/FlattenException.php @@ -163,6 +163,17 @@ public function getTrace(): array /** * @param array $trace the Exception stack trace as an array. + * + * @psalm-param list< + * array{ + * args?: array, + * class?: class-string, + * file?: string, + * function?: string, + * line?: int, + * type?: string + * } + * > $trace */ private function setTrace(array $trace): void { diff --git a/tests/Support/Stub/BrokenProxyImplementation.php b/tests/Support/Stub/BrokenProxyImplementation.php index e1490f462..526bebd2d 100644 --- a/tests/Support/Stub/BrokenProxyImplementation.php +++ b/tests/Support/Stub/BrokenProxyImplementation.php @@ -8,7 +8,7 @@ class BrokenProxyImplementation implements Interface1 { - public function __construct(private Interface1 $decorated) + public function __construct(private readonly Interface1 $decorated) { throw new Exception('Broken proxy'); } diff --git a/tests/Unit/FlattenExceptionTest.php b/tests/Unit/FlattenExceptionTest.php index 63329ec2c..aa852442f 100644 --- a/tests/Unit/FlattenExceptionTest.php +++ b/tests/Unit/FlattenExceptionTest.php @@ -78,7 +78,7 @@ public function testClass(): void $this->assertEquals('Exception', (new FlattenException(new Exception()))->getClass()); } - public function testArguments(): void + public function testArguments(): never { $this->markTestSkipped('Should be fixed'); @@ -151,7 +151,7 @@ public function testClosureSerialize(): void $this->assertStringContainsString(Closure::class, serialize($flattened)); } - public function testRecursionInArguments(): void + public function testRecursionInArguments(): never { $this->markTestSkipped('Should be fixed'); @@ -164,7 +164,7 @@ public function testRecursionInArguments(): void $this->assertStringContainsString('*DEEP NESTED ARRAY*', serialize($trace)); } - public function testTooBigArray(): void + public function testTooBigArray(): never { $this->markTestSkipped('Should be fixed');