From 0ad666238bd2c76fa01e44ba8883112452339099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Sun, 8 Jun 2025 23:48:04 +0200 Subject: [PATCH 1/2] Dev cleaup --- .dev-tools/composer.json | 2 +- .dev-tools/infection.json | 1 + .dev-tools/src/InfectionConfigBuilder.php | 1 + .dev-tools/src/Readme/ReadmeCommand.php | 2 +- .php-cs-fixer.php | 1 + tests/Fixer/AbstractFixerTestCase.php | 11 ++++++++--- tests/Fixer/CommentedOutFunctionFixerTest.php | 4 ++-- tests/Fixer/DataProviderNameFixerTest.php | 4 ++-- tests/Fixer/DataProviderStaticFixerTest.php | 4 ++-- tests/Fixer/NoDuplicatedArrayKeyFixerTest.php | 4 ++-- tests/Fixer/NoSuperfluousConcatenationFixerTest.php | 8 ++++---- tests/Fixer/PhpdocOnlyAllowedAnnotationsFixerTest.php | 4 ++-- tests/Fixer/PromotedConstructorPropertyFixerTest.php | 4 ++-- tests/Fixer/SingleSpaceAfterStatementFixerTest.php | 4 ++-- 14 files changed, 31 insertions(+), 23 deletions(-) diff --git a/.dev-tools/composer.json b/.dev-tools/composer.json index cf9a8373..a846c5e5 100644 --- a/.dev-tools/composer.json +++ b/.dev-tools/composer.json @@ -51,7 +51,7 @@ "phpcbf || exit 0" ], "infection": [ - "infection run --min-msi=100 --logger-github --no-progress --threads=16" + "infection run --logger-github --no-progress --threads=16" ] } } diff --git a/.dev-tools/infection.json b/.dev-tools/infection.json index 11296b69..5e9dc75b 100644 --- a/.dev-tools/infection.json +++ b/.dev-tools/infection.json @@ -17,6 +17,7 @@ "configDir": "..", "customPath": "../vendor/phpunit/phpunit/phpunit" }, + "minCoveredMsi": 100, "mutators": { "ArrayAll": true, "ArrayAny": true, diff --git a/.dev-tools/src/InfectionConfigBuilder.php b/.dev-tools/src/InfectionConfigBuilder.php index 41491558..2b64e4d2 100644 --- a/.dev-tools/src/InfectionConfigBuilder.php +++ b/.dev-tools/src/InfectionConfigBuilder.php @@ -52,6 +52,7 @@ public function build(): array 'configDir' => '..', 'customPath' => '../vendor/phpunit/phpunit/phpunit', ], + 'minCoveredMsi' => 100, 'mutators' => [], ]; diff --git a/.dev-tools/src/Readme/ReadmeCommand.php b/.dev-tools/src/Readme/ReadmeCommand.php index e6048e1d..0b241217 100644 --- a/.dev-tools/src/Readme/ReadmeCommand.php +++ b/.dev-tools/src/Readme/ReadmeCommand.php @@ -269,7 +269,7 @@ private function diff(string $from, string $to): string private function createSplFileInfoDouble(): \SplFileInfo { - return new class (\getcwd() . '/file.php') extends \SplFileInfo { + return new class (\getcwd() . \DIRECTORY_SEPARATOR . 'file.php') extends \SplFileInfo { public function __construct(string $filename) { parent::__construct($filename); diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 5c9bc939..3cc3d743 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -59,6 +59,7 @@ $rules['trailing_comma_in_multiline'] = ['after_heredoc' => true, 'elements' => ['arguments', 'arrays']]; // TODO: remove when dropping support to PHP <8.0 $rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'phpstan-type'; +$rules[PhpdocOnlyAllowedAnnotationsFixer::name()]['elements'][] = 'codeCoverageIgnore'; foreach (new PhpCsFixerCustomFixersDev\Fixers() as $fixer) { $rules[$fixer->getName()] = true; diff --git a/tests/Fixer/AbstractFixerTestCase.php b/tests/Fixer/AbstractFixerTestCase.php index ea29ae3c..8cfb8bba 100644 --- a/tests/Fixer/AbstractFixerTestCase.php +++ b/tests/Fixer/AbstractFixerTestCase.php @@ -159,12 +159,17 @@ final protected static function getFixer(): FixerInterface /** * @param null|array $configuration */ - final protected function doTest(string $expected, ?string $input = null, ?array $configuration = null): void + final protected function doTest(string $expected, ?string $input = null, array $configuration = [], ?WhitespacesFixerConfig $whitespacesFixerConfig = null): void { $fixer = self::getFixer(); if ($fixer instanceof ConfigurableFixerInterface) { - $fixer->configure($configuration ?? []); + $fixer->configure($configuration); + } + + if ($whitespacesFixerConfig instanceof WhitespacesFixerConfig) { + self::assertInstanceOf(WhitespacesAwareFixerInterface::class, $fixer); + $fixer->setWhitespacesConfig($whitespacesFixerConfig); } if ($expected === $input) { @@ -250,7 +255,7 @@ final protected function assertSuccessorName(string $successorName): void private function createSplFileInfoDouble(): \SplFileInfo { - return new class (\getcwd() . '/src/file.php') extends \SplFileInfo { + return new class (\getcwd() . \DIRECTORY_SEPARATOR . 'src' . \DIRECTORY_SEPARATOR . 'FixerFile.php') extends \SplFileInfo { public function __construct(string $filename) { parent::__construct($filename); diff --git a/tests/Fixer/CommentedOutFunctionFixerTest.php b/tests/Fixer/CommentedOutFunctionFixerTest.php index 9e221630..689aedc7 100644 --- a/tests/Fixer/CommentedOutFunctionFixerTest.php +++ b/tests/Fixer/CommentedOutFunctionFixerTest.php @@ -31,11 +31,11 @@ public function testIsRisky(): void } /** - * @param null|array> $configuration + * @param array> $configuration * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void + public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->doTest($expected, $input, $configuration); } diff --git a/tests/Fixer/DataProviderNameFixerTest.php b/tests/Fixer/DataProviderNameFixerTest.php index e4c330ae..9ddf6d23 100644 --- a/tests/Fixer/DataProviderNameFixerTest.php +++ b/tests/Fixer/DataProviderNameFixerTest.php @@ -40,11 +40,11 @@ public function testSuccessorName(): void } /** - * @param null|array $configuration + * @param array $configuration * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void + public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->doTest($expected, $input, $configuration); } diff --git a/tests/Fixer/DataProviderStaticFixerTest.php b/tests/Fixer/DataProviderStaticFixerTest.php index a8155fc9..2e2ca055 100644 --- a/tests/Fixer/DataProviderStaticFixerTest.php +++ b/tests/Fixer/DataProviderStaticFixerTest.php @@ -36,11 +36,11 @@ public function testConfiguration(): void } /** - * @param null|array $configuration + * @param array $configuration * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void + public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->doTest($expected, $input, $configuration); } diff --git a/tests/Fixer/NoDuplicatedArrayKeyFixerTest.php b/tests/Fixer/NoDuplicatedArrayKeyFixerTest.php index 4e36ae0b..c58d692e 100644 --- a/tests/Fixer/NoDuplicatedArrayKeyFixerTest.php +++ b/tests/Fixer/NoDuplicatedArrayKeyFixerTest.php @@ -31,11 +31,11 @@ public function testConfiguration(): void } /** - * @param null|array $configuration + * @param array $configuration * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void + public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->doTest($expected, $input, $configuration); } diff --git a/tests/Fixer/NoSuperfluousConcatenationFixerTest.php b/tests/Fixer/NoSuperfluousConcatenationFixerTest.php index b4064a2c..e9974711 100644 --- a/tests/Fixer/NoSuperfluousConcatenationFixerTest.php +++ b/tests/Fixer/NoSuperfluousConcatenationFixerTest.php @@ -31,11 +31,11 @@ public function testConfiguration(): void } /** - * @param null|array $configuration + * @param array $configuration * * @dataProvider provideFixCases */ - public function testStringIsTheSame(string $expected, ?string $input = null, ?array $configuration = null): void + public function testStringIsTheSame(string $expected, ?string $input = null, array $configuration = []): void { if ($input === null) { $this->expectNotToPerformAssertions(); @@ -48,11 +48,11 @@ public function testStringIsTheSame(string $expected, ?string $input = null, ?ar } /** - * @param null|array $configuration + * @param array $configuration * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void + public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->doTest( '> $configuration + * @param array> $configuration * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void + public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->doTest($expected, $input, $configuration); } diff --git a/tests/Fixer/PromotedConstructorPropertyFixerTest.php b/tests/Fixer/PromotedConstructorPropertyFixerTest.php index 192aca22..d7d062b5 100644 --- a/tests/Fixer/PromotedConstructorPropertyFixerTest.php +++ b/tests/Fixer/PromotedConstructorPropertyFixerTest.php @@ -33,11 +33,11 @@ public function testIsRisky(): void } /** - * @param null|array> $configuration + * @param array> $configuration * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void + public function testFix(string $expected, ?string $input = null, ?array $configuration = []): void { $this->doTest($expected, $input, $configuration); } diff --git a/tests/Fixer/SingleSpaceAfterStatementFixerTest.php b/tests/Fixer/SingleSpaceAfterStatementFixerTest.php index b79de4a6..2d9ddb7f 100644 --- a/tests/Fixer/SingleSpaceAfterStatementFixerTest.php +++ b/tests/Fixer/SingleSpaceAfterStatementFixerTest.php @@ -113,11 +113,11 @@ public function testIsRisky(): void } /** - * @param null|array $configuration + * @param array $configuration * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void + public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->doTest($expected, $input, $configuration); } From 17bd934cdfda3e191701bf161c9f493ec64fbbb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Sun, 8 Jun 2025 23:52:20 +0200 Subject: [PATCH 2/2] Fix types --- tests/Fixer/AbstractFixerTestCase.php | 2 +- tests/Fixer/NumericLiteralSeparatorFixerTest.php | 4 ++-- tests/Fixer/PromotedConstructorPropertyFixerTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Fixer/AbstractFixerTestCase.php b/tests/Fixer/AbstractFixerTestCase.php index 8cfb8bba..6f9fb62f 100644 --- a/tests/Fixer/AbstractFixerTestCase.php +++ b/tests/Fixer/AbstractFixerTestCase.php @@ -157,7 +157,7 @@ final protected static function getFixer(): FixerInterface } /** - * @param null|array $configuration + * @param array $configuration */ final protected function doTest(string $expected, ?string $input = null, array $configuration = [], ?WhitespacesFixerConfig $whitespacesFixerConfig = null): void { diff --git a/tests/Fixer/NumericLiteralSeparatorFixerTest.php b/tests/Fixer/NumericLiteralSeparatorFixerTest.php index 26cac140..53ed584f 100644 --- a/tests/Fixer/NumericLiteralSeparatorFixerTest.php +++ b/tests/Fixer/NumericLiteralSeparatorFixerTest.php @@ -71,11 +71,11 @@ public function testReversingCodeSample(): void } /** - * @param null|array $configuration + * @param array $configuration * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = null): void + public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->doTest( $expected, diff --git a/tests/Fixer/PromotedConstructorPropertyFixerTest.php b/tests/Fixer/PromotedConstructorPropertyFixerTest.php index d7d062b5..bf2eb390 100644 --- a/tests/Fixer/PromotedConstructorPropertyFixerTest.php +++ b/tests/Fixer/PromotedConstructorPropertyFixerTest.php @@ -37,7 +37,7 @@ public function testIsRisky(): void * * @dataProvider provideFixCases */ - public function testFix(string $expected, ?string $input = null, ?array $configuration = []): void + public function testFix(string $expected, ?string $input = null, array $configuration = []): void { $this->doTest($expected, $input, $configuration); }