1--TEST--
2Closures via getParameters() and getDeclaringFunction() calling reflection_method_factory() with an internal object being set
3--FILE--
4<?php
5
6class A {}
7class B extends A {}
8
9$closure = function($op1, $op2 = 0): self { };
10
11$b = new B();
12$fn = $closure->bindTo($b, B::class);
13
14const CLOSURE_NAME = '{closure:' . __FILE__ . ':6}';
15
16$rClosure = new ReflectionFunction($fn);
17var_dump($rClosure->name == CLOSURE_NAME);
18
19$params = $rClosure->getParameters();
20unset ($rClosure);
21$closureFromParam = $params[0]->getDeclaringFunction();
22var_dump($closureFromParam::class);
23var_dump($closureFromParam->name == CLOSURE_NAME);
24
25$rClass = new ReflectionClass($b);
26$rMethods = $rClass->getMethods();
27var_dump($rMethods);
28
29try {
30    $rMethod = new ReflectionMethod($b, CLOSURE_NAME);
31    var_dump($rMethod);
32} catch (\Throwable $e) {
33    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
34}
35
36?>
37--EXPECTF--
38bool(true)
39string(16) "ReflectionMethod"
40bool(true)
41array(0) {
42}
43ReflectionException: Method B::{closure:%s:6}() does not exist
44