How to get autocomplete for magic method __call - PHP Editors
Asked Answered
K

1

7

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

Koziol answered 12/5, 2014 at 9:48 Comment(2)
manual.phpdoc.org/HTMLframesConverter/default/phpDocumentor/…Ambry
great! Thanks @MarkBaker, could you post it as an answer so that i can accept itKoziol
C
8

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

Carnay answered 12/5, 2014 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.