Skip to content

Commit

Permalink
Convert Enum::byValue to Enum::from
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasJancar committed Oct 11, 2024
1 parent aa245d3 commit a3d056d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace BrandEmbassyCodingStandard\Rector\MabeEnumMethodCallToEnumConstRector\Fixture;

use BrandEmbassyCodingStandard\Rector\MabeEnumMethodCallToEnumConstRector\Source\SomeEnum;

final class ByValue {
public function run() {
$user = SomeEnum::byValue('user');
}
}
?>
-----
<?php
namespace BrandEmbassyCodingStandard\Rector\MabeEnumMethodCallToEnumConstRector\Fixture;

use BrandEmbassyCodingStandard\Rector\MabeEnumMethodCallToEnumConstRector\Source\SomeEnum;

final class ByValue {
public function run() {
$user = \BrandEmbassyCodingStandard\Rector\MabeEnumMethodCallToEnumConstRector\Source\SomeEnum::from('user');
}
}
?>
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ private function refactorStaticCall(StaticCall $staticCall, string $staticCallNa
return $this->nodeFactory->createStaticCall($className, 'cases');
}

if ($staticCallName === 'byValue') {
return $this->nodeFactory->createStaticCall($className, 'from', $staticCall->getArgs());
}

if ($staticCallName === 'has') {
return $this->refactorHasStaticCall($staticCall);
}
Expand Down

0 comments on commit a3d056d

Please sign in to comment.