Skip to content

QueryBuilder Result returns mixed when created in another method #308

Open
@alexander-schranz

Description

@alexander-schranz

I'm still running into the #266 issue, which I thought should be fixed with: 149cf71

But in my cases it ends still in mixed state.

I created a reproducer here:

git clone git@github.com:alexander-schranz/phpstan-query-builder-reproducer.git
cd phpstan-query-builder-reproducer/
composer install

vendor/bin/phpstan analyse

https://github.com/alexander-schranz/phpstan-query-builder-reproducer/blob/main/src/Repository/VisitorRepository.php

Output:

 ------ ----------------------------------------------------------------------------------------------------------
  Line   src/Repository/VisitorRepository.php
 ------ ----------------------------------------------------------------------------------------------------------
  46     Dumped type: mixed
  48     Method App\Repository\VisitorRepository::findBy() should return iterable<App\Entity\Visitor> but returns
         mixed.
  60     Dumped type: mixed
  62     Method App\Repository\VisitorRepository::findFlatBy() should return iterable<array{id: int, title:
         string|null}> but returns mixed.
  75     Dumped type: mixed
  77     Method App\Repository\VisitorRepository::findOneBy() should return App\Entity\Visitor|null but returns
         mixed.
  90     Dumped type: mixed
  92     Method App\Repository\VisitorRepository::getOneBy() should return App\Entity\Visitor but returns mixed.
 ------ ----------------------------------------------------------------------------------------------------------

Not sure what is different then to the test case 🤔

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