1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
<?php
/* ===========================================================================
* Copyright (c) 2018-2021 Zindex Software
*
* Licensed under the MIT License
* =========================================================================== */
namespace Opis\Closure\Test;
use Closure;
use Opis\Closure\ReflectionClosure;
use Foo\{
Bar as Baz,
};
class ReflectionClosure4Test extends \PHPUnit\Framework\TestCase
{
protected function c(Closure $closure)
{
$r = new ReflectionClosure($closure);
return $r->getCode();
}
public function testResolveArguments()
{
$f1 = function (object $p){};
$e1 = 'function (object $p){}';
$this->assertEquals($e1, $this->c($f1));
}
public function testResolveReturnType()
{
$f1 = function (): object{};
$e1 = 'function (): object{}';
$this->assertEquals($e1, $this->c($f1));
}
public function testTrailingComma()
{
$f1 = function (): Baz {};
$e1 = 'function (): \Foo\Bar {}';
$this->assertEquals($e1, $this->c($f1));
}
}
|