From 63879f66b5a3d18d359fb250d7850debd3644357 Mon Sep 17 00:00:00 2001 From: Michael Bolli Date: Mon, 6 Jan 2025 08:34:40 +0100 Subject: [PATCH 1/3] Create SkipExplicitlyNullableParams.php --- .../Fixture/SkipExplicitlyNullableParams.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExplicitlyNullableParams.php diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExplicitlyNullableParams.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExplicitlyNullableParams.php new file mode 100644 index 00000000..a50aff1e --- /dev/null +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExplicitlyNullableParams.php @@ -0,0 +1,22 @@ +test(false); + } +} From 841336759d0a24faad91bc388defae7f403a1ba7 Mon Sep 17 00:00:00 2001 From: Michael Bolli Date: Mon, 6 Jan 2025 11:35:06 +0100 Subject: [PATCH 2/3] Update NarrowPublicClassMethodParamTypeRuleTest.php --- .../NarrowPublicClassMethodParamTypeRuleTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php index a62308c4..269a5898 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php @@ -155,7 +155,17 @@ public static function provideData(): Iterator yield [[__DIR__ . '/Fixture/SkipEnum.php'], []]; $argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'int'); +<<<<<<< HEAD yield [[__DIR__ . '/Fixture/HandleDefaultValue.php'], [[$argErrorMessage, 15]]]; +======= + yield [[ + __DIR__ . '/Fixture/HandleDefaultValue.php', + ], [[$argErrorMessage, 15]]]; + + yield [[ + __DIR__ . '/Fixture/SkipExplicitlyNullableParams.php', + ], []]; +>>>>>>> ab7f1f1 (Update NarrowPublicClassMethodParamTypeRuleTest.php) } /** From fa6d469f29a3521345f98a7f9765ff63965994d0 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 4 May 2025 23:08:02 +0200 Subject: [PATCH 3/3] if only bool is passed, it should be required --- ...llableParams.php => ExplicitlyNullableParams.php} | 5 ++--- .../NarrowPublicClassMethodParamTypeRuleTest.php | 12 +++--------- 2 files changed, 5 insertions(+), 12 deletions(-) rename tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/{SkipExplicitlyNullableParams.php => ExplicitlyNullableParams.php} (70%) diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExplicitlyNullableParams.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ExplicitlyNullableParams.php similarity index 70% rename from tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExplicitlyNullableParams.php rename to tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ExplicitlyNullableParams.php index a50aff1e..68e1d5e4 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/SkipExplicitlyNullableParams.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/ExplicitlyNullableParams.php @@ -4,11 +4,10 @@ namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture; -final class SkipExplicitlyNullableParams +final class ExplicitlyNullableParams { public function test( ?bool $bool = true, - array $array = [], ): bool { return $bool; @@ -16,7 +15,7 @@ public function test( static public function run(): void { - $skipDateTimeMix = new SkipExplicitlyNullableParams(); + $skipDateTimeMix = new ExplicitlyNullableParams(); $skipDateTimeMix->test(false); } } diff --git a/tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php b/tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php index 269a5898..ff2044be 100644 --- a/tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php +++ b/tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php @@ -155,17 +155,11 @@ public static function provideData(): Iterator yield [[__DIR__ . '/Fixture/SkipEnum.php'], []]; $argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'int'); -<<<<<<< HEAD + yield [[__DIR__ . '/Fixture/HandleDefaultValue.php'], [[$argErrorMessage, 15]]]; -======= - yield [[ - __DIR__ . '/Fixture/HandleDefaultValue.php', - ], [[$argErrorMessage, 15]]]; - yield [[ - __DIR__ . '/Fixture/SkipExplicitlyNullableParams.php', - ], []]; ->>>>>>> ab7f1f1 (Update NarrowPublicClassMethodParamTypeRuleTest.php) + $argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'bool'); + yield [[__DIR__ . '/Fixture/ExplicitlyNullableParams.php'], [[$argErrorMessage, 9]]]; } /**