【问题标题】:Autocompletition in eclipse pdt in codeigniter for doctrine 2 models教义2模型的codeigniter中的eclipse pdt中的自动完成
【发布时间】:2023-03-21 21:25:01
【问题描述】:

我正在使用 eclipse PDT 使用 codeigniter 2 框架和学说 2 作为 ORM 编写一个项目。我想知道是否有办法让自动补全适用于学说 2 实体类(位于 \application\models\Entities 文件夹中的那些)我设法让它只工作一次,所以我知道这是可能的,现在我想知道如何让它始终工作或我做错了什么。

为了清楚起见,假设我们有这个控制器:

class Main extends My_Controller {

    function index() {

        $casualAccount = $this->doctrine->em->find('Entities\Account' , 1);
        $casualAccount-> **AUTOCOMPLETITION NOT WORKING HERE**
        $this->load->view('welcome_message.php');

    }
}

我们在\models\Entities 中有这个模型:

use Doctrine\ORM\Mapping as ORM;

/**
 * Entities\Account
 */
class Account

{
    /**
     * @var integer $id
     */
    private $id;

    /**
     * @var string $Mail
     */
    private $Mail;

    /**
     * @var string $Password
     */
    private $Password;

    /**
     * @var string $Type
     */
    private $Type;

    /**
     * @var string $First_name
     */
    private $First_name;

    /**
     * @var string $Last_name
     */
    private $Last_name;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set Mail
     *
     * @param string $mail
     * @return Account
     */
    public function setMail($mail)
    {
        $this->Mail = $mail;
        return $this;
    }

    /**
     * Get Mail
     *
     * @return string 
     */
    public function getMail()
    {
        return $this->Mail;
    }

    /**
     * Set Password
     *
     * @param string $password
     * @return Account
     */
    public function setPassword($password)
    {
        $this->Password = $password;
        return $this;
    }

    /**
     * Get Password
     *
     * @return string 
     */
    public function getPassword()
    {
        return $this->Password;
    }

    /**
     * Set Type
     *
     * @param string $type
     * @return Account
     */
    public function setType($type)
    {
        $this->Type = $type;
        return $this;
    }

    /**
     * Get Type
     *
     * @return string 
     */
    public function getType()
    {
        return $this->Type;
    }

    /**
     * Set First_name
     *
     * @param string $firstName
     * @return Account
     */
    public function setFirstName($firstName)
    {
        $this->First_name = $firstName;
        return $this;
    }

    /**
     * Get First_name
     *
     * @return string 
     */
    public function getFirstName()
    {
        return $this->First_name;
    }

    /**
     * Set Last_name
     *
     * @param string $lastName
     * @return Account
     */
    public function setLastName($lastName)
    {
        $this->Last_name = $lastName;
        return $this;
    }

    /**
     * Get Last_name
     *
     * @return string 
     */
    public function getLastName()
    {
        return $this->Last_name;
    }

更新。 Manix 的评论有点帮助。可以在类中声明一个变量,告诉它将使用以下语法:

class Main extends My_Controller {
    /**
    * @var Entities\Account
    */
    var $casualAccount;

 ....

}

这可能会有所帮助,但距离 eclipse 应该具备的自动自动完成功能还有很长的路要走。

【问题讨论】:

    标签: php eclipse codeigniter autocomplete doctrine-orm


    【解决方案1】:

    让我猜猜我是否明白。我从未使用过 Eclipse PDT,但是当不清楚时应该在内联变量中使用注释。下面的代码有助于 IDE 函数返回什么类型的 var find(),因为该函数动态生成实体。没有返回特定类型。

    /** 
     * @var $casualAccount  Entities\Account
     */
    $casualAccount = $this->doctrine->em->find('Entities\Account' , 1);
    $casualAccount-> **AUTOCOMPLETITION SHOULD WORK AT THIS POINT *
    

    上面的注释告诉 IDE $casualAccountEntities\Account 的类型。

    这就是自动完成并不总是可用的原因。看看:

    $this->load->library('Foo');
    $this->foo-> /* nothing to show */
    

    自动补全在这里不起作用,因为类引用本身是动态生成的,即使您已经记录了它。

    【讨论】:

    • 您的评论有点帮助,问题已更新
    猜你喜欢
    • 2011-02-12
    • 2012-04-09
    • 2010-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-24
    • 2012-07-04
    • 1970-01-01
    相关资源
    最近更新 更多