Skip to content

Commit 3465330

Browse files
committed
[stmts-aware] Use NodeGroup::STMTS_AWARE over StmtsAwareInterface
1 parent 2a0f7e7 commit 3465330

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"phpstan/phpstan-deprecation-rules": "^2.0",
1414
"phpstan/phpstan-webmozart-assert": "^2.0",
1515
"phpunit/phpunit": "^11.5",
16-
"rector/rector-src": "dev-main",
16+
"rector/rector-src": "dev-tv-stmts-interface",
1717
"rector/swiss-knife": "^1.0",
1818
"rector/type-perfect": "^2.1",
1919
"symplify/phpstan-extensions": "^12.0",

phpstan.neon

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ parameters:
1111
reportUnmatchedIgnoredErrors: false
1212
errorFormat: symplify
1313

14+
# see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
15+
typeAliases:
16+
StmtsAware: \PhpParser\Node\Expr\Closure | \PhpParser\Node\Stmt\Case_ | \PhpParser\Node\Stmt\Catch_ | \PhpParser\Node\Stmt\ClassMethod | \PhpParser\Node\Stmt\Do_ | \PhpParser\Node\Stmt\Else_ | \PhpParser\Node\Stmt\ElseIf_ | \PhpParser\Node\Stmt\Finally_ | \PhpParser\Node\Stmt\For_ | \PhpParser\Node\Stmt\Foreach_ | \PhpParser\Node\Stmt\Function_ | \PhpParser\Node\Stmt\If_ | \PhpParser\Node\Stmt\Namespace_ | \PhpParser\Node\Stmt\TryCatch | \PhpParser\Node\Stmt\While_
17+
1418
scanDirectories:
1519
- stubs
1620

@@ -48,4 +52,3 @@ parameters:
4852
-
4953
message: '#Parameter \#1 \$value of static method Webmozart\\Assert\\Assert\:\:isAOf\(\) expects object\|string, PhpParser\\Node\\Stmt\\Class_\|null given#'
5054
path: rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php
51-

rules/CodeQuality/Rector/MethodCall/AssertRegExpRector.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
1818
use Rector\Exception\ShouldNotHappenException;
1919
use Rector\NodeManipulator\StmtsManipulator;
20+
use Rector\PhpParser\Enum\NodeGroup;
2021
use Rector\PhpParser\Node\Value\ValueResolver;
2122
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
2223
use Rector\Rector\AbstractRector;
@@ -77,11 +78,11 @@ public function getRuleDefinition(): RuleDefinition
7778
*/
7879
public function getNodeTypes(): array
7980
{
80-
return [StmtsAwareInterface::class];
81+
return NodeGroup::STMTS_AWARE;
8182
}
8283

8384
/**
84-
* @param StmtsAwareInterface $node
85+
* @param StmtsAware $node
8586
*/
8687
public function refactor(Node $node): ?Node
8788
{

rules/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
1313
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
1414
use Rector\Contract\Rector\HTMLAverseRectorInterface;
15+
use Rector\PhpParser\Enum\NodeGroup;
1516
use Rector\PhpParser\Node\BetterNodeFinder;
1617
use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace;
1718
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
@@ -121,11 +122,11 @@ public function beforeTraverse(array $nodes): ?array
121122
*/
122123
public function getNodeTypes(): array
123124
{
124-
return [StmtsAwareInterface::class];
125+
return NodeGroup::STMTS_AWARE;
125126
}
126127

127128
/**
128-
* @param StmtsAwareInterface $node
129+
* @param StmtsAware $node
129130
*/
130131
public function refactor(Node $node): int
131132
{

rules/PHPUnit60/Rector/MethodCall/DelegateExceptionArgumentsRector.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PhpParser\Node\Identifier;
1111
use PhpParser\Node\Stmt\Expression;
1212
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
13+
use Rector\PhpParser\Enum\NodeGroup;
1314
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
1415
use Rector\PHPUnit\NodeFactory\AssertCallFactory;
1516
use Rector\Rector\AbstractRector;
@@ -76,11 +77,11 @@ public function test()
7677
*/
7778
public function getNodeTypes(): array
7879
{
79-
return [StmtsAwareInterface::class];
80+
return NodeGroup::STMTS_AWARE;
8081
}
8182

8283
/**
83-
* @param StmtsAwareInterface $node
84+
* @param StmtsAware $node
8485
*/
8586
public function refactor(Node $node): ?Node
8687
{

0 commit comments

Comments
 (0)