Skip to content

array_filter callback "should return true, but returns bool / short closures issue #3261

@apfelbox

Description

@apfelbox

Bug report

array_filter(
 	$array,
	fn ($entry) => /* some boolean return value */
);

this code will produce the false positive error

Anonymous function should return false but returns bool.

(I also get it with "should return true" sometimes)

Not sure if the issue is related to instanceof usage in the callback

Code snippet that reproduces the problem

https://phpstan.org/r/bfbf5329-3ba0-412a-ae79-cdfc01d54886

Expected output

It should pass (not detect anything), as the array_filter callback should return bool and not true xor false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions