Merge pull request #2997 from gnutix/static-call-fixes

Fix various static calls errors in PHPUnit Rectors.
This commit is contained in:
Tomas Votruba 2020-03-04 00:16:58 +01:00 committed by GitHub
commit e9ee423b34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 6 deletions

View File

@ -71,6 +71,9 @@ final class AssertFalseStrposToContainsRector extends AbstractPHPUnitRector
}
$firstArgumentValue = $node->args[0]->value;
if ($firstArgumentValue instanceof StaticCall) {
return null;
}
if (! $this->isNames($firstArgumentValue, ['strpos', 'stripos'])) {
return null;
}

View File

@ -81,9 +81,10 @@ final class AssertPropertyExistsRector extends AbstractPHPUnitRector
return null;
}
/** @var FuncCall $firstArgumentValue */
$firstArgumentValue = $node->args[0]->value;
if ($firstArgumentValue instanceof StaticCall) {
return null;
}
if (! $this->isName($firstArgumentValue, 'property_exists')) {
return null;
}

View File

@ -73,9 +73,10 @@ final class AssertTrueFalseToSpecificMethodRector extends AbstractPHPUnitRector
}
$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;
}
if (! $this->isNames($firstArgumentValue, array_keys(self::OLD_TO_NEW_METHODS))) {
return null;
}

View File

@ -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());
}
}

View File

@ -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());
}
}

View File

@ -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
{
public function test()
{