mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-25 12:14:02 +01:00
Fix bug when calling toString in Variable
This commit is contained in:
parent
5e4b512f45
commit
5f8df78ce7
@ -3,9 +3,11 @@
|
||||
namespace Rector\Rector\Contrib\PHPUnit\SpecificMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
use Rector\NodeAnalyzer\MethodCallAnalyzer;
|
||||
use Rector\NodeChanger\IdentifierRenamer;
|
||||
use Rector\Rector\AbstractPHPUnitRector;
|
||||
@ -51,7 +53,7 @@ final class AssertFalseStrposToContainsRector extends AbstractPHPUnitRector
|
||||
}
|
||||
|
||||
$firstArgumentValue = $node->args[0]->value;
|
||||
if (! $firstArgumentValue instanceof FuncCall) {
|
||||
if (! $this->isNamedFunction($firstArgumentValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -97,4 +99,14 @@ final class AssertFalseStrposToContainsRector extends AbstractPHPUnitRector
|
||||
$this->identifierRenamer->renameNode($methodCallNode, 'assertContains');
|
||||
}
|
||||
}
|
||||
|
||||
private function isNamedFunction(Expr $node): bool
|
||||
{
|
||||
if (! $node instanceof FuncCall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$functionName = $node->name;
|
||||
return $functionName instanceof Name;
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,10 @@
|
||||
namespace Rector\Rector\Contrib\PHPUnit\SpecificMethod;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Name;
|
||||
use Rector\Node\NodeFactory;
|
||||
use Rector\NodeAnalyzer\MethodCallAnalyzer;
|
||||
use Rector\NodeChanger\IdentifierRenamer;
|
||||
@ -90,7 +92,7 @@ final class AssertTrueFalseInternalTypeToSpecificMethodRector extends AbstractPH
|
||||
$methodCallNode = $node;
|
||||
|
||||
$firstArgumentValue = $methodCallNode->args[0]->value;
|
||||
if (! $firstArgumentValue instanceof FuncCall) {
|
||||
if (! $this->isNamedFunction($firstArgumentValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -125,4 +127,14 @@ final class AssertTrueFalseInternalTypeToSpecificMethodRector extends AbstractPH
|
||||
$argument,
|
||||
], $oldArguments);
|
||||
}
|
||||
|
||||
private function isNamedFunction(Expr $node): bool
|
||||
{
|
||||
if (! $node instanceof FuncCall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$functionName = $node->name;
|
||||
return $functionName instanceof Name;
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,9 @@ final class AssertTrueFalseToSpecificMethodRector extends AbstractPHPUnitRector
|
||||
|
||||
private function resolveFunctionName(Node $node): ?string
|
||||
{
|
||||
if ($node instanceof FuncCall) {
|
||||
if ($node instanceof FuncCall
|
||||
&& $node->name instanceof Name
|
||||
) {
|
||||
/** @var Name $nameNode */
|
||||
$nameNode = $node->name;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user