rdlowrey/auryn

No definition available to provision typeless parameter

Closed this issue · 6 comments

I am getting the error:

No definition available to provision typeless parameter $errorHandler at position 0

I am using the following code to define the class that is causing the error:

        $injector->delegate('errorHandler', function () use ($injector) {
            return $injector->make(BugsnagExceptionHandler::class, [
                ':errorHandler' => $injector->make(Error::class),
                ':bugsnag' => $injector->make(Client::class),
            ]);
        });

I have tried it with a colon : and without, yet it keeps telling me the error.

According to the documentation, this should work. What am I doing wrong here?

Delegate accepts types as first parameters, no parameter names. You need to use define.

No, I'm trying to 'delegate' the creation of a keyword to a function. In that function, I am using 'make', so I think you've misread the code.

This is perfectly valid code according to the documentation.

I have got this to work using the following, but something seems off:

        $injector->delegate('errorHandler', function () use ($injector) {
            $injector->define(BugsnagExceptionHandler::class, [
                ':errorHandler' => $injector->make(Error::class),
                ':bugsnag' => $injector->make(Client::class),
            ]);
            return $injector->make(BugsnagExceptionHandler::class);
        });

Could you please provide a full (runnable) example?

I wish I could, it's all a little convoluted, and I'm sprinting towards an MVP. When I get it done, I will do my best.

Closing due to inactivity.

If anyone has similar issue please provide more info.