Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
namespace Rector\CodingStyle\Rector\Encapsed;

use PhpParser\Node;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\InterpolatedString;
use PhpParser\Token;
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
use Rector\Exception\ShouldNotHappenException;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

/**
* @see \Rector\Tests\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector\WrapEncapsedVariableInCurlyBracesRectorTest
* @deprecated This rule is deprecated, as it is a coding standard preference with no real value. Use a coding standard tool instead.
*/
final class WrapEncapsedVariableInCurlyBracesRector extends AbstractRector
final class WrapEncapsedVariableInCurlyBracesRector extends AbstractRector implements DeprecatedInterface
{
public function getRuleDefinition(): RuleDefinition
{
Expand Down Expand Up @@ -51,28 +51,9 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$hasVariableBeenWrapped = false;
$oldTokens = $this->getFile()
->getOldTokens();

foreach ($node->parts as $index => $nodePart) {
if ($nodePart instanceof Variable && $nodePart->getStartTokenPos() >= 0) {
$start = $oldTokens[$nodePart->getStartTokenPos() - 1] ?? null;
$end = $oldTokens[$nodePart->getEndTokenPos() + 1] ?? null;

if ($start instanceof Token && $end instanceof Token && $start->text === '{' && $end->text === '}') {
continue;
}

$hasVariableBeenWrapped = true;
$node->parts[$index] = new Variable($nodePart->name);
}
}

if (! $hasVariableBeenWrapped) {
return null;
}

return $node;
throw new ShouldNotHappenException(sprintf(
'"%s" rule is deprecated, as it is a coding standard preference with no real value',
self::class
));
}
}
2 changes: 0 additions & 2 deletions src/Config/Level/CodingStyleLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector;
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector;
use Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector;
Expand Down Expand Up @@ -57,7 +56,6 @@ final class CodingStyleLevel
StringClassNameToClassConstantRector::class,
CatchExceptionNameMatchingTypeRector::class,
SplitDoubleAssignRector::class,
WrapEncapsedVariableInCurlyBracesRector::class,
NewlineBeforeNewAssignSetRector::class,
MakeInheritedMethodVisibilitySameAsParentRector::class,
CallUserFuncArrayToVariadicRector::class,
Expand Down
Loading