diff --git a/rules-tests/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/get_class.php.inc b/rules-tests/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/get_class.php.inc index c04f12ae..aafe145c 100644 --- a/rules-tests/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/get_class.php.inc +++ b/rules-tests/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/get_class.php.inc @@ -9,7 +9,6 @@ final class GetClass extends \PHPUnit\Framework\TestCase public function test() { $something = new stdClass(); - $this->assertSame(get_class($something), 'stdClass'); self::assertSame('stdClass', get_class($something)); } } @@ -27,7 +26,6 @@ final class GetClass extends \PHPUnit\Framework\TestCase public function test() { $something = new stdClass(); - $this->assertInstanceOf('stdClass', $something); self::assertInstanceOf('stdClass', $something); } } diff --git a/rules-tests/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/skip_first_param.inc b/rules-tests/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/skip_first_param.inc new file mode 100644 index 00000000..042b58f2 --- /dev/null +++ b/rules-tests/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector/Fixture/skip_first_param.inc @@ -0,0 +1,29 @@ +assertSame(count($something), 5); + $this->assertSame(get_class($something), 'stdClass'); + } +} + +?> + ----- +assertSame(count($something), 5); + $this->assertSame(get_class($something), 'stdClass'); + } +} + +?> diff --git a/rules/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector.php b/rules/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector.php index b12a4355..497e8f80 100644 --- a/rules/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector.php +++ b/rules/CodeQuality/Rector/MethodCall/AssertCompareToSpecificMethodRector.php @@ -57,7 +57,7 @@ public function getRuleDefinition(): RuleDefinition '$this->assertCount(10, $anything, "message");' ), new CodeSample( - '$this->assertNotEquals(get_class($value), SomeInstance::class);', + '$this->assertNotEquals(SomeInstance::class, get_class($value));', '$this->assertNotInstanceOf(SomeInstance::class, $value);' ), ] @@ -95,18 +95,12 @@ public function refactor(Node $node): ?Node $firstArgument = $node->getArgs()[0]; $secondArgument = $node->getArgs()[1]; - - $firstArgumentValue = $firstArgument->value; $secondArgumentValue = $secondArgument->value; if ($secondArgumentValue instanceof FuncCall) { return $this->processFuncCallArgumentValue($node, $secondArgumentValue, $firstArgument); } - if ($firstArgumentValue instanceof FuncCall) { - return $this->processFuncCallArgumentValue($node, $firstArgumentValue, $secondArgument); - } - return null; }