-
-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Handle crash on first class callable inside match on Op…
…tionalParametersAfterRequiredRector (#6263) * [CodeQuality] Handle crash on first class callable inside match on OptionalParametersAfterRequiredRector * Fix * Fix * Fix * Fix
- Loading branch information
1 parent
8073ee7
commit 816c733
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...ptionalParametersAfterRequiredRector/Fixture/skip_match_with_first_class_callable.php.inc
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,18 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector\Fixture; | ||
|
||
use Rector\Tests\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector\Source\SomeClass; | ||
|
||
final class SkipMatchWithFirstClassCallable | ||
{ | ||
public function run($type):void | ||
{ | ||
match($type) { | ||
'string' => SomeClass::fromString(...), | ||
'int' => function () { | ||
return SomeClass::fromInt(...); | ||
} | ||
}; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector/Source/SomeClass.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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector\Source; | ||
|
||
class SomeClass | ||
{ | ||
public static function fromString(string $id) {} | ||
public static function fromInt(int $id) {} | ||
} |
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