Skip to content

Query result type is not recognized if create the query builder on a trait #626

Open
@IndraGunawan

Description

@IndraGunawan

this commit 149cf71 makes the correct getResult return type if the method within the class, but it does not work if the query builder comes from a trait

trait MyTrait
{
	protected function getCustomQueryBuilder() {
		return $this->createQueryBuilder('t')
			->andWhere('t.enabled = true');
	}
}

class MyRepository
{
	use MyTrait;

	public function findBySomething(): array
	{
		$qb = $this->getCustomQueryBuilder()
			->andWhere('t.someInt = 1');
		return $qb->getQuery()->getResult();
	}

getting this error

 Method App\Repository\MyRepository::findBySomething() should return
         array<App\Entity\MyEntity> but returns mixed.

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