How to get autocomplete for magic method __call - PHP Editors
autocomplete, code-formatting, editor, php
Solution
you can use `@method` phpdoc tag to get autocomplete for magic methods
here is a code example for you:
<?php
/**
* Class Controller
* @method mixed foo() foo($parametersHere) explanation of the function
*/
Class Controller {
public function __call($function, $arguments) {
if($function == 'foo') {
// some logic here
}
}
}
This should work well
Problem
we can have an autocomplete in PHP Editors for a class like: ``` <?php /** * Class Controller * @property foo foo */ class Controller { public function bar() { $this->foo-> // autocomplete here } } class foo() { } ``` but if i want an auto complete for a magic method like `__call` how is that possible example below: ``` <?php Class Controller { public function __call($function, $arguments) { if($function == 'foo') { // some logic here } } } Class Home extends Controller { public function somefunction() { $this-> // should have an autocomplete of foo } } ``` any idea how could this be achieved to configure auto-complete in PHP Editors I use PHP-Storm if there is something specific