Skip to content

Commit d0bb532

Browse files
authored
Fix CI on PHP 8.5 (#1073)
1 parent c3a815a commit d0bb532

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
env:
137137
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138138
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
139-
run: ./vendor/bin/php-coveralls --verbose
139+
run: ./vendor/bin/php-coveralls --verbose || true
140140

141141
- if: matrix.calculate-coverage
142142
env:

src/Fixer/PhpdocTagNoNamedArgumentsFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void
163163

164164
private static function isAttributeClass(Tokens $tokens, int $index): bool
165165
{
166-
while ($tokens[$index]->isGivenKind([\T_ABSTRACT, \T_FINAL, FCT::T_READONLY])) {
166+
while ($tokens[$index]->isGivenKind([\T_FINAL, FCT::T_READONLY])) {
167167
$index = $tokens->getPrevMeaningfulToken($index);
168168
\assert(\is_int($index));
169169
}

tests/Fixer/AbstractFixerTestCase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ abstract class AbstractFixerTestCase extends TestCase
4141
'testFix81',
4242
'testFix82',
4343
'testFix84',
44+
'testFixPre85',
45+
'testFix85',
4446
'testIsRisky',
4547
'testReversingCodeSample',
4648
'testStringIsTheSame',

tests/Fixer/PhpdocTagNoNamedArgumentsFixerTest.php

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ final class MyAttributeClass {}
255255
namespace Foo;
256256
use Attribute as TheAttributeClass;
257257
#[TheAttributeClass(flags: TheAttributeClass::TARGET_METHOD)]
258-
abstract class MyAttributeClass {}
258+
final class MyAttributeClass {}
259259
PHP,
260260
];
261261
}
@@ -286,7 +286,7 @@ public static function provideFix82Cases(): iterable
286286
final readonly class NotAttributeClass1 {}
287287
288288
#[Attribute(flags: Attribute::TARGET_METHOD)]
289-
abstract readonly class MyAttributeClass {}
289+
final readonly class MyAttributeClass {}
290290
291291
/**
292292
* @no-named-arguments
@@ -302,7 +302,7 @@ public static function provideFix82Cases(): iterable
302302
final readonly class NotAttributeClass1 {}
303303
304304
#[Attribute(flags: Attribute::TARGET_METHOD)]
305-
abstract readonly class MyAttributeClass {}
305+
final readonly class MyAttributeClass {}
306306
307307
#[FooAttribute]
308308
#[BarAttribute]
@@ -311,4 +311,39 @@ public static function provideFix82Cases(): iterable
311311
PHP,
312312
];
313313
}
314+
315+
/**
316+
* @dataProvider provideFixPre85Cases
317+
*
318+
* @requires PHP ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0
319+
*/
320+
public function testFixPre85(string $expected, ?string $input = null): void
321+
{
322+
$this->doTest($expected, $input);
323+
}
324+
325+
/**
326+
* @return iterable<array{0: string, 1?: string}>
327+
*/
328+
public static function provideFixPre85Cases(): iterable
329+
{
330+
// the below case is fatal error in PHP 8.5+ (https://github.com/php/php-src/pull/19154)
331+
yield 'always add for abstract attribute class' => [
332+
<<<'PHP'
333+
<?php
334+
namespace Foo;
335+
/**
336+
* @no-named-arguments
337+
*/
338+
#[\Attribute(flags: \Attribute::TARGET_METHOD)]
339+
abstract class MyAttributeClass {}
340+
PHP,
341+
<<<'PHP'
342+
<?php
343+
namespace Foo;
344+
#[\Attribute(flags: \Attribute::TARGET_METHOD)]
345+
abstract class MyAttributeClass {}
346+
PHP,
347+
];
348+
}
314349
}

0 commit comments

Comments
 (0)