|
5 | 5 | namespace Rector\TypeDeclaration\Rector\ClassMethod; |
6 | 6 |
|
7 | 7 | use PhpParser\Node; |
8 | | -use PHPStan\Type\Type; |
9 | 8 | use PhpParser\Node\Expr; |
10 | | -use PHPStan\Type\ArrayType; |
11 | | -use PHPStan\Type\FloatType; |
12 | | -use PHPStan\Type\MixedType; |
13 | | -use PHPStan\Type\StringType; |
14 | | -use PHPStan\Type\IntegerType; |
15 | 9 | use PhpParser\Node\Expr\Array_; |
| 10 | +use PhpParser\Node\Expr\ArrayDimFetch; |
16 | 11 | use PhpParser\Node\Expr\Assign; |
17 | | -use PhpParser\Node\Scalar\Int_; |
18 | | -use PhpParser\Node\Stmt\Return_; |
19 | 12 | use PhpParser\Node\Expr\Variable; |
20 | | -use Rector\Rector\AbstractRector; |
21 | 13 | use PhpParser\Node\Scalar\DNumber; |
| 14 | +use PhpParser\Node\Scalar\Int_; |
22 | 15 | use PhpParser\Node\Scalar\String_; |
23 | | -use PhpParser\Node\Stmt\Function_; |
24 | 16 | use PhpParser\Node\Stmt\ClassMethod; |
25 | | -use PhpParser\Node\Expr\ArrayDimFetch; |
| 17 | +use PhpParser\Node\Stmt\Function_; |
| 18 | +use PhpParser\Node\Stmt\Return_; |
| 19 | +use PHPStan\Type\ArrayType; |
| 20 | +use PHPStan\Type\FloatType; |
| 21 | +use PHPStan\Type\IntegerType; |
| 22 | +use PHPStan\Type\MixedType; |
| 23 | +use PHPStan\Type\StringType; |
| 24 | +use PHPStan\Type\Type; |
| 25 | +use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; |
| 26 | +use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; |
26 | 27 | use Rector\PhpParser\Node\BetterNodeFinder; |
| 28 | +use Rector\Rector\AbstractRector; |
27 | 29 | use Rector\TypeDeclaration\NodeAnalyzer\ReturnAnalyzer; |
28 | | -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; |
29 | | -use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; |
30 | 30 | use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; |
31 | | -use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; |
| 31 | +use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; |
32 | 32 |
|
33 | 33 | /** |
34 | 34 | * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddReturnDocblockForScalarArrayFromAssignsRector\AddReturnDocblockForScalarArrayFromAssignsRectorTest |
@@ -123,7 +123,6 @@ public function refactor(Node $node): ?Node |
123 | 123 |
|
124 | 124 | $returnsScoped = $this->betterNodeFinder->findReturnsScoped($node); |
125 | 125 |
|
126 | | - |
127 | 126 | if (! $this->returnAnalyzer->hasOnlyReturnWithExpr($node, $returnsScoped)) { |
128 | 127 | return null; |
129 | 128 | } |
@@ -191,7 +190,10 @@ private function resolveScalarArrayTypeForVariable(ClassMethod|Function_ $node, |
191 | 190 | $arrayHasDimAssigns = false; |
192 | 191 |
|
193 | 192 | foreach ($assigns as $assign) { |
194 | | - if ($assign->var instanceof Variable && $this->isName($assign->var, $variableName) && ($assign->expr instanceof Array_ && $assign->expr->items === [])) { |
| 193 | + if ($assign->var instanceof Variable && $this->isName( |
| 194 | + $assign->var, |
| 195 | + $variableName |
| 196 | + ) && ($assign->expr instanceof Array_ && $assign->expr->items === [])) { |
195 | 197 | $arrayHasInitialized = true; |
196 | 198 | continue; |
197 | 199 | } |
|
0 commit comments