1

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

1 Answer 1

2

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.
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.