|
37 | 37 | use PHPStan\Reflection\ParametersAcceptor; |
38 | 38 | use PHPStan\Reflection\ParametersAcceptorSelector; |
39 | 39 | use PHPStan\Reflection\PassedByReference; |
| 40 | +use PHPStan\Reflection\Php\DummyParameter; |
40 | 41 | use PHPStan\Reflection\Php\PhpFunctionFromParserNodeReflection; |
41 | 42 | use PHPStan\Reflection\Php\PhpMethodFromParserNodeReflection; |
42 | 43 | use PHPStan\Reflection\PropertyReflection; |
@@ -1281,7 +1282,25 @@ private function resolveType(Expr $node): Type |
1281 | 1282 | $returnType = TypehintHelper::decideType($this->getFunctionType($node->returnType, false, false), $returnType); |
1282 | 1283 | } |
1283 | 1284 | } else { |
1284 | | -$closureScope = $this->enterAnonymousFunctionWithoutReflection($node); |
| 1285 | +$callableParameters = null; |
| 1286 | +$arg = $node->getAttribute('parent'); |
| 1287 | +if ($arg instanceof Arg) { |
| 1288 | +$funcCall = $arg->getAttribute('parent'); |
| 1289 | +$argOrder = $arg->getAttribute('expressionOrder'); |
| 1290 | +if ($funcCall instanceof FuncCall && $funcCall->name instanceof Name) { |
| 1291 | +$functionName = $this->reflectionProvider->resolveFunctionName($funcCall->name, $this); |
| 1292 | +if ( |
| 1293 | +$functionName === 'array_map' |
| 1294 | +&& $argOrder === 0 |
| 1295 | +&& isset($funcCall->args[1]) |
| 1296 | +) { |
| 1297 | +$callableParameters = [ |
| 1298 | +new DummyParameter('item', $this->getType($funcCall->args[1]->value)->getIterableValueType(), false, PassedByReference::createNo(), false, null), |
| 1299 | +]; |
| 1300 | +} |
| 1301 | +} |
| 1302 | +} |
| 1303 | +$closureScope = $this->enterAnonymousFunctionWithoutReflection($node, $callableParameters); |
1285 | 1304 | $closureReturnStatements = []; |
1286 | 1305 | $closureYieldStatements = []; |
1287 | 1306 | $closureExecutionEnds = []; |
|
0 commit comments