Skip to content

Commit d0508ee

Browse files
[stmts-aware] Use NodeGroup::STMTS_AWARE over StmtsAwareInterface (#593)
* [stmts-aware] Use NodeGroup::STMTS_AWARE over StmtsAwareInterface * [ci-review] Rector Rectify * clean up phpstan ignore notice --------- Co-authored-by: GitHub Action <actions@github.com>
1 parent 2a0f7e7 commit d0508ee

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed

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 & 12 deletions
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

@@ -31,21 +35,9 @@ parameters:
3135
# phpstan false positive
3236
- '#Parameter \#1 \$className of method Rector\\PhpParser\\AstResolver\:\:resolveClassMethod\(\) expects class\-string, string given#'
3337

34-
# false positive
35-
- '#Access to an undefined property Rector\\Contract\\PhpParser\\Node\\StmtsAwareInterface\:\:\$stmts#'
36-
3738
# more advanced usage, but not always working
3839
# see https://github.com/rectorphp/rector-src/actions/runs/11798721617/job/32865546672?pr=6422#step:5:110
3940
- '#Doing instanceof PHPStan\\Type\\.+ is error\-prone and deprecated#'
4041

4142
- identifier: instanceof.alwaysTrue
4243
- identifier: assign.propertyType
43-
44-
# not relevant
45-
- '#Method (.*?)provideMinPhpVersion\(\) never returns \d+ so it can be removed from the return type#'
46-
47-
# chicken-egg false positive
48-
-
49-
message: '#Parameter \#1 \$value of static method Webmozart\\Assert\\Assert\:\:isAOf\(\) expects object\|string, PhpParser\\Node\\Stmt\\Class_\|null given#'
50-
path: rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php
51-

rules/CodeQuality/Rector/MethodCall/AssertRegExpRector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
use PhpParser\Node\Identifier;
1515
use PhpParser\Node\Scalar\Int_;
1616
use PhpParser\Node\Stmt\Expression;
17-
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
1817
use Rector\Exception\ShouldNotHappenException;
1918
use Rector\NodeManipulator\StmtsManipulator;
19+
use Rector\PhpParser\Enum\NodeGroup;
2020
use Rector\PhpParser\Node\Value\ValueResolver;
2121
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
2222
use Rector\Rector\AbstractRector;
@@ -77,11 +77,11 @@ public function getRuleDefinition(): RuleDefinition
7777
*/
7878
public function getNodeTypes(): array
7979
{
80-
return [StmtsAwareInterface::class];
80+
return NodeGroup::STMTS_AWARE;
8181
}
8282

8383
/**
84-
* @param StmtsAwareInterface $node
84+
* @param StmtsAware $node
8585
*/
8686
public function refactor(Node $node): ?Node
8787
{

rules/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use PhpParser\Node\Stmt\Nop;
1111
use PhpParser\NodeVisitor;
1212
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
13-
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
1413
use Rector\Contract\Rector\HTMLAverseRectorInterface;
14+
use Rector\PhpParser\Enum\NodeGroup;
1515
use Rector\PhpParser\Node\BetterNodeFinder;
1616
use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace;
1717
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
@@ -121,11 +121,11 @@ public function beforeTraverse(array $nodes): ?array
121121
*/
122122
public function getNodeTypes(): array
123123
{
124-
return [StmtsAwareInterface::class];
124+
return NodeGroup::STMTS_AWARE;
125125
}
126126

127127
/**
128-
* @param StmtsAwareInterface $node
128+
* @param StmtsAware $node
129129
*/
130130
public function refactor(Node $node): int
131131
{

rules/PHPUnit60/Rector/MethodCall/DelegateExceptionArgumentsRector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use PhpParser\Node\Expr\StaticCall;
1010
use PhpParser\Node\Identifier;
1111
use PhpParser\Node\Stmt\Expression;
12-
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
12+
use Rector\PhpParser\Enum\NodeGroup;
1313
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
1414
use Rector\PHPUnit\NodeFactory\AssertCallFactory;
1515
use Rector\Rector\AbstractRector;
@@ -76,11 +76,11 @@ public function test()
7676
*/
7777
public function getNodeTypes(): array
7878
{
79-
return [StmtsAwareInterface::class];
79+
return NodeGroup::STMTS_AWARE;
8080
}
8181

8282
/**
83-
* @param StmtsAwareInterface $node
83+
* @param StmtsAware $node
8484
*/
8585
public function refactor(Node $node): ?Node
8686
{

0 commit comments

Comments
 (0)