Skip to content

Commit aea9099

Browse files
committed
static fixes
1 parent 2ac4572 commit aea9099

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

phpstan.neon

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,12 @@ parameters:
376376
-
377377
message: '#Property Rector\\PhpParser\\NodeTraverser\\AbstractImmutableNodeTraverser\:\:\$visitors \(list<PhpParser\\NodeVisitor>\) does not accept array<int\|string, PhpParser\\NodeVisitor>#'
378378
path: src/PhpParser/NodeTraverser/AbstractImmutableNodeTraverser.php
379+
380+
# special check for stmts aware virtual interface
381+
-
382+
path: src/PhpParser/NodeTraverser/RectorNodeTraverser.php
383+
identifier: symplify.forbiddenFuncCall
384+
- '#Parameter 1 should use "Rector\\Contract\\PhpParser\\Node\\StmtsAwareInterface" type as the only type passed to this method#'
385+
- '#Parameter \#1 \$stmtsAware of method (.*?) expects Rector\\Contract\\PhpParser\\Node\\StmtsAwareInterface#'
386+
387+
- '#Method (.*?) should return Rector\\Contract\\PhpParser\\Node\\StmtsAwareInterface\|null but returns (.*?)\|null#'

rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Rector\Rector\AbstractRector;
2626
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
2727
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
28+
use Webmozart\Assert\Assert;
2829

2930
/**
3031
* @see \Rector\Tests\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector\SimplifyUselessVariableRectorTest
@@ -157,11 +158,13 @@ public function refactor(Node $node): ?Node
157158
* @return StmtsAwareInterface
158159
*/
159160
private function processSimplifyUselessVariable(
160-
Stmt|Closure $stmtsAware,
161+
\PhpParser\Node $stmtsAware,
161162
Return_ $return,
162163
Assign|AssignOp $assign,
163164
int $key
164-
): Stmt|Closure|null {
165+
): \PhpParser\Node|null {
166+
Assert::propertyExists($stmtsAware, 'stmts');
167+
165168
if (! $assign instanceof Assign) {
166169
$binaryClass = $this->assignAndBinaryMap->getAlternative($assign);
167170
if ($binaryClass === null) {

rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getNodeTypes(): array
6363
/**
6464
* @param StmtsAwareInterface $node
6565
*/
66-
public function refactor(Node $node): ?Stmt
66+
public function refactor(Node $node): ?\PhpParser\Node
6767
{
6868
foreach ((array) $node->stmts as $key => $stmt) {
6969
if (! $stmt instanceof If_) {

src/NodeManipulator/StmtsManipulator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Rector\PhpDocParser\NodeTraverser\SimpleCallableNodeTraverser;
2020
use Rector\PhpParser\Comparing\NodeComparator;
2121
use Rector\PhpParser\Node\BetterNodeFinder;
22+
use Webmozart\Assert\Assert;
2223

2324
final readonly class StmtsManipulator
2425
{
@@ -77,8 +78,10 @@ function (Node $node) use (&$stmts): null {
7778
/**
7879
* @param StmtsAwareInterface $stmtsAware
7980
*/
80-
public function isVariableUsedInNextStmt(Stmt|Closure $stmtsAware, int $jumpToKey, string $variableName): bool
81+
public function isVariableUsedInNextStmt(Node $stmtsAware, int $jumpToKey, string $variableName): bool
8182
{
83+
Assert::propertyExists($stmtsAware, 'stmts');
84+
8285
if ($stmtsAware->stmts === null) {
8386
return false;
8487
}

0 commit comments

Comments
 (0)