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 @@ -14,7 +14,7 @@
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^11.5",
"rector/jack": "^0.2.9",
"rector/rector-src": "dev-main",
"rector/rector-src": "dev-tv-stmts-interface",
"rector/type-perfect": "^2.1",
"symfony/config": "^6.4",
"symfony/dependency-injection": "^6.4",
Expand Down
9 changes: 8 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ parameters:
level: 8
errorFormat: symplify

# reportUnmatchedIgnoredErrors: false
# 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_

reportUnmatchedIgnoredErrors: false
treatPhpDocTypesAsCertain: false

paths:
Expand Down Expand Up @@ -59,3 +63,6 @@ parameters:
- rules/Configs/NodeDecorator/ServiceDefaultsCallClosureDecorator.php

- '#Parameter 1 should use "PHPStan\\BetterReflection\\Reflection\\Adapter\\ReflectionMethod" type as the only type passed to this method#'

# local use php 8.3
- identifier: typeCoverage.constantTypeCoverage
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private function refactorClassMethod(
return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

if (! $node instanceof StmtsAwareInterface) {
if (! property_exists($node, 'stmts')) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpParser\Node\Attribute;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode;
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
use Rector\BetterPhpDocParser\PhpDoc\StringNode;
Expand Down Expand Up @@ -257,10 +258,9 @@ public function refactor(Node $node): ?Class_
return $node;
}

private function shouldSkipMethod(Node\Stmt\ClassMethod $classMethod): bool
private function shouldSkipMethod(ClassMethod $classMethod): bool
{
return
!$classMethod->isPublic()
return ! $classMethod->isPublic()
|| $this->magicClassMethodAnalyzer->isUnsafeOverridden($classMethod);
}

Expand Down
5 changes: 3 additions & 2 deletions rules/Symfony42/Rector/New_/RootNodeTreeBuilderRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use PhpParser\Node\Stmt\Expression;
use PHPStan\Type\ObjectType;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\PhpParser\Enum\NodeGroup;
use Rector\PhpParser\Node\BetterNodeFinder;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
Expand Down Expand Up @@ -61,11 +62,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 @@ -13,6 +13,7 @@
use PhpParser\Node\Stmt\Expression;
use PHPStan\Type\ObjectType;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\PhpParser\Enum\NodeGroup;
use Rector\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
Expand Down Expand Up @@ -50,11 +51,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 @@ -12,7 +12,7 @@
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Stmt\Expression;
use Rector\Contract\PhpParser\Node\StmtsAwareInterface;
use Rector\PhpParser\Enum\NodeGroup;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Rector\Rector\AbstractRector;
use Rector\Symfony\Enum\SymfonyClass;
Expand Down Expand Up @@ -69,16 +69,23 @@ public function run()
]);
}

/**
* @return array<class-string<Node>>
*/
public function getNodeTypes(): array
{
return [StmtsAwareInterface::class];
return NodeGroup::STMTS_AWARE;
}

/**
* @param StmtsAwareInterface $node
* @param StmtsAware $node
*/
public function refactor(Node $node): ?StmtsAwareInterface
public function refactor(Node $node): ?Node
{
if ($node->stmts === null) {
return null;
}

if (! $this->testsNodeAnalyzer->isInTestClass($node)) {
return null;
}
Expand Down