Skip to content

Commit b24c9f8

Browse files
committed
fix
1 parent 11341ca commit b24c9f8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Type/Php/ArrayFilterFunctionReturnTypeReturnTypeExtension.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
106106
} elseif ($callbackArg instanceof ArrowFunction && count($callbackArg->params) > 0) {
107107
return $this->filterByTruthyValue($scope, null, $arrayArgType, $callbackArg->params[0]->var, $callbackArg->expr);
108108
} elseif ($callbackArg instanceof String_) {
109+
$funcName = self::createFunctionName($callbackArg->value);
110+
if ($funcName === null) {
111+
return new ErrorType();
112+
}
113+
109114
$keyVar = new Variable('key');
110-
$expr = new FuncCall(self::createFunctionName($callbackArg->value), [new Arg($keyVar)]);
115+
$expr = new FuncCall($funcName, [new Arg($keyVar)]);
111116
return $this->filterByTruthyValue($scope, null, $arrayArgType, $keyVar, $expr);
112117
}
113118
}
@@ -121,9 +126,14 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
121126
} elseif ($callbackArg instanceof ArrowFunction && count($callbackArg->params) > 0) {
122127
return $this->filterByTruthyValue($scope, $callbackArg->params[0]->var, $arrayArgType, $callbackArg->params[1]->var ?? null, $callbackArg->expr);
123128
} elseif ($callbackArg instanceof String_) {
129+
$funcName = self::createFunctionName($callbackArg->value);
130+
if ($funcName === null) {
131+
return new ErrorType();
132+
}
133+
124134
$itemVar = new Variable('item');
125135
$keyVar = new Variable('key');
126-
$expr = new FuncCall(self::createFunctionName($callbackArg->value), [new Arg($itemVar), new Arg($keyVar)]);
136+
$expr = new FuncCall($funcName, [new Arg($itemVar), new Arg($keyVar)]);
127137
return $this->filterByTruthyValue($scope, $itemVar, $arrayArgType, $keyVar, $expr);
128138
}
129139
}

0 commit comments

Comments
 (0)