mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-05 19:00:49 +00:00
cs fixes
This commit is contained in:
parent
e3e26f8ccf
commit
2b5ce2b815
|
@ -8,6 +8,9 @@ use PhpParser\Node\Expr\StaticCall;
|
|||
|
||||
final class MethodCallAnalyzer
|
||||
{
|
||||
/**
|
||||
* @param string[] $methodsNames
|
||||
*/
|
||||
public function isMethodCallTypeAndMethods(Node $node, string $type, array $methodsNames): bool
|
||||
{
|
||||
if (! $this->isMethodCallType($node, $type)) {
|
||||
|
@ -17,21 +20,6 @@ final class MethodCallAnalyzer
|
|||
return in_array((string) $node->name, $methodsNames, true);
|
||||
}
|
||||
|
||||
private function isMethodCallType(Node $node, string $type): bool
|
||||
{
|
||||
if (! $node instanceof MethodCall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$variableType = $this->findVariableType($node);
|
||||
if ($variableType !== $type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string[] $methodNames
|
||||
*/
|
||||
|
@ -53,6 +41,20 @@ final class MethodCallAnalyzer
|
|||
return false;
|
||||
}
|
||||
|
||||
private function isMethodCallType(Node $node, string $type): bool
|
||||
{
|
||||
if (! $node instanceof MethodCall) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$variableType = $this->findVariableType($node);
|
||||
if ($variableType !== $type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function isStaticMethodCallType(Node $node, string $type): bool
|
||||
{
|
||||
if (! $node instanceof StaticCall) {
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace Rector\Rector\Contrib\Nette;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\ClassConstFetch;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use Rector\Deprecation\SetNames;
|
||||
use Rector\NodeAnalyzer\MethodCallAnalyzer;
|
||||
|
@ -57,7 +59,7 @@ final class FormSetRequiredRector extends AbstractRector
|
|||
}
|
||||
|
||||
$arg = $node->args[0];
|
||||
if (! $arg->value instanceof Node\Expr\ClassConstFetch) {
|
||||
if (! $arg->value instanceof ClassConstFetch) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -74,7 +76,7 @@ final class FormSetRequiredRector extends AbstractRector
|
|||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
$args = [
|
||||
new Node\Arg($this->nodeFactory->createFalseConstant())
|
||||
new Arg($this->nodeFactory->createFalseConstant()),
|
||||
];
|
||||
|
||||
return new MethodCall($node->var, 'setRequired', $args);
|
||||
|
|
Loading…
Reference in New Issue
Block a user