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 @@ -71,6 +71,9 @@ public function refactor(Node $node): ?Node
}

$firstArgumentValue = $node->args[0]->value;
if ($firstArgumentValue instanceof StaticCall) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, should be ! $firstArgumentValue instanceof FuncCall
Always go for stricter condition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried and it broke the tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How?

Copy link
Copy Markdown
Contributor Author

@gnutix gnutix Mar 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember by heart and I don't have more time to dedicate to this.

Feel free to try triggering the failing tests yourself (by applying the change you're suggesting) and you can then decide if you want to write this any differently.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Let's give it a go now, and wait for more issues

return null;
}
if (! $this->isNames($firstArgumentValue, ['strpos', 'stripos'])) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ public function refactor(Node $node): ?Node
return null;
}

/** @var FuncCall $firstArgumentValue */
$firstArgumentValue = $node->args[0]->value;

if ($firstArgumentValue instanceof StaticCall) {
return null;
}
if (! $this->isName($firstArgumentValue, 'property_exists')) {
Comment on lines +85 to 88
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with FuncCall

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ public function refactor(Node $node): ?Node
}

$firstArgumentValue = $node->args[0]->value;
if ($firstArgumentValue instanceof StaticCall ||
! $this->isNames($firstArgumentValue, array_keys(self::OLD_TO_NEW_METHODS))
) {
if ($firstArgumentValue instanceof StaticCall) {
return null;
}
Comment on lines +76 to +78
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

if (! $this->isNames($firstArgumentValue, array_keys(self::OLD_TO_NEW_METHODS))) {
return null;
}

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

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

final class SkipStaticCall extends \PHPUnit\Framework\TestCase
{
public function test()
{
self::assertFalse(SomeClass::someMethod());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

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

final class SkipStaticCall extends \PHPUnit\Framework\TestCase
{
public function test()
{
self::assertFalse(SomeClass::someMethod());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

final class Fixture3Test extends \PHPUnit\Framework\TestCase
final class SkipStaticCall extends \PHPUnit\Framework\TestCase
Comment thread
gnutix marked this conversation as resolved.
{
public function test()
{
Expand Down