Skip to content

Where should I document Closure and ==? #4804

@chx

Description

@chx

I have commit rights to the repo so I just need guidance where should I document two closures made from the same callable are equal but not identical:

$x = new class {
    function test() {}
};
$a = [$x, 'test'];
$b = Closure::fromCallable($a);
$c = Closure::fromCallable($a);
var_dump($b == $c);  // TRUE
var_dump($b === $c); // FALSE

This is used in Symfony eventdispatcher: if ($v === $listener || ($listener instanceof \Closure && $v == $listener)) { I guess because this makes removeListener($foo(..)) work

I really have no idea where is it best to document this. https://www.php.net/manual/en/language.oop5.object-comparison.php ? Closure::fromCallable ? first class functions?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions