diff --git a/composer.json b/composer.json index 10ca68c7..843ccd45 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/phpstan.neon b/phpstan.neon index 6fe15a7a..c89f87c9 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -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 @@ -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 - diff --git a/rules/CodeQuality/Rector/MethodCall/AssertRegExpRector.php b/rules/CodeQuality/Rector/MethodCall/AssertRegExpRector.php index 81beee1a..87d45b0d 100644 --- a/rules/CodeQuality/Rector/MethodCall/AssertRegExpRector.php +++ b/rules/CodeQuality/Rector/MethodCall/AssertRegExpRector.php @@ -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; @@ -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 { diff --git a/rules/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector.php b/rules/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector.php index 6a2706e0..19eae113 100644 --- a/rules/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector.php +++ b/rules/CodeQuality/Rector/StmtsAwareInterface/DeclareStrictTypesTestsRector.php @@ -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; @@ -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 { diff --git a/rules/PHPUnit60/Rector/MethodCall/DelegateExceptionArgumentsRector.php b/rules/PHPUnit60/Rector/MethodCall/DelegateExceptionArgumentsRector.php index 5d94a434..a9dcbe9f 100644 --- a/rules/PHPUnit60/Rector/MethodCall/DelegateExceptionArgumentsRector.php +++ b/rules/PHPUnit60/Rector/MethodCall/DelegateExceptionArgumentsRector.php @@ -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; @@ -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 {