Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Jan 15, 2021
1 parent 770de9a commit 992fec6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Reflection/CallableReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions tests/Reflection/CallableReflectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php declare(strict_types=1);

namespace Invoker\Test\Reflection;

use Invoker\Reflection\CallableReflection;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;

class CallableReflectionTest extends TestCase
{
public function test_with_not_real_PHP_callable_array()
{
$reflection = CallableReflection::create([self::class, 'foo']);

$this->assertInstanceOf(ReflectionMethod::class, $reflection);
}

public function foo(): void
{
}
}

0 comments on commit 992fec6

Please sign in to comment.