Skip to content

Commit

Permalink
Failing test for phpstan#512
Browse files Browse the repository at this point in the history
  • Loading branch information
jlherren committed Jan 8, 2024
1 parent b15c279 commit 4675b3b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function dataFileAsserts(): iterable
{
yield from $this->gatherAssertTypes(__DIR__ . '/../data/QueryResult/queryBuilderGetQuery.php');
yield from $this->gatherAssertTypes(__DIR__ . '/../data/QueryResult/bug-245.php');
yield from $this->gatherAssertTypes(__DIR__ . '/../data/QueryResult/bug-512.php');
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/Type/Doctrine/data/QueryResult/Entities/One.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
namespace QueryResult\Entities;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Embedded as ORMEmbedded;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OneToOne;
use Doctrine\ORM\QueryBuilder;

/**
* @Entity
Expand Down Expand Up @@ -71,4 +73,11 @@ public function __construct()
{
$this->subOne = new SubOne();
}

public static function createQueryBuilder(EntityManagerInterface $em): QueryBuilder
{
return $em->createQueryBuilder()
->select('o')
->from(self::class, 'o');
}
}
17 changes: 17 additions & 0 deletions tests/Type/Doctrine/data/QueryResult/bug-512.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php declare(strict_types = 1);

namespace QueryResult\Bug512;

use Doctrine\ORM\EntityManagerInterface;
use QueryResult\Entities\One;
use function PHPStan\Testing\assertType;

class Bug512
{
public function test(EntityManagerInterface $em): void
{
$query = One::createQueryBuilder($em)->getQuery();
assertType('Doctrine\ORM\Query<null, QueryResult\Entities\One>', $query);
assertType('list<QueryResult\Entities\One>', $query->getResult());
}
}

0 comments on commit 4675b3b

Please sign in to comment.