Skip to content

Commit a7fa1c1

Browse files
TomasVotrubambolli
andauthored
[tests] Add fixture with nullable param (#64)
* Create SkipExplicitlyNullableParams.php * Update NarrowPublicClassMethodParamTypeRuleTest.php * if only bool is passed, it should be required --------- Co-authored-by: Michael Bolli <michael@bolli.us>
1 parent 6231236 commit a7fa1c1

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture;
6+
7+
final class ExplicitlyNullableParams
8+
{
9+
public function test(
10+
?bool $bool = true,
11+
): bool
12+
{
13+
return $bool;
14+
}
15+
16+
static public function run(): void
17+
{
18+
$skipDateTimeMix = new ExplicitlyNullableParams();
19+
$skipDateTimeMix->test(false);
20+
}
21+
}

tests/Rules/NarrowPublicClassMethodParamTypeRule/NarrowPublicClassMethodParamTypeRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ public static function provideData(): Iterator
155155
yield [[__DIR__ . '/Fixture/SkipEnum.php'], []];
156156

157157
$argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'int');
158+
158159
yield [[__DIR__ . '/Fixture/HandleDefaultValue.php'], [[$argErrorMessage, 15]]];
160+
161+
$argErrorMessage = sprintf(NarrowPublicClassMethodParamTypeRule::ERROR_MESSAGE, 'bool');
162+
yield [[__DIR__ . '/Fixture/ExplicitlyNullableParams.php'], [[$argErrorMessage, 9]]];
159163
}
160164

161165
/**

0 commit comments

Comments
 (0)