Skip to content
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
10 changes: 0 additions & 10 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -8041,21 +8041,11 @@
'count' => 1,
'path' => __DIR__ . '/system/Pager/Pager.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in an if condition, array given\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Pager/Pager.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Pager\\\\Pager\\:\\:\\$groups type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Pager/Pager.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Pager\\\\Pager\\:\\:\\$only type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Pager/Pager.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Pager\\\\Pager\\:\\:\\$segment type has no value type specified in iterable type array\\.$#',
'count' => 1,
Expand Down
6 changes: 3 additions & 3 deletions system/Pager/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class Pager implements PagerInterface
/**
* List of only permitted queries
*
* @var array
* @var list<string>|null
*/
protected $only = [];
protected $only;

/**
* Constructor.
Expand Down Expand Up @@ -276,7 +276,7 @@ public function getPageURI(?int $page = null, string $group = 'default', bool $r
$uri->addQuery($this->groups[$group]['pageSelector'], $page);
}

if ($this->only) {
if ($this->only !== null) {
$query = array_intersect_key($_GET, array_flip($this->only));

if (! $segment) {
Expand Down
8 changes: 8 additions & 0 deletions tests/system/Pager/PagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ public function testStoreWithQueries(): void
'http://example.com/?foo=bar&page=5',
$this->pager->only(['foo'])->getPageURI(5)
);
$this->assertSame(
'http://example.com/?page=5',
$this->pager->only([])->getPageURI(5)
);
}

public function testStoreWithSegments(): void
Expand All @@ -181,6 +185,10 @@ public function testStoreWithSegments(): void
'http://example.com/5?foo=bar',
$this->pager->only(['foo'])->getPageURI(5)
);
$this->assertSame(
'http://example.com/5',
$this->pager->only([])->getPageURI(5)
);
}

public function testGetPageURIWithURIReturnObject(): void
Expand Down