Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/PhpdocTagNoNamedArgumentsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixer/AbstractFixerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ abstract class AbstractFixerTestCase extends TestCase
'testFix81',
'testFix82',
'testFix84',
'testFixPre85',
'testFix85',
'testIsRisky',
'testReversingCodeSample',
'testStringIsTheSame',
Expand Down
41 changes: 38 additions & 3 deletions tests/Fixer/PhpdocTagNoNamedArgumentsFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
}
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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<array{0: string, 1?: string}>
*/
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'
<?php
namespace Foo;
/**
* @no-named-arguments
*/
#[\Attribute(flags: \Attribute::TARGET_METHOD)]
abstract class MyAttributeClass {}
PHP,
<<<'PHP'
<?php
namespace Foo;
#[\Attribute(flags: \Attribute::TARGET_METHOD)]
abstract class MyAttributeClass {}
PHP,
];
}
}
Loading