2010-09-08 4 views
1

J'utilise le framework Codeigniter pour PHP. Je me demandais s'il y avait un moyen de charger des méthodes dans un Modèle pour l'auto-complétion en utilisant PHPDoc @property.Chargement de modèles pour l'auto-complétion en utilisant PHPDoc @property

Ce que je veux dire est ....

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

je fait quelque chose comme cela en utilisant NetBeans tout en travaillant sur CakePHP. Je me demandais si une telle chose est possible pour CodeIgniter et/

Cordialement

Répondre

2

Vous devez ajouter à votre propriété phpdoc de classe. Vérifiez cette vidéo sur 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 
    } 

} 

?> 

Ou si vous obtenez une valeur d'une fonction avec un type de retour mixte, vous devez lui comme ceci:

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. 
    } 
Questions connexes