Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^11.5",
"rector/rector-src": "dev-main",
"rector/rector-src": "dev-tv-stmts-interface",
"rector/swiss-knife": "^1.0",
"rector/type-perfect": "^2.1",
"symplify/phpstan-extensions": "^12.0",
Expand Down
16 changes: 4 additions & 12 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ parameters:
reportUnmatchedIgnoredErrors: false
errorFormat: symplify

# see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
typeAliases:
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_

scanDirectories:
- stubs

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

# false positive
- '#Access to an undefined property Rector\\Contract\\PhpParser\\Node\\StmtsAwareInterface\:\:\$stmts#'

# more advanced usage, but not always working
# see https://github.com/rectorphp/rector-src/actions/runs/11798721617/job/32865546672?pr=6422#step:5:110
- '#Doing instanceof PHPStan\\Type\\.+ is error\-prone and deprecated#'

- identifier: instanceof.alwaysTrue
- identifier: assign.propertyType

# not relevant
- '#Method (.*?)provideMinPhpVersion\(\) never returns \d+ so it can be removed from the return type#'

# chicken-egg false positive
-
message: '#Parameter \#1 \$value of static method Webmozart\\Assert\\Assert\:\:isAOf\(\) expects object\|string, PhpParser\\Node\\Stmt\\Class_\|null given#'
path: rules/AnnotationsToAttributes/Rector/Class_/AnnotationWithValueToAttributeRector.php

6 changes: 3 additions & 3 deletions rules/CodeQuality/Rector/MethodCall/AssertRegExpRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use PhpParser\Node\Identifier;
use PhpParser\Node\Scalar\Int_;
use PhpParser\Node\Stmt\Expression;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\Exception\ShouldNotHappenException;
use Rector\NodeManipulator\StmtsManipulator;
use Rector\PhpParser\Enum\NodeGroup;
use Rector\PhpParser\Node\Value\ValueResolver;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
Expand Down Expand Up @@ -77,11 +77,11 @@ public function getRuleDefinition(): RuleDefinition
*/
public function getNodeTypes(): array
{
return [StmtsAwareInterface::class];
return NodeGroup::STMTS_AWARE;
}

/**
* @param StmtsAwareInterface $node
* @param StmtsAware $node
*/
public function refactor(Node $node): ?Node
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use PhpParser\Node\Stmt\Nop;
use PhpParser\NodeVisitor;
use Rector\ChangesReporting\ValueObject\RectorWithLineChange;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\Contract\Rector\HTMLAverseRectorInterface;
use Rector\PhpParser\Enum\NodeGroup;
use Rector\PhpParser\Node\BetterNodeFinder;
use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
Expand Down Expand Up @@ -121,11 +121,11 @@ public function beforeTraverse(array $nodes): ?array
*/
public function getNodeTypes(): array
{
return [StmtsAwareInterface::class];
return NodeGroup::STMTS_AWARE;
}

/**
* @param StmtsAwareInterface $node
* @param StmtsAware $node
*/
public function refactor(Node $node): int
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\Expression;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\PhpParser\Enum\NodeGroup;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\PHPUnit\NodeFactory\AssertCallFactory;
use Rector\Rector\AbstractRector;
Expand Down Expand Up @@ -76,11 +76,11 @@ public function test()
*/
public function getNodeTypes(): array
{
return [StmtsAwareInterface::class];
return NodeGroup::STMTS_AWARE;
}

/**
* @param StmtsAwareInterface $node
* @param StmtsAware $node
*/
public function refactor(Node $node): ?Node
{
Expand Down