-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NarrowPublicClassMethodParamTypeRule: Take default value into account (…
…#4) * Added failling test * better test * fix * Update MethodCallArgTypesCollector.php * Update NarrowPrivateClassMethodParamTypeRule.php * Update CollectorMetadataPrinter.php * run rectorrunr rector
- Loading branch information
Showing
5 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/Rules/NarrowPublicClassMethodParamTypeRule/Fixture/HandleDefaultValue.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture; | ||
|
||
class HandleDefaultValue { | ||
public function takesUnionWithDifferentDefaultValue( | ||
int|string $value = "hallo" | ||
): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function takesUnionWithSameTypeDefaultValue( | ||
int|string $value = 123 | ||
): bool | ||
{ | ||
return true; | ||
} | ||
|
||
static public function run(): void | ||
{ | ||
$o = new HandleDefaultValue(); | ||
$o->takesUnionWithDifferentDefaultValue(1); | ||
|
||
$o = new HandleDefaultValue(); | ||
$o->takesUnionWithSameTypeDefaultValue(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters