From 992fec6c56f2d1ad1ad5fee28267867c85bfb8f9 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 15 Jan 2021 11:25:40 +0100 Subject: [PATCH] Solve https://github.com/PHP-DI/PHP-DI/issues/746 --- src/Reflection/CallableReflection.php | 8 +++++--- tests/Reflection/CallableReflectionTest.php | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 tests/Reflection/CallableReflectionTest.php diff --git a/src/Reflection/CallableReflection.php b/src/Reflection/CallableReflection.php index 676f302..c2130a7 100644 --- a/src/Reflection/CallableReflection.php +++ b/src/Reflection/CallableReflection.php @@ -10,16 +10,18 @@ use ReflectionMethod; /** - * Create a reflection object from a callable. + * Create a reflection object from a callable or a callable-like. * - * @internal + * @api */ class CallableReflection { /** + * @param callable|array|string $callable Can be a callable or a callable-like. + * * @throws NotCallableException|ReflectionException */ - public static function create(callable $callable): ReflectionFunctionAbstract + public static function create($callable): ReflectionFunctionAbstract { // Closure if ($callable instanceof Closure) { diff --git a/tests/Reflection/CallableReflectionTest.php b/tests/Reflection/CallableReflectionTest.php new file mode 100644 index 0000000..6317737 --- /dev/null +++ b/tests/Reflection/CallableReflectionTest.php @@ -0,0 +1,21 @@ +assertInstanceOf(ReflectionMethod::class, $reflection); + } + + public function foo(): void + { + } +}