diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f6415266..1c8593e1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -136,7 +136,7 @@ jobs: env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - run: ./vendor/bin/php-coveralls --verbose + run: ./vendor/bin/php-coveralls --verbose || true - if: matrix.calculate-coverage env: diff --git a/src/Fixer/PhpdocTagNoNamedArgumentsFixer.php b/src/Fixer/PhpdocTagNoNamedArgumentsFixer.php index 06c95f28..085ffe1e 100644 --- a/src/Fixer/PhpdocTagNoNamedArgumentsFixer.php +++ b/src/Fixer/PhpdocTagNoNamedArgumentsFixer.php @@ -163,7 +163,7 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void private static function isAttributeClass(Tokens $tokens, int $index): bool { - while ($tokens[$index]->isGivenKind([\T_ABSTRACT, \T_FINAL, FCT::T_READONLY])) { + while ($tokens[$index]->isGivenKind([\T_FINAL, FCT::T_READONLY])) { $index = $tokens->getPrevMeaningfulToken($index); \assert(\is_int($index)); } diff --git a/tests/Fixer/AbstractFixerTestCase.php b/tests/Fixer/AbstractFixerTestCase.php index 0ed73f85..aa6f5580 100644 --- a/tests/Fixer/AbstractFixerTestCase.php +++ b/tests/Fixer/AbstractFixerTestCase.php @@ -41,6 +41,8 @@ abstract class AbstractFixerTestCase extends TestCase 'testFix81', 'testFix82', 'testFix84', + 'testFixPre85', + 'testFix85', 'testIsRisky', 'testReversingCodeSample', 'testStringIsTheSame', diff --git a/tests/Fixer/PhpdocTagNoNamedArgumentsFixerTest.php b/tests/Fixer/PhpdocTagNoNamedArgumentsFixerTest.php index 772255e5..f3f8cf04 100644 --- a/tests/Fixer/PhpdocTagNoNamedArgumentsFixerTest.php +++ b/tests/Fixer/PhpdocTagNoNamedArgumentsFixerTest.php @@ -255,7 +255,7 @@ final class MyAttributeClass {} namespace Foo; use Attribute as TheAttributeClass; #[TheAttributeClass(flags: TheAttributeClass::TARGET_METHOD)] - abstract class MyAttributeClass {} + final class MyAttributeClass {} PHP, ]; } @@ -286,7 +286,7 @@ public static function provideFix82Cases(): iterable final readonly class NotAttributeClass1 {} #[Attribute(flags: Attribute::TARGET_METHOD)] - abstract readonly class MyAttributeClass {} + final readonly class MyAttributeClass {} /** * @no-named-arguments @@ -302,7 +302,7 @@ public static function provideFix82Cases(): iterable final readonly class NotAttributeClass1 {} #[Attribute(flags: Attribute::TARGET_METHOD)] - abstract readonly class MyAttributeClass {} + final readonly class MyAttributeClass {} #[FooAttribute] #[BarAttribute] @@ -311,4 +311,39 @@ public static function provideFix82Cases(): iterable PHP, ]; } + + /** + * @dataProvider provideFixPre85Cases + * + * @requires PHP ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 + */ + public function testFixPre85(string $expected, ?string $input = null): void + { + $this->doTest($expected, $input); + } + + /** + * @return iterable + */ + public static function provideFixPre85Cases(): iterable + { + // the below case is fatal error in PHP 8.5+ (https://github.com/php/php-src/pull/19154) + yield 'always add for abstract attribute class' => [ + <<<'PHP' +