Skip to content

Commit

Permalink
[Phpunit] Prevent MethodCall instances of being processed (#5798)
Browse files Browse the repository at this point in the history
Co-authored-by: Dominik Peters <d.peters@billiger-mietwagen.de>
  • Loading branch information
Dominik Peters and Dominik Peters authored Mar 8, 2021
1 parent 896ca73 commit 5f70de5
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function refactor(Node $node): ?Node
}

$firstArgumentValue = $node->args[0]->value;
if ($firstArgumentValue instanceof StaticCall) {
if ($firstArgumentValue instanceof StaticCall || $firstArgumentValue instanceof MethodCall) {
return null;
}
if (! $this->isNames($firstArgumentValue, ['strpos', 'stripos'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function refactor(Node $node): ?Node
}

$firstArgumentValue = $node->args[0]->value;
if ($firstArgumentValue instanceof StaticCall) {
if ($firstArgumentValue instanceof StaticCall || $firstArgumentValue instanceof MethodCall) {
return null;
}
if (! $this->isName($firstArgumentValue, 'property_exists')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function refactor(Node $node): ?Node
}

$firstArgumentValue = $node->args[0]->value;
if ($firstArgumentValue instanceof StaticCall) {
if ($firstArgumentValue instanceof StaticCall || $firstArgumentValue instanceof MethodCall) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Rector\PHPUnit\Tests\Rector\MethodCall\AssertFalseStrposToContainsRector\Fixture;

final class SkipMethodCall extends \PHPUnit\Framework\TestCase
{
public function test()
{
$someObject = new Foo();
self::assertFalse($someObject->someMethod());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Rector\PHPUnit\Tests\Rector\MethodCall\AssertPropertyExistsRector\Fixture;

final class SkipMethodCall extends \PHPUnit\Framework\TestCase
{
public function test()
{
$someObject = new Foo();
self::assertFalse($someObject->someMethod());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Rector\PHPUnit\Tests\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector\Fixture;

final class SkipMethodCall extends \PHPUnit\Framework\TestCase
{
public function test()
{
$someObject = new Foo();
self::assertFalse($someObject->someMethod());
}
}

0 comments on commit 5f70de5

Please sign in to comment.