mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
[PHP 8.0] Drop FalseableCountToZeroRector, not used anymore
This commit is contained in:
parent
5f975f48f6
commit
120e857606
@ -6,7 +6,6 @@ use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
|
||||
use Rector\Generic\NodeAnalyzer\ArgumentAddingScope;
|
||||
use Rector\Generic\Rector\ClassMethod\ArgumentAdderRector;
|
||||
use Rector\Generic\ValueObject\ArgumentAdder;
|
||||
use Rector\Php80\Rector\Assign\FalseableCountToZeroRector;
|
||||
use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector;
|
||||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
|
||||
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
|
||||
@ -77,5 +76,4 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
'pg_setclientencoding' => 'pg_set_client_encoding',
|
||||
],
|
||||
]]);
|
||||
$services->set(FalseableCountToZeroRector::class);
|
||||
};
|
||||
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Php80\Rector\Assign;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\Cast\Int_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
||||
/**
|
||||
* @see \Rector\Php80\Tests\Rector\Assign\FalseableCountToZeroRector\FalseableCountToZeroRectorTest
|
||||
*/
|
||||
final class FalseableCountToZeroRector extends AbstractRector
|
||||
{
|
||||
public function getRuleDefinition(): RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Convert false of pg_num_rows() to zero', [
|
||||
new CodeSample(
|
||||
<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$value = pg_num_rows('...');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
|
||||
,
|
||||
<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$value = (int) pg_num_rows('...');
|
||||
}
|
||||
}
|
||||
CODE_SAMPLE
|
||||
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNodeTypes(): array
|
||||
{
|
||||
return [Assign::class];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Assign $node
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if (! $this->isFuncCallName($node->expr, 'pg_num_rows')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$node->expr = new Int_($node->expr);
|
||||
return $node;
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Php80\Tests\Rector\Assign\FalseableCountToZeroRector;
|
||||
|
||||
use Iterator;
|
||||
use Rector\Php80\Rector\Assign\FalseableCountToZeroRector;
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FalseableCountToZeroRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test(SmartFileInfo $fileInfo): void
|
||||
{
|
||||
$this->doTestFileInfo($fileInfo);
|
||||
}
|
||||
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
protected function getRectorClass(): string
|
||||
{
|
||||
return FalseableCountToZeroRector::class;
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Php80\Tests\Rector\Assign\FalseableCountToZeroRector\Fixture;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$value = pg_num_rows('...');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Php80\Tests\Rector\Assign\FalseableCountToZeroRector\Fixture;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$value = (int) pg_num_rows('...');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user