File tree Expand file tree Collapse file tree
rules-tests/DowngradePhp81/Rector/ClassMethod/AddReturnTypeWillChangeAttributeRector
rules/DowngradePhp81/Rector/ClassMethod Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99use Rector \Config \RectorConfig ;
1010use Rector \ValueObject \PhpVersion ;
1111use Rector \DowngradePhp81 \Rector \ClassConst \DowngradeFinalizePublicClassConstantRector ;
12+ use Rector \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector ;
1213use Rector \DowngradePhp81 \Rector \FuncCall \DowngradeArrayIsListRector ;
1314use Rector \DowngradePhp81 \Rector \FuncCall \DowngradeFirstClassCallableSyntaxRector ;
1415use Rector \DowngradePhp81 \Rector \FunctionLike \DowngradeNeverTypeDeclarationRector ;
2526 $ rectorConfig ->phpVersion (PhpVersion::PHP_80 );
2627
2728 $ rectorConfig ->rules ([
29+ AddReturnTypeWillChangeAttributeRector::class,
2830 DowngradeFinalizePublicClassConstantRector::class,
2931 DowngradeFirstClassCallableSyntaxRector::class,
3032 DowngradeNeverTypeDeclarationRector::class,
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector ;
6+
7+ use Iterator ;
8+ use PHPUnit \Framework \Attributes \DataProvider ;
9+ use Rector \Testing \PHPUnit \AbstractRectorTestCase ;
10+
11+ final class AddReturnTypeWillChangeAttributeRectorTest extends AbstractRectorTestCase
12+ {
13+ #[DataProvider('provideData ' )]
14+ public function test (string $ filePath ): void
15+ {
16+ $ this ->doTestFile ($ filePath );
17+ }
18+
19+ public static function provideData (): Iterator
20+ {
21+ return self ::yieldFilesFromDirectory (__DIR__ . '/Fixture ' );
22+ }
23+
24+ public function provideConfigFilePath (): string
25+ {
26+ return __DIR__ . '/config/configured_rule.php ' ;
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
4+
5+ class ArrayAccessClass implements \ArrayAccess
6+ {
7+ public function offsetGet ($ offset )
8+ {
9+ }
10+
11+ public function offsetExists ($ offset )
12+ {
13+ }
14+
15+ public function offsetSet ($ offset , $ value )
16+ {
17+ }
18+
19+ public function offsetUnset ($ offset )
20+ {
21+ }
22+ }
23+
24+ ?>
25+ -----
26+ <?php
27+
28+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
29+
30+ class ArrayAccessClass implements \ArrayAccess
31+ {
32+ #[\ReturnTypeWillChange]
33+ public function offsetGet ($ offset )
34+ {
35+ }
36+
37+ #[\ReturnTypeWillChange]
38+ public function offsetExists ($ offset )
39+ {
40+ }
41+
42+ #[\ReturnTypeWillChange]
43+ public function offsetSet ($ offset , $ value )
44+ {
45+ }
46+
47+ #[\ReturnTypeWillChange]
48+ public function offsetUnset ($ offset )
49+ {
50+ }
51+ }
52+
53+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
4+
5+ class SomeCountable implements \Countable
6+ {
7+ public function count ()
8+ {
9+ }
10+ }
11+
12+ ?>
13+ -----
14+ <?php
15+
16+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
17+
18+ class SomeCountable implements \Countable
19+ {
20+ #[\ReturnTypeWillChange]
21+ public function count ()
22+ {
23+ }
24+ }
25+
26+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
4+
5+ class SomeIterator implements \Iterator
6+ {
7+ public function current ()
8+ {
9+ }
10+
11+ public function key ()
12+ {
13+ }
14+
15+ public function next ()
16+ {
17+ }
18+
19+ public function rewind ()
20+ {
21+ }
22+
23+ public function valid ()
24+ {
25+ }
26+ }
27+
28+ ?>
29+ -----
30+ <?php
31+
32+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
33+
34+ class SomeIterator implements \Iterator
35+ {
36+ #[\ReturnTypeWillChange]
37+ public function current ()
38+ {
39+ }
40+
41+ #[\ReturnTypeWillChange]
42+ public function key ()
43+ {
44+ }
45+
46+ #[\ReturnTypeWillChange]
47+ public function next ()
48+ {
49+ }
50+
51+ #[\ReturnTypeWillChange]
52+ public function rewind ()
53+ {
54+ }
55+
56+ #[\ReturnTypeWillChange]
57+ public function valid ()
58+ {
59+ }
60+ }
61+
62+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
4+
5+ class SomeIteratorAggregate implements \IteratorAggregate
6+ {
7+ public function getIterator ()
8+ {
9+ }
10+ }
11+
12+ ?>
13+ -----
14+ <?php
15+
16+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
17+
18+ class SomeIteratorAggregate implements \IteratorAggregate
19+ {
20+ #[\ReturnTypeWillChange]
21+ public function getIterator ()
22+ {
23+ }
24+ }
25+
26+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
4+
5+ class ArrayAccessAlreadyAttributed implements \ArrayAccess
6+ {
7+ #[\ReturnTypeWillChange]
8+ public function offsetGet ($ offset )
9+ {
10+ }
11+
12+ #[\ReturnTypeWillChange]
13+ public function offsetExists ($ offset )
14+ {
15+ }
16+
17+ #[\ReturnTypeWillChange]
18+ public function offsetSet ($ offset , $ value )
19+ {
20+ }
21+
22+ #[\ReturnTypeWillChange]
23+ public function offsetUnset ($ offset )
24+ {
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
4+
5+ class ArrayAccessWithReturnType implements \ArrayAccess
6+ {
7+ public function offsetGet ($ offset ): mixed
8+ {
9+ }
10+
11+ public function offsetExists ($ offset ): bool
12+ {
13+ }
14+
15+ public function offsetSet ($ offset , $ value ): void
16+ {
17+ }
18+
19+ public function offsetUnset ($ offset ): void
20+ {
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
4+
5+ class SomeStringable implements \Stringable
6+ {
7+ public function __toString ()
8+ {
9+ }
10+ }
11+
12+ ?>
13+ -----
14+ <?php
15+
16+ namespace Rector \Tests \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector \Fixture ;
17+
18+ class SomeStringable implements \Stringable
19+ {
20+ #[\ReturnTypeWillChange]
21+ public function __toString ()
22+ {
23+ }
24+ }
25+
26+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ use Rector \Config \RectorConfig ;
6+ use Rector \DowngradePhp81 \Rector \ClassMethod \AddReturnTypeWillChangeAttributeRector ;
7+
8+ return static function (RectorConfig $ rectorConfig ): void {
9+ $ rectorConfig ->rule (AddReturnTypeWillChangeAttributeRector::class);
10+ };
You can’t perform that action at this time.
0 commit comments