static fixes (#5127)

* static fixes

* fix remove class rule for tests
This commit is contained in:
Tomas Votruba 2021-01-10 12:01:40 +01:00 committed by GitHub
parent edcfe417a4
commit 074298d35c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 20 deletions

View File

@ -9,6 +9,7 @@ use PhpParser\Node\Stmt\Class_;
use Rector\Caching\Contract\Rector\ZeroCacheRectorInterface;
use Rector\Core\Rector\AbstractRector;
use Rector\DeadCode\UnusedNodeResolver\UnusedClassResolver;
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -87,7 +88,11 @@ CODE_SAMPLE
return null;
}
$this->removeFile($this->getFileInfo());
if (StaticPHPUnitEnvironment::isPHPUnitRun()) {
$this->removeNode($node);
} else {
$this->removeFile($this->getFileInfo());
}
return null;
}

View File

@ -4,14 +4,6 @@ namespace Rector\DeadCode\Tests\Rector\Class_\RemoveUnusedClassesRector\Fixture;
use Rector\DeadCode\Tests\Rector\Class_\RemoveUnusedClassesRector\Source\SomeInterface;
class SomeClass implements SomeInterface
{
public function run($items)
{
return null;
}
}
class NowhereUsedClass
{
}
@ -24,12 +16,4 @@ namespace Rector\DeadCode\Tests\Rector\Class_\RemoveUnusedClassesRector\Fixture;
use Rector\DeadCode\Tests\Rector\Class_\RemoveUnusedClassesRector\Source\SomeInterface;
class SomeClass implements SomeInterface
{
public function run($items)
{
return null;
}
}
?>

View File

@ -22,7 +22,7 @@ final class RectorRuleAndValueObjectHaveSameStartsRuleTest extends AbstractServi
public function provideData(): Iterator
{
yield [__DIR__ . '/Fixture/HaveSameStarts.php', []];
yield [__DIR__ . '/Fixture/SkipHaveSameStarts.php', []];
yield [__DIR__ . '/Fixture/SkipDifferentType.php', []];
yield [__DIR__ . '/Fixture/SkipNoCall.php', []];
yield [__DIR__ . '/Fixture/SkipNoCallConfigure.php', []];

View File

@ -6,7 +6,7 @@ namespace Rector\PHPStanExtensions\Tests\Rule\RequireRectorCategoryByGetNodeType
use PhpParser\Node\Stmt\ClassMethod;
abstract class AbstractSkip
abstract class SkipAbstract
{
public function getNodeTypes(): array
{

View File

@ -33,7 +33,7 @@ final class RequireRectorCategoryByGetNodeTypesRuleTest extends AbstractServiceA
yield [__DIR__ . '/Fixture/ClassMethod/ChangeSomethingRector.php', [[$errorMessage, 14]]];
yield [__DIR__ . '/Fixture/FunctionLike/SkipSubtypeRector.php', []];
yield [__DIR__ . '/Fixture/ClassMethod/SkipInterface.php', []];
yield [__DIR__ . '/Fixture/AbstractSkip.php', []];
yield [__DIR__ . '/Fixture/SkipAbstract.php', []];
}
protected function getRule(): Rule