Skip to content

Commit 6232fb5

Browse files
committed
[CS] Add generics support for EntityAutocompleterInterface
1 parent ec09cdf commit 6232fb5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Autocomplete/src/EntityAutocompleterInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,37 @@
1818
/**
1919
* Interface for classes that will have an "autocomplete" endpoint exposed.
2020
*
21+
* @template T of object
22+
*
2123
* @method mixed getGroupBy() Return group_by option.
2224
*/
2325
interface EntityAutocompleterInterface
2426
{
2527
/**
2628
* The fully-qualified entity class this will be autocompleting.
29+
*
30+
* @return class-string<T>
2731
*/
2832
public function getEntityClass(): string;
2933

3034
/**
3135
* Create a query builder that filters for the given "query".
36+
*
37+
* @param EntityRepository<T> $repository
3238
*/
3339
public function createFilteredQueryBuilder(EntityRepository $repository, string $query): QueryBuilder;
3440

3541
/**
3642
* Returns the "choice_label" used to display this entity.
43+
*
44+
* @param T $entity
3745
*/
3846
public function getLabel(object $entity): string;
3947

4048
/**
4149
* Returns the "value" attribute for this entity, usually the id.
50+
*
51+
* @param T $entity
4252
*/
4353
public function getValue(object $entity): mixed;
4454

src/Autocomplete/tests/Fixtures/Autocompleter/CustomProductAutocompleter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
use Symfony\UX\Autocomplete\EntityAutocompleterInterface;
2020
use Symfony\UX\Autocomplete\Tests\Fixtures\Entity\Product;
2121

22+
/**
23+
* @implements EntityAutocompleterInterface<Product>
24+
*/
2225
class CustomProductAutocompleter implements EntityAutocompleterInterface
2326
{
2427
public function __construct(

0 commit comments

Comments
 (0)