This is about PHP | Php Inspections (EA Extended) | Code Style | Implicit magic method calls inspection.
TL;DR: I want to disable it for __invoke method calls.
Here is a (I sure not complete) list of ways to call __invoke of object:
$invokable = $this->searchHistoryWriter;
$invokable($this->filter);
\call_user_func([$this->searchHistoryWriter, '__invoke'], $this->filter);
$this->searchHistoryWriter->__invoke($this->filter);
Lets examine they one-by-one:
Problems:
($this->searchHistoryWriter)($this->filter)__invoke method of invokable directly 鈥斅爌hpstorm will point you to class property__invoke (tracked in https://youtrack.jetbrains.com/issue/WI-34223)Pros:
PHP | Type compatibility | Parameter type inspection works (but doesn't work for ($invokable)($parameter) call. Looks like I have to open issue in jetbrains tracker)call_user_funcProblems:
PHP | Type compatibility | Parameter type doesn't work__invoke and probably should be marked by this inspection? 馃 Pros:
__invoke method directly__invoke usages__invoke direct callProblems:
Pros:
parameter type inspection worksSo what I propose:聽igone __invoke direct calls by this inspection or add ability to disable it only for __invoke check in inspection settings.
If you use __invoke directly, why not have a real method name instead of using __invoke?
I rethinked this and found that I should require callables, so they are allowed to have no __invoke method.
Most helpful comment
If you use
__invokedirectly, why not have a real method name instead of using__invoke?