New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UndefinedVariable "$__fake_offset_var__" #7164
Comments
I found these snippets: https://psalm.dev/r/cccdb532d0<?php
function bar(array $a): array {
return $a;
}
/**
* @param array[] $x
*
* @return array[]
*/
function foo(array $x): array {
return array_map(
"array_merge",
array_map(
"bar",
$x
),
$x
);
}
https://psalm.dev/r/c114e494ca<?php
class Test {
/** @param array[] $x */
public function foo(array $x): array {
return array_map(
"array_merge",
array_map(
[$this, "bar"],
$x
),
$x
);
}
public function bar(array $a): array {
return $a;
}
}
|
Best I can tell, this is due to the nested Using a temporary variable is another workaround: https://psalm.dev/r/b582aba92e |
I found these snippets: https://psalm.dev/r/b582aba92e<?php
function bar(array $a): array {
return $a;
}
/**
* @param array[] $x
*
* @return array[]
*/
function foo(array $x): array {
$tmp = array_map(
"bar",
$x
);
return array_map(
"array_merge",
$tmp,
$x
);
}
|
Ok, I'm convinced the |
Thank you for making Psalm such an amazing analyzer.
I might have found a bug but I'm not sure.
https://psalm.dev/r/cccdb532d0
https://psalm.dev/r/c114e494ca
The error goes away when I use an anonymous function as the callable for the inner array_map.
The text was updated successfully, but these errors were encountered: