Skip to content

Commit 5f40ddb

Browse files
committed
add back return by array shape test
1 parent cb5ba1d commit 5f40ddb

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector\Fixture;
4+
5+
class ReturnByArrayShapeType
6+
{
7+
/**
8+
* @param array<int, array{bar: int}> $values
9+
*/
10+
private function foo(array $values): void
11+
{
12+
$bars = array_map(fn($value) => $value['bar'], $values);
13+
}
14+
}
15+
16+
?>
17+
-----
18+
<?php
19+
20+
namespace Rector\Tests\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector\Fixture;
21+
22+
class ReturnByArrayShapeType
23+
{
24+
/**
25+
* @param array<int, array{bar: int}> $values
26+
*/
27+
private function foo(array $values): void
28+
{
29+
$bars = array_map(fn($value): int => $value['bar'], $values);
30+
}
31+
}
32+
33+
?>

rules/TypeDeclaration/Rector/FuncCall/AddArrowFunctionParamArrayWhereDimFetchRector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ private function resolveDimFetchVariableNames(Closure|ArrowFunction $closureExpr
149149
if ($arrayDimFetch->var instanceof Variable) {
150150
$type = $this->nodeTypeResolver->getNativeType($arrayDimFetch->var);
151151

152-
// skip string values
153-
if (! $arrayDimFetch->dim instanceof String_ && ($type->isString()->yes() || $type->isString()->maybe())) {
152+
if ($type->isString()->yes()) {
154153
continue;
155154
}
156155

0 commit comments

Comments
 (0)