opis / closure

Serialize closures (anonymous functions)

Home Page:https://opis.io/closure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue on parsing closure callback

and1truong opened this issue · comments

Issue on for PHP-DI/Slim-Bridge/ users when compiling the container, PHP-DI/Slim-Bridge#63, because this code https://github.com/PHP-DI/Slim-Bridge/blob/2.0.0/src/config.php#L61-L72

    'foundHandler.invoker' => function (ContainerInterface $c) {
        $resolvers = [
            new AssociativeArrayResolver,
            …
        ];
        return new Invoker(new ResolverChain($resolvers), $c);
    },

For object created without (), namespace was ignored:

Expecting:

new \Invoker\ParameterResolver\AssociativeArrayResolver\AssociativeArrayResolver

actual:

new AssociativeArrayResolver

What version of this package?

@GrahamCampbell, you can test on master.

The test case:

class ClosureTest extends \PHPUnit\Framework\TestCase
{
    public function test()
    {
        $wrapper = new SerializableClosure(
            function () {
                return new ClosureContext; // new object without `()`
            }
        );

        $code = $wrapper->getReflector()->getCode();
        $this->assertContains('Opis\Closure\ClosureContext', $code);
    }
}

@sorinsarca may you tag the master?