PHPDoc"静态"返回类型在这里表示什么?

Chr*_*ris 6 php phpdoc symfony doctrine-orm phpstorm

我正在与由Doctrine管理的实体合作开发Symfony项目.以下是我的实体的代码:

class User {
    /**
     * @ORM\OneToMany(targetEntity="Appointment", mappedBy="user")
     */
    private $appointments;

    /**
     * Get appointments
     *
     * @return \Doctrine\Common\Collections\ArrayCollection
     */
    public function getAppointments()
    {
        return $this->appointments;
    }

    /**
     * Get appointments at a specified date
     *
     * @param \DateTime $date
     * @return \Doctrine\Common\Collections\Collection|static
     */
    public function getAppointmentsAtDate(\DateTime $date) {
        $allAppointments = $this->getAppointments();

        $criteria = Criteria::create()->where(/* some clever filtering logic goes here */);

        return $allAppointments ->matching($criteria);
    }
}
Run Code Online (Sandbox Code Playgroud)

getAppointments是由Doctrine自动生成的.该getAppointmentsAtDate方法由我自己实施.该方法的PHPDoc标头由PhpStorm自动生成.

我无法理解的是static我的自定义方法的返回类型中的关键字.

根据我对PHPDoc类型的 理解,static表示此方法返回调用它的类的实例,在本例中为User实例.

但是,我没有看到此方法如何返回User实例或除了实例之外的任何其他内容Collection.

那么static关键字在这里意味着什么呢?我对关键字的理解是否有缺陷?或者PhpStorm的自动生成的文档标题是错误的?

Nic*_*ico 7

我已经查看了matching函数的学说来源,这里是返回类型:

return new static($filtered);
Run Code Online (Sandbox Code Playgroud)

Phpstorm可能解析了doctrine源并在匹配函数中看到了返回静态语句.