Skip to content

Commit

Permalink
Add generics to ModelManagerInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 authored and jordisala1991 committed Aug 30, 2020
1 parent 63de836 commit bd0e435
Showing 1 changed file with 46 additions and 4 deletions.
50 changes: 46 additions & 4 deletions src/Model/ModelManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ interface ModelManagerInterface extends DatagridManagerInterface
* @param string $name
*
* @return FieldDescriptionInterface
*
* @phpstan-param class-string $class
*/
public function getNewFieldDescriptionInstance($class, $name, array $options = []);

Expand All @@ -54,16 +56,26 @@ public function update($object);
public function delete($object);

/**
* @param string $class
* @param string $class
* @param array<string, mixed> $criteria
*
* @return object[] all objects matching the criteria
*
* @return array all objects matching the criteria
* @phpstan-template T
* @phpstan-param class-string<T> $class
* @phpstan-return T[]
*/
public function findBy($class, array $criteria = []);

/**
* @param string $class
* @param string $class
* @param array<string, mixed> $criteria
*
* @return object|null an object matching the criteria or null if none match
*
* @phpstan-template T
* @phpstan-param class-string<T> $class
* @phpstan-return T|null
*/
public function findOneBy($class, array $criteria = []);

Expand All @@ -72,13 +84,19 @@ public function findOneBy($class, array $criteria = []);
* @param mixed $id
*
* @return object|null the object with id or null if not found
*
* @phpstan-template T
* @phpstan-param class-string<T> $class
* @phpstan-return T|null
*/
public function find($class, $id);

/**
* @param string $class
*
* @throws ModelManagerException
*
* @phpstan-param class-string $class
*/
public function batchDelete($class, ProxyQueryInterface $queryProxy);

Expand All @@ -90,6 +108,8 @@ public function batchDelete($class, ProxyQueryInterface $queryProxy);
*
* @param array $parentAssociationMapping
* @param string $class
*
* @phpstan-param class-string $class
*/
public function getParentFieldDescription($parentAssociationMapping, $class);

Expand All @@ -98,6 +118,8 @@ public function getParentFieldDescription($parentAssociationMapping, $class);
* @param string $alias
*
* @return ProxyQueryInterface
*
* @phpstan-param class-string $class
*/
public function createQuery($class, $alias = 'o');

Expand All @@ -111,6 +133,8 @@ public function createQuery($class, $alias = 'o');
* @param string $class fully qualified class name
*
* @return string
*
* @phpstan-param class-string $class
*/
public function getModelIdentifier($class);

Expand All @@ -133,7 +157,9 @@ public function getIdentifierValues($model);
*
* @param string $class fully qualified class name
*
* @return array
* @return string[]
*
* @phpstan-param class-string $class
*/
public function getIdentifierFieldNames($class);

Expand Down Expand Up @@ -165,6 +191,10 @@ public function getUrlSafeIdentifier($model);
* @param string $class
*
* @return object
*
* @phpstan-template T
* @phpstan-param class-string<T> $class
* @phpstan-return T
*/
public function getModelInstance($class);

Expand Down Expand Up @@ -244,6 +274,10 @@ public function getSortParameters(FieldDescriptionInterface $fieldDescription, D
* @param string $class
*
* @return object
*
* @phpstan-template T
* @phpstan-param class-string<T> $class
* @phpstan-return T
*/
public function modelReverseTransform($class, array $array = []);

Expand All @@ -252,6 +286,10 @@ public function modelReverseTransform($class, array $array = []);
* @param object $instance
*
* @return object
*
* @phpstan-template T
* @phpstan-param class-string<T> $class
* @phpstan-return T
*/
public function modelTransform($class, $instance);

Expand All @@ -277,6 +315,8 @@ public function getDataSourceIterator(
* @param string $class
*
* @return string[]
*
* @phpstan-param class-string $class
*/
public function getExportFields($class);

Expand All @@ -294,6 +334,8 @@ public function getPaginationParameters(DatagridInterface $datagrid, $page);

/**
* @param string $class
*
* @phpstan-param class-string $class
*/
public function addIdentifiersToQuery($class, ProxyQueryInterface $query, array $idx);
}

0 comments on commit bd0e435

Please sign in to comment.