Skip to content

Commit

Permalink
[fix] phpstan-compatible typings for $entities
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMediocresTestAccount committed Nov 2, 2022
1 parent 1d33d77 commit a4f75cd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Domain/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* @phpstan-template T of StorableEntity
* @template T of StorableEntity
* @implements EntityRepository<T>
* @phpstan-type ResultArray array<int, array{item: T, dirty: bool}>
* //phpstan-type ResultArray<T> array<int, array{item: T, dirty: bool}>
* ^ this is not currently possible in phpstan and can not be imported: https://github.com/phpstan/phpstan/issues/6099
*/
abstract class AbstractRepository extends Singleton implements
EntityRepository,
Expand All @@ -20,7 +21,7 @@ abstract class AbstractRepository extends Singleton implements
/** @var string */
public static $metaKey;

/** @var ResultArray */
/** @var array<int, array{item: T, dirty: bool}> */
protected $entities = [];

/** @var class-string<T> FQCN of an entity class implementing StorableEntity */
Expand Down Expand Up @@ -125,7 +126,7 @@ public function refresh(): EntityRepository
* Retrieve all posts fetched by getPosts() directly from the database and
* instantiate them into StorableEntities using entityFromPostId().
*
* @return ResultArray
* @return array<int, array{item: T, dirty: bool}>
*/
protected static function getAllFromDB(): array
{
Expand Down Expand Up @@ -214,7 +215,7 @@ abstract protected static function getPosts(): array;
/**
* @param array<WP_Post> $posts
*
* @return ResultArray
* @return array<int, array{item: T, dirty: bool}>
*/
protected static function mapPostsToEntities(array $posts): array
{
Expand Down

0 comments on commit a4f75cd

Please sign in to comment.