@@ -1207,25 +1207,6 @@ private function resolveType(string $exprString, Expr $node): Type
1207
1207
}
1208
1208
}
1209
1209
1210
- foreach ($ node ->params as $ i => $ param ) {
1211
- if ($ param ->variadic ) {
1212
- $ isVariadic = true ;
1213
- }
1214
- if (!$ param ->var instanceof Variable || !is_string ($ param ->var ->name )) {
1215
- throw new ShouldNotHappenException ();
1216
- }
1217
- $ parameters [] = new NativeParameterReflection (
1218
- $ param ->var ->name ,
1219
- $ firstOptionalParameterIndex !== null && $ i >= $ firstOptionalParameterIndex ,
1220
- $ this ->getFunctionType ($ param ->type , $ this ->isParameterValueNullable ($ param ), false ),
1221
- $ param ->byRef
1222
- ? PassedByReference::createCreatesNewVariable ()
1223
- : PassedByReference::createNo (),
1224
- $ param ->variadic ,
1225
- $ param ->default !== null ? $ this ->getType ($ param ->default ) : null ,
1226
- );
1227
- }
1228
-
1229
1210
$ callableParameters = null ;
1230
1211
$ arrayMapArgs = $ node ->getAttribute (ArrayMapArgVisitor::ATTRIBUTE_NAME );
1231
1212
if ($ arrayMapArgs !== null ) {
@@ -1245,6 +1226,28 @@ private function resolveType(string $exprString, Expr $node): Type
1245
1226
1246
1227
if ($ node instanceof Expr \ArrowFunction) {
1247
1228
$ arrowScope = $ this ->enterArrowFunctionWithoutReflection ($ node , $ callableParameters );
1229
+ foreach ($ node ->params as $ i => $ param ) {
1230
+ if ($ param ->variadic ) {
1231
+ $ isVariadic = true ;
1232
+ }
1233
+ if (!$ param ->var instanceof Variable || !is_string ($ param ->var ->name )) {
1234
+ throw new ShouldNotHappenException ();
1235
+ }
1236
+ $ parameterType = $ arrowScope ->getType ($ param ->var );
1237
+ if ($ param ->variadic ) {
1238
+ $ parameterType = $ parameterType ->getIterableValueType ();
1239
+ }
1240
+ $ parameters [] = new NativeParameterReflection (
1241
+ $ param ->var ->name ,
1242
+ $ firstOptionalParameterIndex !== null && $ i >= $ firstOptionalParameterIndex ,
1243
+ $ parameterType ,
1244
+ $ param ->byRef
1245
+ ? PassedByReference::createCreatesNewVariable ()
1246
+ : PassedByReference::createNo (),
1247
+ $ param ->variadic ,
1248
+ $ param ->default !== null ? $ this ->getType ($ param ->default ) : null ,
1249
+ );
1250
+ }
1248
1251
1249
1252
if ($ node ->expr instanceof Expr \Yield_ || $ node ->expr instanceof Expr \YieldFrom) {
1250
1253
$ yieldNode = $ node ->expr ;
@@ -1316,6 +1319,28 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
1316
1319
$ usedVariables = [];
1317
1320
} else {
1318
1321
$ closureScope = $ this ->enterAnonymousFunctionWithoutReflection ($ node , $ callableParameters );
1322
+ foreach ($ node ->params as $ i => $ param ) {
1323
+ if ($ param ->variadic ) {
1324
+ $ isVariadic = true ;
1325
+ }
1326
+ if (!$ param ->var instanceof Variable || !is_string ($ param ->var ->name )) {
1327
+ throw new ShouldNotHappenException ();
1328
+ }
1329
+ $ parameterType = $ closureScope ->getType ($ param ->var );
1330
+ if ($ param ->variadic ) {
1331
+ $ parameterType = $ parameterType ->getIterableValueType ();
1332
+ }
1333
+ $ parameters [] = new NativeParameterReflection (
1334
+ $ param ->var ->name ,
1335
+ $ firstOptionalParameterIndex !== null && $ i >= $ firstOptionalParameterIndex ,
1336
+ $ parameterType ,
1337
+ $ param ->byRef
1338
+ ? PassedByReference::createCreatesNewVariable ()
1339
+ : PassedByReference::createNo (),
1340
+ $ param ->variadic ,
1341
+ $ param ->default !== null ? $ this ->getType ($ param ->default ) : null ,
1342
+ );
1343
+ }
1319
1344
$ closureReturnStatements = [];
1320
1345
$ closureYieldStatements = [];
1321
1346
$ closureExecutionEnds = [];
0 commit comments