@@ -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