Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand All @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertCompareToSpecificMethodRector\Fixture;

final class SkipFirstParam extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertSame(count($something), 5);
$this->assertSame(get_class($something), 'stdClass');
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\AssertCompareToSpecificMethodRector\Fixture;

final class SkipFirstParam extends \PHPUnit\Framework\TestCase
{
public function test()
{
$this->assertSame(count($something), 5);
$this->assertSame(get_class($something), 'stdClass');
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -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);'
),
]
Expand Down Expand Up @@ -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;
}

Expand Down
Loading