Skip to content

Commit b3e556c

Browse files
authored
[TypeDeclaration] Handle crash on direct callable without params on AddArrayFunctionClosureParamTypeRector (#7131)
* [TypeDeclaration] Handle crash on direct callable with single arg on AddArrayFunctionClosureParamTypeRector * fixture * fix
1 parent a357fdb commit b3e556c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\AddArrayFunctionClosureParamTypeRector\Fixture;
4+
5+
final class SkipDirectCallableWithoutParams
6+
{
7+
public function getRandomData(): array
8+
{
9+
return array_map(fn (): int => random_int(1, 100), range(0, 23));
10+
}
11+
}

rules/TypeDeclaration/Rector/FuncCall/AddArrayFunctionClosureParamTypeRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ public function refactor(Node $node): ?Node
9292
continue;
9393
}
9494

95+
if (count($firstArgExpr->getParams()) !== 1) {
96+
continue;
97+
}
98+
9599
$arrowFunction = $firstArgExpr;
96100
$arrowFunctionParam = $arrowFunction->getParams()[0];
97101

0 commit comments

Comments
 (0)