Skip to content

Question - Invocation Syntax #82

Open
@TheDigitalOrchard

Description

@TheDigitalOrchard

This is just a minor question, but I'm curious about the syntax being used to invoke objects as methods.

Example:

$outputs = $this->model->__invoke($modelInputs);

Is it intentional to be calling __invoke(...) directly, rather than this:

$outputs = $this->model($modelInputs);

Is there evidence that a direct method call is more efficient than the engine figuring out it needs to route the request to a magic method?

I'm asking because PHP docs specifically say this:

Caution All methods names starting with __ are reserved by PHP. Therefore, it is not recommended to use such method names unless overriding PHP's behavior.

which can be interpreted as the only time that you'd manually call a magic method was within the class that is overriding PHP's behaviour, not from outside the class definition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions