File tree 2 files changed +26
-3
lines changed
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 10
10
use ReflectionMethod ;
11
11
12
12
/**
13
- * Create a reflection object from a callable.
13
+ * Create a reflection object from a callable or a callable-like .
14
14
*
15
- * @internal
15
+ * @api
16
16
*/
17
17
class CallableReflection
18
18
{
19
19
/**
20
+ * @param callable|array|string $callable Can be a callable or a callable-like.
21
+ *
20
22
* @throws NotCallableException|ReflectionException
21
23
*/
22
- public static function create (callable $ callable ): ReflectionFunctionAbstract
24
+ public static function create ($ callable ): ReflectionFunctionAbstract
23
25
{
24
26
// Closure
25
27
if ($ callable instanceof Closure) {
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+
3
+ namespace Invoker \Test \Reflection ;
4
+
5
+ use Invoker \Reflection \CallableReflection ;
6
+ use PHPUnit \Framework \TestCase ;
7
+ use ReflectionMethod ;
8
+
9
+ class CallableReflectionTest extends TestCase
10
+ {
11
+ public function test_with_not_real_PHP_callable_array ()
12
+ {
13
+ $ reflection = CallableReflection::create ([self ::class, 'foo ' ]);
14
+
15
+ $ this ->assertInstanceOf (ReflectionMethod::class, $ reflection );
16
+ }
17
+
18
+ public function foo (): void
19
+ {
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments