Skip to content

Commit 47ec049

Browse files
committed
Proberly describe wrapped CallableProxy instances
1 parent fc96501 commit 47ec049

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/CallableProxy.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public function toString(): string
113113
}
114114
}
115115

116+
if ($this->callable instanceof self) {
117+
return $this->callable->toString();
118+
}
119+
116120
return sprintf('%s::__invoke()', get_class($this->callable));
117121
}
118122

tests/Unit/CachedCallableProxyTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function dataProviderSelfDescribing(): array
6868
[ Closure::bind(function () {}, new Exception(), null), [], 'Exception::{closure}()' ],
6969
[ Closure::bind(function () {}, new Exception(), InvocableClass::class), [], 'Exception::{closure}()' ],
7070
[ Closure::bind(function () {}, null, InvocableClass::class), [], InvocableClass::class . '::{closure}()' ],
71+
[ new CachedCallableProxy('count'), [], 'count()' ],
7172
[ new InvocableClass(), [], InvocableClass::class . '::__invoke()' ],
7273
];
7374
}

tests/Unit/CallableProxyTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function dataProviderSelfDescribing(): array
6868
[ Closure::bind(function () {}, new Exception(), null), [], 'Exception::{closure}()' ],
6969
[ Closure::bind(function () {}, new Exception(), InvocableClass::class), [], 'Exception::{closure}()' ],
7070
[ Closure::bind(function () {}, null, InvocableClass::class), [], InvocableClass::class . '::{closure}()' ],
71+
[ new CallableProxy('count'), [], 'count()' ],
7172
[ new InvocableClass(), [], InvocableClass::class . '::__invoke()' ],
7273
];
7374
}

0 commit comments

Comments
 (0)