Skip to content

Commit

Permalink
Move template param to the class
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Apr 14, 2021
1 parent a824dfe commit 82121f7
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/Admin/AdminInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
* @phpstan-extends AccessRegistryInterface<T>
* @phpstan-extends UrlGeneratorInterface<T>
* @phpstan-extends LifecycleHookProviderInterface<T>
* @phpstan-extends TaggedAdminInterface<T>
*/
interface AdminInterface extends TaggedAdminInterface, AccessRegistryInterface, FieldDescriptionRegistryInterface, LifecycleHookProviderInterface, MenuBuilderInterface, ParentAdminInterface, UrlGeneratorInterface, MutableTemplateRegistryAwareInterface
{
Expand Down
5 changes: 5 additions & 0 deletions src/DependencyInjection/Admin/AbstractTaggedAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

/**
* @phpstan-template T of object
* @phpstan-implements TaggedAdminInterface<T>
*/
abstract class AbstractTaggedAdmin implements TaggedAdminInterface
{
Expand Down Expand Up @@ -117,6 +118,7 @@ abstract class AbstractTaggedAdmin implements TaggedAdminInterface
* The Entity or Document manager.
*
* @var ModelManagerInterface|null
* @phpstan-var ModelManagerInterface<T>|null
*/
protected $modelManager;

Expand Down Expand Up @@ -372,7 +374,10 @@ final public function hasFilterPersister(): bool
}

/**
* NEXT_MAJOR: Move the phpdoc to the interface.
*
* @final since sonata-admin/admin-bundle 3.84
* @phpstan-param ModelManagerInterface<T> $modelManager
*/
public function setModelManager(ModelManagerInterface $modelManager)
{
Expand Down
5 changes: 5 additions & 0 deletions src/DependencyInjection/Admin/TaggedAdminInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
* @method Pool getConfigurationPool()
* @method void setRouteGenerator(RouteGeneratorInterface $routeGenerator)
* @method RouteGeneratorInterface getRouteGenerator()
*
* @phpstan-template T of object
*/
interface TaggedAdminInterface
{
Expand Down Expand Up @@ -153,11 +155,14 @@ public function getSecurityInformation();

/**
* NEXT_MAJOR: Uncomment this method.
*
* @phpstan-param ModelManagerInterface<T>
*/
// public function setModelManager(ModelManagerInterface $modelManager): void;

/**
* @return ModelManagerInterface
* @phpstan-return ModelManagerInterface<T>
*/
public function getModelManager();

Expand Down
4 changes: 3 additions & 1 deletion src/Form/DataTransformer/ArrayToModelTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ArrayToModelTransformer implements DataTransformerInterface
{
/**
* @var ModelManagerInterface
* @phpstan-var ModelManagerInterface<T>
*/
protected $modelManager;

Expand All @@ -41,7 +42,8 @@ class ArrayToModelTransformer implements DataTransformerInterface
/**
* @param string $className
*
* @phpstan-param class-string<T> $className
* @phpstan-param ModelManagerInterface<T> $modelManager
* @phpstan-param class-string<T> $className
*/
public function __construct(ModelManagerInterface $modelManager, $className)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Form/DataTransformer/ModelToIdPropertyTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ModelToIdPropertyTransformer implements DataTransformerInterface
{
/**
* @var ModelManagerInterface
* @phpstan-var ModelManagerInterface<T>
*/
protected $modelManager;

Expand Down Expand Up @@ -65,7 +66,8 @@ class ModelToIdPropertyTransformer implements DataTransformerInterface
* @param callable|null $toStringCallback
*
* @phpstan-template P
* @phpstan-param class-string<T> $className
* @phpstan-param ModelManagerInterface<T> $modelManager
* @phpstan-param class-string<T> $className
* @phpstan-param null|callable(object, P): string $toStringCallback
*/
public function __construct(
Expand Down
4 changes: 3 additions & 1 deletion src/Form/DataTransformer/ModelToIdTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ModelToIdTransformer implements DataTransformerInterface
{
/**
* @var ModelManagerInterface
* @phpstan-var ModelManagerInterface<T>
*/
protected $modelManager;

Expand All @@ -40,7 +41,8 @@ class ModelToIdTransformer implements DataTransformerInterface
/**
* @param string $className
*
* @phpstan-param class-string<T> $className
* @phpstan-param ModelManagerInterface<T> $modelManager
* @phpstan-param class-string<T> $className
*/
public function __construct(ModelManagerInterface $modelManager, $className)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Form/DataTransformer/ModelsToArrayTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ModelsToArrayTransformer implements DataTransformerInterface
{
/**
* @var ModelManagerInterface
* @phpstan-var ModelManagerInterface<T>
*/
protected $modelManager;

Expand All @@ -60,7 +61,8 @@ class ModelsToArrayTransformer implements DataTransformerInterface
* @param ModelManagerInterface $modelManager
* @param string $class
*
* @phpstan-param class-string<T> $class
* @phpstan-param ModelManagerInterface<T> $modelManager
* @phpstan-param class-string<T> $class
*
* @throws RuntimeException
*/
Expand Down
12 changes: 4 additions & 8 deletions src/Model/ModelManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*
* @method bool supportsQuery(object $query)
* @method void reverseTransform(object $object, array $array = [])
*
* @phpstan-template T of object
*/
interface ModelManagerInterface extends DatagridManagerInterface
{
Expand Down Expand Up @@ -72,7 +74,6 @@ public function delete($object);
*
* @return object[] all objects matching the criteria
*
* @phpstan-template T of object
* @phpstan-param class-string<T> $class
* @phpstan-return T[]
*/
Expand All @@ -84,7 +85,6 @@ public function findBy($class, array $criteria = []);
*
* @return object|null an object matching the criteria or null if none match
*
* @phpstan-template T of object
* @phpstan-param class-string<T> $class
* @phpstan-return T|null
*/
Expand All @@ -96,7 +96,6 @@ public function findOneBy($class, array $criteria = []);
*
* @return object|null the object with id or null if not found
*
* @phpstan-template T of object
* @phpstan-param class-string<T> $class
* @phpstan-return T|null
*/
Expand Down Expand Up @@ -204,7 +203,6 @@ public function getUrlSafeIdentifier($model);
*
* @return object
*
* @phpstan-template T of object
* @phpstan-param class-string<T> $class
* @phpstan-return T
*/
Expand Down Expand Up @@ -291,7 +289,6 @@ public function getSortParameters(FieldDescriptionInterface $fieldDescription, D
*
* @return object
*
* @phpstan-template T of object
* @phpstan-param class-string<T> $class
* @phpstan-return T
*/
Expand All @@ -310,7 +307,6 @@ public function modelReverseTransform($class, array $array = []);
*
* @return object
*
* @phpstan-template T of object
* @phpstan-param class-string<T> $class
* @phpstan-return T
*/
Expand Down Expand Up @@ -346,7 +342,7 @@ public function getDataSourceIterator(
*
* @return string[]
*
* @phpstan-param class-string $class
* @phpstan-param class-string<T> $class
*/
public function getExportFields($class);

Expand All @@ -366,7 +362,7 @@ public function getPaginationParameters(DatagridInterface $datagrid, $page);
* @param string $class
* @param array<int, int|string> $idx
*
* @phpstan-param class-string $class
* @phpstan-param class-string<T> $class
*/
public function addIdentifiersToQuery($class, ProxyQueryInterface $query, array $idx);
}
Expand Down

0 comments on commit 82121f7

Please sign in to comment.