Skip to content

Commit

Permalink
[ci-review] Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbelasichon authored and github-actions[bot] committed May 28, 2024
1 parent 3051d3d commit 0e4d028
Showing 1 changed file with 0 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PHPStan\Type\ObjectType;
use Rector\PhpParser\Node\Value\ValueResolver;
use Rector\Rector\AbstractRector;
use Rector\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
Expand All @@ -30,16 +28,6 @@ final class MigrateExpressionBuilderTrimMethodSecondParameterRector extends Abst
3 => 'BOTH',
];

/**
* @readonly
*/
private ValueResolver $valueResolver;

public function __construct(ValueResolver $valueResolver)
{
$this->valueResolver = $valueResolver;
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Migrate second parameter of trim method to enum', [new CodeSample(
Expand Down Expand Up @@ -74,41 +62,6 @@ public function getNodeTypes(): array
public function refactor(Node $node): ?Node
{
echo "test";exit;
if (! $this->isName($node->name, 'trim')) {
return null;
}

if (! $this->nodeTypeResolver->isMethodStaticCallOrClassMethodObjectType(
$node,
new ObjectType('TYPO3\\CMS\\Core\\Database\\Query\\Expression\\ExpressionBuilder')
)) {
return null;
}

$secondArgument = $node->args[1] ?? null;

if ($secondArgument === null) {
return null;
}

$trimMode = $this->valueResolver->getValue($secondArgument->value);

if (! is_numeric($trimMode)) {
return null;
}

if (! isset(self::$integerToTrimMode[((int) $trimMode)])) {
return null;
}

$trimModeConstant = self::$integerToTrimMode[((int) $trimMode)];

$node->args[1]->value = $this->nodeFactory->createClassConstFetch(
'Doctrine\\DBAL\\Platforms\\TrimMode',
$trimModeConstant
);

return $node;
}

public function provideMinPhpVersion(): int
Expand Down

0 comments on commit 0e4d028

Please sign in to comment.