Skip to content

Commit

Permalink
better generic typings, fix DbalMapper->toEntity()
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Apr 4, 2023
1 parent accdaab commit 191ecbb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Mapper/Dbal/DbalMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public function toCollection($data): ICollection
/**
* @param QueryBuilder|Result|Row|array $data
* @phpstan-param QueryBuilder|Result|Row|array<string, mixed> $data
* @return E|null
*/
public function toEntity($data): ?IEntity
{
Expand Down
2 changes: 1 addition & 1 deletion tests/inc/model/author/AuthorsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static function getEntityClassNames(): array


/**
* @return Author[]|ICollection<Author>
* @return ICollection<Author>
*/
public function findByTags(string $name): ICollection
{
Expand Down
3 changes: 1 addition & 2 deletions tests/inc/model/book/BooksMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


use Nextras\Orm\Collection\ICollection;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Mapper\Dbal\Conventions\IConventions;
use Nextras\Orm\Mapper\Dbal\DbalMapper;

Expand All @@ -22,7 +21,7 @@ public function findBooksWithEvenId(): ICollection


/** @return Book|null */
public function findFirstBook(): ?IEntity
public function findFirstBook(): ?Book
{
return $this->toEntity($this->builder()->where('id = 1'));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/inc/model/book/BooksRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


/**
* @method ICollection<Book>|Book[] findBooksWithEvenId()
* @method ICollection<Book> findBooksWithEvenId()
* @method Book|null findFirstBook()
* @extends Repository<Book>
*/
Expand All @@ -20,7 +20,7 @@ static function getEntityClassNames(): array
}


/** @return Book[]|ICollection<Book> */
/** @return ICollection<Book> */
public function findLatest(): ICollection
{
return $this->findAll()
Expand All @@ -29,7 +29,7 @@ public function findLatest(): ICollection
}


/** @return Book[]|ICollection<Book> */
/** @return ICollection<Book> */
public function findByTags(string $name): ICollection
{
return $this->findBy(['tags->name' => $name]);
Expand Down

0 comments on commit 191ecbb

Please sign in to comment.