|
5 | 5 | namespace Rector\CodingStyle\Rector\Encapsed; |
6 | 6 |
|
7 | 7 | use PhpParser\Node; |
8 | | -use PhpParser\Node\Expr\Variable; |
9 | 8 | use PhpParser\Node\Scalar\InterpolatedString; |
10 | | -use PhpParser\Token; |
| 9 | +use Rector\Configuration\Deprecation\Contract\DeprecatedInterface; |
| 10 | +use Rector\Exception\ShouldNotHappenException; |
11 | 11 | use Rector\Rector\AbstractRector; |
12 | 12 | use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; |
13 | 13 | use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; |
14 | 14 |
|
15 | 15 | /** |
16 | | - * @see \Rector\Tests\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector\WrapEncapsedVariableInCurlyBracesRectorTest |
| 16 | + * @deprecated This rule is deprecated, as it is a coding standard preference with no real value. Use a coding standard tool instead. |
17 | 17 | */ |
18 | | -final class WrapEncapsedVariableInCurlyBracesRector extends AbstractRector |
| 18 | +final class WrapEncapsedVariableInCurlyBracesRector extends AbstractRector implements DeprecatedInterface |
19 | 19 | { |
20 | 20 | public function getRuleDefinition(): RuleDefinition |
21 | 21 | { |
@@ -51,28 +51,9 @@ public function getNodeTypes(): array |
51 | 51 | */ |
52 | 52 | public function refactor(Node $node): ?Node |
53 | 53 | { |
54 | | - $hasVariableBeenWrapped = false; |
55 | | - $oldTokens = $this->getFile() |
56 | | - ->getOldTokens(); |
57 | | - |
58 | | - foreach ($node->parts as $index => $nodePart) { |
59 | | - if ($nodePart instanceof Variable && $nodePart->getStartTokenPos() >= 0) { |
60 | | - $start = $oldTokens[$nodePart->getStartTokenPos() - 1] ?? null; |
61 | | - $end = $oldTokens[$nodePart->getEndTokenPos() + 1] ?? null; |
62 | | - |
63 | | - if ($start instanceof Token && $end instanceof Token && $start->text === '{' && $end->text === '}') { |
64 | | - continue; |
65 | | - } |
66 | | - |
67 | | - $hasVariableBeenWrapped = true; |
68 | | - $node->parts[$index] = new Variable($nodePart->name); |
69 | | - } |
70 | | - } |
71 | | - |
72 | | - if (! $hasVariableBeenWrapped) { |
73 | | - return null; |
74 | | - } |
75 | | - |
76 | | - return $node; |
| 54 | + throw new ShouldNotHappenException(sprintf( |
| 55 | + '"%s" rule is deprecated, as it is a coding standard preference with no real value', |
| 56 | + self::class |
| 57 | + )); |
77 | 58 | } |
78 | 59 | } |
0 commit comments