This Question is Not Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
2 Replies Last post: May 24, 2013 3:35 AM by Benji Koltai  
Benji Koltai Newbie 2 posts since
May 24, 2013
Currently Being Moderated

May 24, 2013 1:51 AM

custom completion rules for PHP?

Hey IntelliJ Community!


I am working on a large project with IntelliJ 12 using the PHP plugin, and I have quite a few classes that have some magic functions (using __call and __callStatic). I would love to be able to get autocompletion for these classes, as the magic methods provided can be statically determined with some computations.


For example, I have a model class that defines an array of relationships with other classes


class Store{

    public static $has_many = array(





    public function __call($method, $param) {

        if (in_array($method, self::$has_many)) {

            // return relationship object


        // magic for setters




The goal is to be able to do:


$my_store = // some store instance;

$my_store->p.. // <--- autocompletes to 'products()'


As an autocomplete extension, I would say that any Store instance should also have methods for all its relations (like $has_many, $belongs_to, etc.). It would also be great to do this sort of magic autocomplete for other classes that have deterministic rules to define what extra methods can be called on the class.


Some of my objects have tens of methods that I'd like to have autocomplete for, so explicitly defining them all is not a scalable option.


Thanks for the help!

Mark Vedder Apprentice 1,076 posts since
Dec 10, 2003
Currently Being Moderated
May 24, 2013 2:55 AM in response to: Benji Koltai
Re: custom completion rules for PHP?

You can create a Live Template to do such.  See Help > IntelliJ IDEA > IntelliJ IDEA Usage Guidelines > Live Templates and its sub-pages for information (or the same information in web help).  You can go to File > Settings > [IDE Settings] Live Templates to create them. Be sure to give them a scope of PHP in the 'avaiable in' setting below the large text box (some people miss that setting).



p.s. There are also File Templates for creating new files. See Help > IntelliJ IDEA > IntelliJ IDEA Usage Guidelines > File Templates


More Like This

  • Retrieving data ...