skip encapsed string from constant extraction

This commit is contained in:
TomasVotruba 2020-06-15 15:22:57 +02:00
parent e9ebf725d4
commit 5b8bf939a6
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,13 @@
<?php
namespace Rector\SOLID\Tests\Rector\ClassMethod\ChangeReadOnlyVariableWithDefaultValueToConstantRector\Fixture;
class SkipEnscapedString
{
public function run()
{
$testsBaseDir = "{$this->testSuite->rootPath}/tests";
return $testsBaseDir;
}
}

View File

@ -10,6 +10,7 @@ use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar;
use PhpParser\Node\Scalar\Encapsed;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\NodeTraverser\CallableNodeTraverser;
@ -87,6 +88,10 @@ final class VariableManipulator
return null;
}
if ($node->expr instanceof Encapsed) {
return null;
}
if ($node->expr instanceof Array_ && ! $this->arrayManipulator->isArrayOnlyScalarValues($node->expr)) {
return null;
}