-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathAssertCountWithZeroToAssertEmptyRector.php
More file actions
56 lines (50 loc) · 1.64 KB
/
AssertCountWithZeroToAssertEmptyRector.php
File metadata and controls
56 lines (50 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace Rector\PHPUnit\CodeQuality\Rector\MethodCall;
use PhpParser\Node;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @deprecated This rule is deprecated and will be removed in future releases. The use of empty() is discouraged as it introduces ambiguity. PHPStan and Rector promote refactoring away from empty() to more explicit readable structures.
*/
final class AssertCountWithZeroToAssertEmptyRector extends AbstractRector implements DeprecatedInterface
{
public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition(
'Change $this->assertCount(0, ...) to $this->assertEmpty(...)',
[
new CodeSample(
<<<'CODE_SAMPLE'
$this->assertCount(0, $countable);
$this->assertNotCount(0, $countable);
CODE_SAMPLE
,
<<<'CODE_SAMPLE'
$this->assertEmpty($countable);
$this->assertNotEmpty($countable);
CODE_SAMPLE
),
],
);
}
/**
* @return array<class-string<MethodCall|StaticCall>>
*/
public function getNodeTypes(): array
{
return [MethodCall::class, StaticCall::class];
}
/**
* @param MethodCall|StaticCall $node
*/
public function refactor(Node $node): MethodCall|StaticCall|null
{
// deprecated
return null;
}
}