Closed mxr576 closed 2 years ago
😩 You're right. Detecting static
declarations is a lot harder than it looks, I guess. Here's a minimal test case I came up with which actually produces a bunch of weird errors:
function function_with_static_closure_inside_array_map($account, $getTeamsByUserQuery) {
$developer_team_ids = array_map(
static function (GroupInterface $group) {
return (int) $group->id();
},
($getTeamsByUserQuery)((int) $account->id())
);
return $developer_team_ids;
}
2 | WARNING | Unused static variable $account.
2 | WARNING | Unused static variable $getTeamsByUserQuery.
7 | WARNING | Redeclaration of function parameter $getTeamsByUserQuery as static variable.
7 | WARNING | Redeclaration of function parameter $account as static variable.
Thanks, this was quick 😉
I believe there is still a regression related to static variables even after #272 and #275.
The following code leads to an invalid concern raised by the checker on the last line in the example.