Skip to content

Doctrine findBy()/findOneBy() in repository fails as incorrectΒ #898

Open
@viktorasp

Description

@viktorasp

Phpstorm version: 2016.3.3
Plugin version: 0.13.138

Considering Account entity and AccountRepository for it, then the following code in the repository clas:

    /**
     * @param string $accountEmail
     *
     * @return null|Account
     */
    public function getAccountByEmail(string $email)
    {
        return $this->findOneBy(['email' => $email]);
    }

would result in "return" statement being marked as incorrect, due to type mismatch. There's no auto-complete for fields names as well.
However, the following function would have all the auto-complete and return type is detected correctly:

    /**
     * @param string $accountEmail
     *
     * @return null|Account
     */
    public function getAccountByEmail2(string $accountEmail)
    {
        return $this->getEntityManager()->getRepository('AccountBundle:Account')->findOneBy(['email' => $accountEmail]);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions