We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5be8f82 commit 85da029Copy full SHA for 85da029
1 file changed
rules/TypeDeclaration/Rector/ArrowFunction/AddArrowFunctionReturnTypeRector.php
@@ -5,6 +5,7 @@
5
namespace Rector\TypeDeclaration\Rector\ArrowFunction;
6
7
use PhpParser\Node;
8
+use PhpParser\Node\Expr\ArrayDimFetch;
9
use PhpParser\Node\Expr\ArrowFunction;
10
use PHPStan\Type\MixedType;
11
use PHPStan\Type\NullType;
@@ -58,7 +59,10 @@ public function refactor(Node $node): ?Node
58
59
return null;
60
}
61
- $type = $this->nodeTypeResolver->getNativeType($node->expr);
62
+ // to allow array shape
63
+ $type = $node->expr instanceof ArrayDimFetch
64
+ ? $this->getType($node->expr)
65
+ : $this->nodeTypeResolver->getNativeType($node->expr);
66
67
// not valid to add explicit type in PHP
68
if ($type->isVoid()->yes()) {
0 commit comments