Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic for PagerInterface #6759

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Datagrid/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*
* @author Fabien Potencier <[email protected]>
* @author Thomas Rabaix <[email protected]>
*
* @phpstan-template T of ProxyQueryInterface
* @phpstan-implements PagerInterface<T>
*/
abstract class Pager implements \Iterator, \Countable, \Serializable, PagerInterface
{
Expand Down Expand Up @@ -113,6 +116,8 @@ abstract class Pager implements \Iterator, \Countable, \Serializable, PagerInter

/**
* @var ProxyQueryInterface|null
*
* @phpstan-var T|null
*/
protected $query;

Expand Down Expand Up @@ -856,6 +861,8 @@ public function setQuery($query)

/**
* @return ProxyQueryInterface|null
*
* @phpstan-return T|null $query
*/
public function getQuery()
{
Expand Down
9 changes: 9 additions & 0 deletions src/Datagrid/PagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* @method array getLinks(?int $nbLinks = null)
* @method bool haveToPaginate()
* @method ProxyQueryInterface|null getQuery()
*
* @phpstan-template T of ProxyQueryInterface
*/
interface PagerInterface
{
Expand Down Expand Up @@ -79,10 +81,17 @@ public function setPage($page);
// public function isLastPage(): bool;

// NEXT_MAJOR: uncomment this method in 4.0
// /**
// * @return ProxyQueryInterface|null
// *
// * @phpstan-return T|null
// */
// public function getQuery(): ?ProxyQueryInterface;

/**
* @param ProxyQueryInterface $query
*
* @phpstan-param T $query
*/
public function setQuery($query);

Expand Down