Skip to content

Bug: return type resolving #57

@msvrtan

Description

@msvrtan

Hi,

I'we just noticed that when using 'phpstan-doctrine' extension, there is a weird behaviour/bug with findOneBy methods: doesnt report error on calling non-existing method.

As a proof of concept (not able to share project I work on): https://github.com/msvrtan/phpstan-bug`

When calling a method findOneByUuid, it doesnt understand it's getting a Customer|null back but when calling findXOneByUuid it does: https://travis-ci.com/msvrtan/phpstan-bug/jobs/183766249

I'we also created a PR msvrtan/phpstan-bug#2 that fails https://travis-ci.com/msvrtan/phpstan-bug/builds/103870199 once I remove that Repository does extend EntityRepository...

On the other hand, if I do 'inject' repository as

/* @var \Doctrine\ORM\EntityRepository<\Customer\Customer> */
private $customerRepository;

it does report ...

I know this would be a quick 'fix' to go thru codebase and add those docblocks but it still feels like unexpected behaviour

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions