Skip to content

Conversation

@cs278
Copy link
Contributor

@cs278 cs278 commented Jan 11, 2020

@ondrejmirtes
Copy link
Member

Hi, can you sum up in your own words what was wrong with the previous code and why does your work?

@cs278
Copy link
Contributor Author

cs278 commented Jan 11, 2020

/** @param int[] $input */ function (array $input) { $i = 0; // $input[$i] is int \assert($input[$i] === 1); // $input[$i] is 1 $i++; // $input[$i] is 1 (without this PR) // $input[$i] is int (with this PR) };

PHPStan was only extracting the first variable referenced so in the string $input[$i] it would only find $input which is not being assigned so is not unset. My change results in both $input and $i being found, $i is being assigned so the known value of $input[$i] is unset.

@ondrejmirtes
Copy link
Member

Of course, nice find! Thank you.

@ondrejmirtes ondrejmirtes merged commit e81d732 into phpstan:master Jan 11, 2020
@cs278 cs278 deleted the issue-2822 branch January 11, 2020 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants