Skip to content

Commit 85da029

Browse files
authored
Fix compatibility with latest phpstan patch 2.1.x-dev (#7997)
1 parent 5be8f82 commit 85da029

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

rules/TypeDeclaration/Rector/ArrowFunction/AddArrowFunctionReturnTypeRector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Rector\TypeDeclaration\Rector\ArrowFunction;
66

77
use PhpParser\Node;
8+
use PhpParser\Node\Expr\ArrayDimFetch;
89
use PhpParser\Node\Expr\ArrowFunction;
910
use PHPStan\Type\MixedType;
1011
use PHPStan\Type\NullType;
@@ -58,7 +59,10 @@ public function refactor(Node $node): ?Node
5859
return null;
5960
}
6061

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);
6266

6367
// not valid to add explicit type in PHP
6468
if ($type->isVoid()->yes()) {

0 commit comments

Comments
 (0)