You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Passing reference return value of function into pass-by-reference parameter is broken #13711
When I have a function that returns a reference and I pass the return-value of that function to a parameter that expects a reference I get a false-positive error
Parameter #1 $array of function reset is passed by reference, so it expects variables only.
class Foo
{
/** @var array<string> */
private array $array = [];
/** @return array<string> */
public function &getList(): array
{
return $this->array;
}
public function rewind(): void
{
reset($this->getList());
}
}
getList returns a pointer to the array $array. But passing that pointer to reset works in PHP (see 3v4l.org example) but is considered broken by PHPStan.
Is there some additional magical annotation I need to pass to make this work?
Activity
Add regression test for #13711
Add regression test for #13711
Updated PHPStan to commit 1f6cf23dfc54a22860c35a3e8fa736ba95861281
heiglandreas commentedon Feb 12, 2026
Did I recently mention that you rock, @ondrejmirtes?
github-actions commentedon Mar 16, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.