Skip to content

Conversation

@schlndh
Copy link
Contributor

@schlndh schlndh commented Oct 11, 2024

Fixes: https://3v4l.org/QKHrt (https://phpstan.org/r/357b09e6-80b7-4c50-97db-35995ff4cb67)

Unfortunately, since it depends on values of multiple variables at the same time (which may be correlated), there will be false positives like this:

if (rand()) { $a = [1]; $b = [2]; } else { $a = [1, 2]; $b = [3, 4]; } array_map(null, $a, $b);

But I guess it's better to be safe than sorry. I at least added support for array_map(null, $a, $a).

public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): ?Type
{
if (count($functionCall->getArgs()) < 2) {
$numArgs = count($functionCall->getArgs());
Copy link

Choose a reason for hiding this comment

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

By the way, i see multiple call function $functionCall->getArgs(). Can refactor?

@ondrejmirtes ondrejmirtes merged commit d0e7aca into phpstan:1.12.x Nov 12, 2024
474 of 502 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@schlndh schlndh deleted the fix-arrayMapZip branch November 12, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants