Skip to content

Commit 179941a

Browse files
committed
Help IDEs figure out which instances are being returned
1 parent 21e0570 commit 179941a

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/PoolInterface.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
interface PoolInterface
1717
{
18+
/**
19+
* @template TClassName
20+
* @param class-string<TClassName> $type
21+
* @return TClassName
22+
*/
1823
public function produce(string $type, array $attributes = null, $save = true): EntityInterface;
1924
public function modify(EntityInterface &$instance, array $attributes = null, $save = true): EntityInterface;
2025
public function scrap(EntityInterface &$instance, $force_delete = false): EntityInterface;
@@ -26,8 +31,25 @@ public function setDefaultProducerClass(string $default_producer_class): PoolInt
2631
public function registerProducer(string $type, ProducerInterface $producer): PoolInterface;
2732
public function registerProducerByClass(string $type, string $producer_class): PoolInterface;
2833

34+
/**
35+
* @template TClassName
36+
* @param class-string<TClassName> $type
37+
* @return ?TClassName
38+
*/
2939
public function getById(string $type, int $id, bool $use_cache = true): ?EntityInterface;
40+
41+
/**
42+
* @template TClassName
43+
* @param class-string<TClassName> $type
44+
* @return TClassName
45+
*/
3046
public function mustGetById(string $type, int $id, bool $use_cache = true): EntityInterface;
47+
48+
/**
49+
* @template TClassName
50+
* @param class-string<TClassName> $type
51+
* @return ?TClassName
52+
*/
3153
public function reload(string $type, int $id): ?EntityInterface;
3254
public function isInPool(string $type, int $id): bool;
3355
public function remember(EntityInterface $object): void;
@@ -42,10 +64,6 @@ public function count(string $type, mixed $conditions = null): int;
4264

4365
/**
4466
* Return true if object of the given type with the given ID exists.
45-
*
46-
* @param string $type
47-
* @param int $id
48-
* @return bool
4967
*/
5068
public function exists(string $type, int $id): bool;
5169

0 commit comments

Comments
 (0)