|
5 | 5 | namespace Rector\TypeDeclaration\Rector\ClassMethod; |
6 | 6 |
|
7 | 7 | use PhpParser\Node; |
| 8 | +use PHPStan\Type\Type; |
| 9 | +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; |
8 | 15 | use PhpParser\Node\Expr\Array_; |
9 | | -use PhpParser\Node\Expr\ArrayDimFetch; |
10 | 16 | use PhpParser\Node\Expr\Assign; |
| 17 | +use PhpParser\Node\Scalar\Int_; |
| 18 | +use PhpParser\Node\Stmt\Return_; |
11 | 19 | use PhpParser\Node\Expr\Variable; |
| 20 | +use Rector\Rector\AbstractRector; |
12 | 21 | use PhpParser\Node\Scalar\DNumber; |
13 | | -use PhpParser\Node\Scalar\Int_; |
14 | 22 | use PhpParser\Node\Scalar\String_; |
15 | | -use PhpParser\Node\Stmt\ClassMethod; |
16 | 23 | use PhpParser\Node\Stmt\Function_; |
17 | | -use PhpParser\Node\Stmt\Return_; |
18 | | -use PHPStan\Type\ArrayType; |
19 | | -use PHPStan\Type\FloatType; |
20 | | -use PHPStan\Type\IntegerType; |
21 | | -use PHPStan\Type\MixedType; |
22 | | -use PHPStan\Type\StringType; |
23 | | -use PHPStan\Type\Type; |
24 | | -use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; |
25 | | -use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; |
| 24 | +use PhpParser\Node\Stmt\ClassMethod; |
| 25 | +use PhpParser\Node\Expr\ArrayDimFetch; |
26 | 26 | use Rector\PhpParser\Node\BetterNodeFinder; |
27 | | -use Rector\Rector\AbstractRector; |
28 | 27 | use Rector\TypeDeclaration\NodeAnalyzer\ReturnAnalyzer; |
29 | | -use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; |
30 | 28 | use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; |
| 29 | +use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; |
| 30 | +use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; |
| 31 | +use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; |
31 | 32 |
|
32 | 33 | /** |
33 | 34 | * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddReturnDocblockForScalarArrayFromAssignsRector\AddReturnDocblockForScalarArrayFromAssignsRectorTest |
@@ -145,10 +146,6 @@ public function refactor(Node $node): ?Node |
145 | 146 | } |
146 | 147 | } |
147 | 148 |
|
148 | | - if ($scalarArrayTypes === []) { |
149 | | - return null; |
150 | | - } |
151 | | - |
152 | 149 | $firstScalarType = $scalarArrayTypes[0]; |
153 | 150 | foreach ($scalarArrayTypes as $scalarArrayType) { |
154 | 151 | if (! $firstScalarType->equals($scalarArrayType)) { |
@@ -250,7 +247,7 @@ private function resolveScalarArrayTypeForVariable(ClassMethod|Function_ $node, |
250 | 247 | return $firstType; |
251 | 248 | } |
252 | 249 |
|
253 | | - private function resolveScalarType(Node $expr): ?Type |
| 250 | + private function resolveScalarType(Expr $expr): ?Type |
254 | 251 | { |
255 | 252 | if ($expr instanceof String_) { |
256 | 253 | return new StringType(); |
|
0 commit comments