File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed
tests/Issues/DowngradeNullableInitialization Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \Tests \Issues \DowngradeNullableInitialization ;
6+
7+ use Iterator ;
8+ use PHPUnit \Framework \Attributes \DataProvider ;
9+ use Rector \Testing \PHPUnit \AbstractRectorTestCase ;
10+
11+ final class DowngradeNullableInitializationTest 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 \Issues \DowngradeNullableInitialization \Fixture ;
4+
5+ final class AddNullableInitializtion
6+ {
7+ public function __construct (
8+ private array $ doctrineTypeToScalarType = [
9+ 'tinyint ' => new \PHPStan \Type \BooleanType (),
10+ ]
11+ ) {}
12+ }
13+
14+ ?>
15+ -----
16+ <?php
17+
18+ namespace Rector \Tests \Issues \DowngradeNullableInitialization \Fixture ;
19+
20+ final class AddNullableInitializtion
21+ {
22+ private array $ doctrineTypeToScalarType ;
23+ public function __construct (?array $ doctrineTypeToScalarType = null )
24+ {
25+ $ doctrineTypeToScalarType ??= [
26+ 'tinyint ' => new \PHPStan \Type \BooleanType (),
27+ ];
28+ $ this ->doctrineTypeToScalarType = $ doctrineTypeToScalarType ;
29+ }
30+ }
31+
32+ ?>
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 \FunctionLike \DowngradeNewInInitializerRector ;
7+ use Rector \DowngradePhp80 \Rector \Class_ \DowngradePropertyPromotionRector ;
8+
9+ return static function (RectorConfig $ rectorConfig ): void {
10+ $ rectorConfig ->rules ([
11+ DowngradeNewInInitializerRector::class,
12+ DowngradePropertyPromotionRector::class,
13+ ]);
14+ };
You can’t perform that action at this time.
0 commit comments