@@ -39,10 +39,6 @@ final class WrappedListener implements ListenerInterface
39
39
public function __construct ($ listener )
40
40
{
41
41
$ this ->listener = $ listener ;
42
-
43
- if (null === self ::$ hasVarDumper ) {
44
- self ::$ hasVarDumper = class_exists (ClassStub::class);
45
- }
46
42
}
47
43
48
44
/**
@@ -76,8 +72,25 @@ public function getWrappedListener()
76
72
77
73
public function getInfo (): array
78
74
{
79
- if (null === $ this ->stub ) {
80
- $ this ->stub = self ::$ hasVarDumper ? new ClassStub (\get_class ($ this ->listener )) : \get_class ($ this ->listener );
75
+ if (null !== $ this ->stub ) {
76
+ // no-op
77
+ } elseif (self ::$ hasVarDumper ?? self ::$ hasVarDumper = class_exists (ClassStub::class)) {
78
+ $ this ->stub = ClassStub::wrapCallable ($ this ->listener );
79
+ } elseif (\is_array ($ this ->listener )) {
80
+ $ this ->stub = (\is_object ($ this ->listener [0 ]) ? \get_class ($ this ->listener [0 ]) : $ this ->listener [0 ]).':: ' .$ this ->listener [1 ];
81
+ } elseif ($ this ->listener instanceof \Closure) {
82
+ $ r = new \ReflectionFunction ($ this ->listener );
83
+ if (false !== strpos ($ r ->name , '{closure} ' )) {
84
+ $ this ->stub = 'closure ' ;
85
+ } elseif ($ class = $ r ->getClosureScopeClass ()) {
86
+ $ this ->stub = $ class ->name .':: ' .$ r ->name ;
87
+ } else {
88
+ $ this ->stub = $ r ->name ;
89
+ }
90
+ } elseif (\is_string ($ this ->listener )) {
91
+ $ this ->stub = $ this ->listener ;
92
+ } else {
93
+ $ this ->stub = \get_class ($ this ->listener ).'::__invoke ' ;
81
94
}
82
95
83
96
return [
0 commit comments