Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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