-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor MyCLabs\Enum\Enum::equals calls to comparisons (#4532)
- Loading branch information
Showing
2 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...hp81/Rector/MethodCall/MyCLabsMethodCallToEnumConstRector/Fixture/usage_of_equals.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,59 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Fixture; | ||
|
||
use Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Source\SomeEnum; | ||
|
||
final class UsageOfEquals | ||
{ | ||
private SomeEnum $prop; | ||
|
||
public function run($value) | ||
{ | ||
$this->prop = $var = SomeEnum::USED_TO_BE_CONST(); | ||
|
||
$compare = SomeEnum::USED_TO_BE_CONST()->equals(SomeEnum::USED_TO_BE_CONST()); | ||
$compare = SomeEnum::USED_TO_BE_CONST()->equals($var); | ||
$compare = SomeEnum::USED_TO_BE_CONST()->equals($this->prop); | ||
|
||
$compare = $var->equals(SomeEnum::USED_TO_BE_CONST()); | ||
$compare = $var->equals($var); | ||
$compare = $var->equals($this->prop); | ||
|
||
$compare = $this->prop->equals(SomeEnum::USED_TO_BE_CONST()); | ||
$compare = $this->prop->equals($var); | ||
$compare = $this->prop->equals($this->prop); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Fixture; | ||
|
||
use Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Source\SomeEnum; | ||
|
||
final class UsageOfEquals | ||
{ | ||
private SomeEnum $prop; | ||
|
||
public function run($value) | ||
{ | ||
$this->prop = $var = \Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Source\SomeEnum::USED_TO_BE_CONST; | ||
|
||
$compare = \Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Source\SomeEnum::USED_TO_BE_CONST === \Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Source\SomeEnum::USED_TO_BE_CONST; | ||
$compare = \Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Source\SomeEnum::USED_TO_BE_CONST === $var; | ||
$compare = \Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Source\SomeEnum::USED_TO_BE_CONST === $this->prop; | ||
|
||
$compare = $var === \Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Source\SomeEnum::USED_TO_BE_CONST; | ||
$compare = $var === $var; | ||
$compare = $var === $this->prop; | ||
|
||
$compare = $this->prop === \Rector\Tests\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector\Source\SomeEnum::USED_TO_BE_CONST; | ||
$compare = $this->prop === $var; | ||
$compare = $this->prop === $this->prop; | ||
} | ||
} | ||
|
||
?> |
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