-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp80] Rollback to change match to switch on DowngradeMatch…
…ToSwitchRector (#139) * restore fixture * restore * regenerate docs * roll back fixtures * rename fixture * update fixture * rename fixture * fixture fix * more fixture rollback * reduce parent take 1: on ArrowFunction * [ci-review] Rector Rectify * implemented 🎉 * rename fixture * rename fixture * update fixture * fix * fix phpstan * fix phpstan --------- Co-authored-by: Tomas Votruba <[email protected]> Co-authored-by: GitHub Action <[email protected]>
- Loading branch information
1 parent
06c6448
commit 57ad03c
Showing
26 changed files
with
773 additions
and
87 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
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
45 changes: 45 additions & 0 deletions
45
.../Rector/Expression/DowngradeMatchToSwitchRector/Fixture/array_item_keyed_assigned.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,45 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
|
||
class ArrayItemKeyedAssigned | ||
{ | ||
public function run($statusCode) | ||
{ | ||
$value = [ | ||
'result' => match ($statusCode) { | ||
200, 300 => null, | ||
400 => 'not found', | ||
default => 'unknown status code', | ||
}, | ||
]; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
|
||
class ArrayItemKeyedAssigned | ||
{ | ||
public function run($statusCode) | ||
{ | ||
$value = [ | ||
'result' => (function () use ($statusCode) { | ||
switch ($statusCode) { | ||
case 200: | ||
case 300: | ||
return null; | ||
case 400: | ||
return 'not found'; | ||
default: | ||
return 'unknown status code'; | ||
} | ||
})(), | ||
]; | ||
} | ||
} | ||
|
||
?> |
45 changes: 45 additions & 0 deletions
45
...adePhp80/Rector/Expression/DowngradeMatchToSwitchRector/Fixture/array_item_spread.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,45 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
|
||
class ArrayItemSpread | ||
{ | ||
public function run($statusCode) | ||
{ | ||
return [ | ||
...match ($statusCode) { | ||
200, 300 => [null], | ||
400 => ['not found'], | ||
default => ['unknown status code'], | ||
}, | ||
]; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
|
||
class ArrayItemSpread | ||
{ | ||
public function run($statusCode) | ||
{ | ||
return [ | ||
...(function () use ($statusCode) { | ||
switch ($statusCode) { | ||
case 200: | ||
case 300: | ||
return [null]; | ||
case 400: | ||
return ['not found']; | ||
default: | ||
return ['unknown status code']; | ||
} | ||
})(), | ||
]; | ||
} | ||
} | ||
|
||
?> |
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
38 changes: 38 additions & 0 deletions
38
...80/Rector/Expression/DowngradeMatchToSwitchRector/Fixture/call_anonymous_function.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; | ||
|
||
$output = function($value) { | ||
echo $value; | ||
}; | ||
|
||
$output(match ($statusCode) { | ||
100, 200 => null, | ||
300 => 'not found', | ||
default => 'unknown status code', | ||
}); | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
|
||
$output = function($value) { | ||
echo $value; | ||
}; | ||
|
||
switch ($statusCode) { | ||
case 100: | ||
case 200: | ||
$output(null); | ||
break; | ||
case 300: | ||
$output('not found'); | ||
break; | ||
default: | ||
$output('unknown status code'); | ||
break; | ||
} | ||
|
||
?> |
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
52 changes: 52 additions & 0 deletions
52
...wngradePhp80/Rector/Expression/DowngradeMatchToSwitchRector/Fixture/function_call.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,52 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
|
||
function output($value) | ||
{ | ||
echo $value; | ||
} | ||
|
||
class FunctionCall | ||
{ | ||
public function run($statusCode) | ||
{ | ||
output(match ($statusCode) { | ||
200, 300 => null, | ||
400 => 'not found', | ||
default => 'unknown status code', | ||
}); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
|
||
function output($value) | ||
{ | ||
echo $value; | ||
} | ||
|
||
class FunctionCall | ||
{ | ||
public function run($statusCode) | ||
{ | ||
switch ($statusCode) { | ||
case 200: | ||
case 300: | ||
output(null); | ||
break; | ||
case 400: | ||
output('not found'); | ||
break; | ||
default: | ||
output('unknown status code'); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
?> |
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
39 changes: 39 additions & 0 deletions
39
...dePhp80/Rector/Expression/DowngradeMatchToSwitchRector/Fixture/in_arrow_function2.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,39 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
final class InArrowFunction2 | ||
{ | ||
public function run($value) | ||
{ | ||
$mapped = static fn (mixed $default): mixed => match (true) { | ||
is_string($default) => sprintf('"%s"', $default), | ||
default => $default, | ||
}; | ||
|
||
return $mapped($value); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture; | ||
final class InArrowFunction2 | ||
{ | ||
public function run($value) | ||
{ | ||
$mapped = static function (mixed $default) : mixed { | ||
switch (true) { | ||
case is_string($default): | ||
return sprintf('"%s"', $default); | ||
default: | ||
return $default; | ||
} | ||
}; | ||
|
||
return $mapped($value); | ||
} | ||
} | ||
|
||
?> |
Oops, something went wrong.