The test included is quite comprehensive. Cheers Joe
On Friday, 9 July 2021, Larry Garfield <la...@garfieldtech.com> wrote: > On Fri, Jul 9, 2021, at 4:51 AM, Nikita Popov wrote: > > On Fri, Jul 9, 2021 at 10:45 AM Joe Watkins <krak...@php.net> wrote: > > > > > Morning internals, > > > > > > While discussing some of the details of the first class callable RFC, > it > > > became apparent that fake closures (created by Closure::fromCallable) > are > > > not currently comparable in a useful way. > > > > > > Although this is not directly related to the first class callable > feature, > > > it's likely that the proliferation of this kind of code will follow, > so now > > > seems like a good time to fix the problem. > > > > > > https://github.com/php/php-src/pull/7223 > > > > > > Any objections to merging that in master ? > > > > > > > To clarify: What this implements is that > > > > $strlen1 = Closure::fromCallable('strlen'); > > $strlen2 = Closure::fromCallable('strlen'); > > var_dump($strlen1 == $strlen2); > > // bool(true) with this patch, previously bool(false) > > > > The same would also apply to the first-class callable syntax, i.e. after > > this patch strlen(...) == strlen(...) would return true. > > > > Regards, > > Nikita > > Seems reasonable on the surface. My main question is how far that > extends. Does it work *only* for Closure::fromCallable()/FCC syntax? What > if the argument is not a string? How deep does the comparison go for, say, > objects and methods? > > class C { > public function beep(string $a): string { return $a . 'beep'; } > } > > $c1 = new C(); > $c2 = new C(); > > $strlen1 = Closure::fromCallable([$c1, 'beep']); > $strlen1b = Closure::fromCallable([$c1, 'beep']); > $strlen2 = Closure::fromCallable([$c2, 'beep']); > > // What do these do? > var_dump($strlen1 == $strlen1b); > var_dump($strlen1 == $strlen2); > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > >