Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp80] Handle Throw Exception on DowngradeMatchToSwitchRect…
…or (#1019) * Add failing test fixture for DowngradeMatchToSwitchRector + DowngradeThrowExprRector # Failing Test for DowngradeMatchToSwitchRector + DowngradeThrowExprRector Based on https://getrector.org/demo/1ec2fda5-2490-6c56-9d12-93cf2aafeb8a * update fixture * Closes #1018 Fixes rectorphp/rector#6750 * [ci-review] Rector Rectify Co-authored-by: Leonardo Losoviz <leo@getpop.org> Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
adb6e3c
commit 33e5cab
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...radePhp80/Rector/Expression/DowngradeMatchToSwitchRector/Fixture/throw_expression.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,38 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
|
||
final class DemoFile | ||
{ | ||
public function run($param) | ||
{ | ||
return match ($param) { | ||
'a' => 'hi', | ||
'b' => 'bye', | ||
default => throw new Exception('no salutation'), | ||
}; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
|
||
final class DemoFile | ||
{ | ||
public function run($param) | ||
{ | ||
switch ($param) { | ||
case 'a': | ||
return 'hi'; | ||
case 'b': | ||
return 'bye'; | ||
default: | ||
throw new Exception('no salutation'); | ||
} | ||
} | ||
} | ||
|
||
?> |
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