mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-05 02:40:50 +00:00
[Symfony] add the other method as well
This commit is contained in:
parent
b0d3984ae0
commit
9899eab6c5
|
@ -7,19 +7,25 @@ use PhpParser\Node\Expr\StaticCall;
|
|||
|
||||
final class MethodCallAnalyzer
|
||||
{
|
||||
public function isStaticMethodCallTypeAndMethod(Node $node, string $type, string $method): bool
|
||||
/**
|
||||
* @param string[] $methodNames
|
||||
*/
|
||||
public function isStaticMethodCallTypeAndMethods(Node $node, string $type, array $methodNames): bool
|
||||
{
|
||||
if (! $this->isStaticMethodCallType($node, $type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @var StaticCall $node */
|
||||
$methodName = (string) $node->name;
|
||||
if ($methodName !== $method) {
|
||||
return false;
|
||||
$currentMethodName = (string) $node->name;
|
||||
|
||||
foreach ($methodNames as $methodName) {
|
||||
if ($currentMethodName === $methodName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isStaticMethodCallType(Node $node, string $type): bool
|
||||
|
|
|
@ -22,7 +22,11 @@ use Rector\Rector\AbstractRector;
|
|||
*/
|
||||
final class VarDumperTestTraitMethodArgsRector extends AbstractRector
|
||||
{
|
||||
const TRAIT_NAME = 'VarDumperTestTrait';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const TRAIT_NAME = 'VarDumperTestTrait';
|
||||
|
||||
/**
|
||||
* @var MethodCallAnalyzer
|
||||
*/
|
||||
|
@ -45,9 +49,9 @@ final class VarDumperTestTraitMethodArgsRector extends AbstractRector
|
|||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
if (! $this->methodCallAnalyzer->isStaticMethodCallTypeAndMethod($node,self::TRAIT_NAME,'assertDumpEquals')) {
|
||||
if (! $this->methodCallAnalyzer->isStaticMethodCallTypeAndMethods($node,self::TRAIT_NAME, ['assertDumpEquals', 'assertDumpMatchesFormat'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @var StaticCall $node */
|
||||
if (count($node->args) <= 2) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
VarDumperTestTrait::assertDumpEquals($dump, $data, null, 'Some message');
|
||||
|
||||
VarDumperTestTrait::assertDumpMatchesFormat($dump, $format, null, 'Some message');
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
VarDumperTestTrait::assertDumpEquals($dump, $data, 'Some message');
|
||||
|
||||
VarDumperTestTrait::assertDumpMatchesFormat($dump, $format, 'Some message');
|
||||
|
|
Loading…
Reference in New Issue
Block a user