Skip to content
Discussion options

You must be logged in to vote

That's not how it supposed to work. Maybe this example might illuminate things for you:

class Hello {
    public function say(string $something = null): void {
        dump('Hello '.($something ?? 'space'));
    }
}

(new Hello())->say();

(new Hello())->say('humans');

app()->bindMethod([Hello::class, 'say'], function (Hello $instance, $app) {
    // Custom implementation for the process() method
    return $instance->say('world');
});

if(app()->hasMethodBinding(Hello::class.'@say')) {
    app()->callMethodBinding(Hello::class.'@say', new Hello());
}

A reallife example in laravel would be: https://laravel.com/docs/10.x/queues#handle-method-dependency-injection

It's used to override the …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aimonext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants