Skip to content

[5.0] Contextual binding doesn't work with method injection. #6177

@Arhimandril

Description

@Arhimandril

Right now contextual binding resolution only works at the constructor level but it should also work with method injection. So, for example, if we have:

$app->when('PostsController')
    ->needs('PostRepositoryInterface')
    ->give('EloquentPostRepository');

then PostsController::__construct(PostRepositoryInterface $posts) will resolve the dependency correctly but PostsController::store(PostRepositoryInterface $posts) will only look for a non-contextual binding and will fail to resolve.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions