views:

23

answers:

1

Hello all

I am using Codeigniter framework for PHP. I was wondering if there is a way to load methods in a Model for autocompletion using PHPDoc @property.

What I mean is ....

class abc_controller extends Controller {

  /**
   * @property Model1
   */
  function func() {
     $this->load->model("Model1"); // I am loading the model here

     $result = $this->Model1->getIds(); 
     // When I type Model1 in the statement above, it should popup 
     // an autocompletion box populated with all the methods of Model1
  }
}

I did something like this using NetBeans while working on Cakephp. I was wondering if such a thing is possible for CodeIgniter as well/

Regards

A: 

You need to add property to your class phpdoc. Check this video out http://netbeans.org/kb/docs/php/class-property-variables-screencast.html

<?php

/**
 * blah blah balh
 *
 * @property Model1 Model1
 * @property <type> <name>
 */
class abc_controller extends Controller {

    /**
     * blah blah blah
     */
    function func() {
        $this->load->model("Model1"); // I am loading the model here

        $result = $this->Model1->getIds();
        // When I type Model1 in the statement above, it should popup
        // an autocompletion box populated with all the methods of Model1
    }

}

?>

Or if you are getting a value from a function with a mixed return type you need to to it like this:

 function func(){
        $myObj =  $this->getMixedType();
        /* @var $myObj TypeOfMyObject */

        //  The vdoc has to be below the function call, otherwise the latest return type will be used
        //  Shortcut for generating vdoc is "vdoc" + tab
        //  For example if you have vdoc above the function call and function 
        //  returns Type1, then your object will have autocomplete for Type1.
    }
Alex