如何获得魔术方法的自动完成__call - PHP编辑器

时间:2014-05-12 09:48:26

标签: php autocomplete editor code-formatting

我们可以在PHP编辑器中使用类似的自动完成功能:

<?php

/**
 * Class Controller
 * @property foo foo
*/
class Controller {
   public function bar() {
      $this->foo-> // autocomplete here
   }
}

class foo() {
}

但如果我想要一个像__call这样的魔术方法的自动完成,那该怎么可能

以下示例:

<?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
   }
}

任何想法如何在PHP编辑器中配置自动完成

如果有特定的

,我会使用PHP-Storm

1 个答案:

答案 0 :(得分:4)

您可以使用@method phpdoc标记获取魔术方法的自动填充功能

这是一个代码示例:

<?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
      }
   }
}

这应该可以正常使用