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!


Please sign in to leave a comment.