-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PHP 8.0] Fix ChangeSwitchToMatchRector for next new variable re-use (#…
…2798) Co-authored-by: Sergey Burkun <sburkun@eyeconweb.com>
- Loading branch information
1 parent
66d273e
commit d92936b
Showing
6 changed files
with
114 additions
and
22 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
52 changes: 52 additions & 0 deletions
52
...hp80/Rector/Switch_/ChangeSwitchToMatchRector/Fixture/assign_and_use_as_parameter.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\Php80\Rector\Switch_\ChangeSwitchToMatchRector\Fixture; | ||
|
||
use Rector\Tests\Php80\Rector\Switch_\ChangeSwitchToMatchRector\Source\SomeResponse; | ||
|
||
final class AssignAndUseAsParameter | ||
{ | ||
public function getErrorResponse(int $errorCode): SomeResponse | ||
{ | ||
switch ($errorCode) { | ||
case 1: | ||
$content = 'BAD REQUEST'; | ||
break; | ||
case 2: | ||
$content = 'CHANGE STATUS FAILED'; | ||
break; | ||
case 3: | ||
$content = 'NOT FOUND'; | ||
break; | ||
default: | ||
$content = 'FAILED'; | ||
} | ||
|
||
return new SomeResponse($content, 400); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Switch_\ChangeSwitchToMatchRector\Fixture; | ||
|
||
use Rector\Tests\Php80\Rector\Switch_\ChangeSwitchToMatchRector\Source\SomeResponse; | ||
|
||
final class AssignAndUseAsParameter | ||
{ | ||
public function getErrorResponse(int $errorCode): SomeResponse | ||
{ | ||
$content = match ($errorCode) { | ||
1 => 'BAD REQUEST', | ||
2 => 'CHANGE STATUS FAILED', | ||
3 => 'NOT FOUND', | ||
default => 'FAILED', | ||
}; | ||
|
||
return new SomeResponse($content, 400); | ||
} | ||
} | ||
|
||
?> |
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
12 changes: 12 additions & 0 deletions
12
rules-tests/Php80/Rector/Switch_/ChangeSwitchToMatchRector/Source/SomeResponse.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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Php80\Rector\Switch_\ChangeSwitchToMatchRector\Source; | ||
|
||
final class SomeResponse | ||
{ | ||
public function __construct($content, $statusCode) | ||
{ | ||
} | ||
} |
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