Skip to content

Support call_user_func_array#5286

Merged
VincentLanglet merged 5 commits intophpstan:2.1.xfrom
VincentLanglet:callUserFuncArray
Mar 24, 2026
Merged

Support call_user_func_array#5286
VincentLanglet merged 5 commits intophpstan:2.1.xfrom
VincentLanglet:callUserFuncArray

Conversation

@VincentLanglet
Copy link
Copy Markdown
Contributor

@VincentLanglet VincentLanglet commented Mar 23, 2026

Extracted from #5282

This copy the existing behavior of call_user_func but for call_user_func_array.

Closes phpstan/phpstan#5942
Closes phpstan/phpstan#5934

@VincentLanglet VincentLanglet requested a review from staabm March 23, 2026 22:24
@VincentLanglet VincentLanglet marked this pull request as ready for review March 23, 2026 22:24
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

Comment on lines +146 to +149
$calledOnType = $scope->getType($callbackArg->value);
if (!$calledOnType->isCallable()->yes()) {
return null;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the following loop might return early, we could move this 4 lines nearer to the usage in line 174 to prevent unnecessary work

Comment on lines 1130 to 1132
}
$this->analyse([__DIR__ . '/data/call-user-func-array.php'], $errors);
$this->analyse([__DIR__ . '/data/call-user-func-array-named-args.php'], $errors);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is call-user-func-array.php no longer tested in this rule?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just renamed the initial call-user-func-array.php file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interessting.. the PR does not include a file which got renamed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I renamed call-user-func-array and recreated a new call-user-func-array.

Git consider call-user-func-array-named-args new, and the other as modified

@staabm
Copy link
Copy Markdown
Contributor

staabm commented Mar 24, 2026

issue-bot shows a new error with phpstan/phpstan#8214 .. might indicate we miss splat operator support...?

@VincentLanglet
Copy link
Copy Markdown
Contributor Author

issue-bot shows a new error with phpstan/phpstan#8214 .. might indicate we miss splat operator support...?

The phpdoc of the snippet is

@param Closure(mixed...):T $createState Create the state
@phpstan-param Closure(mixed,mixed,mixed,mixed,mixed,mixed):T $createState

so the error is legit

@VincentLanglet VincentLanglet requested a review from staabm March 24, 2026 08:34
@VincentLanglet VincentLanglet merged commit b6c48a0 into phpstan:2.1.x Mar 24, 2026
651 of 654 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants