Skip to content

Commit 3a3531b

Browse files
committed
docs: replace type in Pager
1 parent 8a93b65 commit 3a3531b

3 files changed

Lines changed: 29 additions & 10 deletions

File tree

system/Pager/Pager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function store(string $group, int $page, ?int $perPage, int $total, int $
158158
/**
159159
* Sets segment for a group.
160160
*
161-
* @return mixed
161+
* @return $this
162162
*/
163163
public function setSegment(int $number, string $group = 'default')
164164
{
@@ -174,7 +174,7 @@ public function setSegment(int $number, string $group = 'default')
174174
/**
175175
* Sets the path that an aliased group of links will use.
176176
*
177-
* @return mixed
177+
* @return $this
178178
*/
179179
public function setPath(string $path, string $group = 'default')
180180
{

system/Pager/PagerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ public function makeLinks(int $page, int $perPage, int $total, string $template
4242
* Stores a set of pagination data for later display. Most commonly used
4343
* by the model to automate the process.
4444
*
45-
* @return mixed
45+
* @return $this
4646
*/
4747
public function store(string $group, int $page, int $perPage, int $total);
4848

4949
/**
5050
* Sets the path that an aliased group of links will use.
5151
*
52-
* @return mixed
52+
* @return $this
5353
*/
5454
public function setPath(string $path, string $group = 'default');
5555

tests/system/Pager/PagerTest.php

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use CodeIgniter\Pager\Exceptions\PagerException;
1919
use CodeIgniter\Test\CIUnitTestCase;
2020
use Config\App;
21-
use Config\Pager;
21+
use Config\Pager as PagerConfig;
2222
use Config\Services;
2323

2424
/**
@@ -28,7 +28,7 @@
2828
*/
2929
final class PagerTest extends CIUnitTestCase
3030
{
31-
private ?\CodeIgniter\Pager\Pager $pager = null;
31+
private ?Pager $pager = null;
3232
private $config;
3333

3434
protected function setUp(): void
@@ -58,8 +58,8 @@ private function createPager(string $requestUri): void
5858
$request = $request->withMethod('GET');
5959
Services::injectMock('request', $request);
6060

61-
$this->config = new Pager();
62-
$this->pager = new \CodeIgniter\Pager\Pager($this->config, Services::renderer());
61+
$this->config = new PagerConfig();
62+
$this->pager = new Pager($this->config, Services::renderer());
6363
}
6464

6565
public function testSetPathRemembersPath()
@@ -180,6 +180,25 @@ public function testStoreWithSegments()
180180
);
181181
}
182182

183+
public function testStoreWithURIReturnObject()
184+
{
185+
$_GET['page'] = 5;
186+
$_GET['id'] = 1;
187+
188+
$this->pager->store('bar', 5, 25, 100, 1);
189+
190+
$uri = $this->pager->getPageURI(7, 'bar', true);
191+
$onlyURI = $this->pager->only(['bar'])->getPageURI(9, 'bar', true);
192+
193+
// Total Segment
194+
$this->assertSame(1, $uri->getTotalSegments());
195+
$this->assertSame(1, $onlyURI->getTotalSegments());
196+
197+
// Get Segment
198+
$this->assertSame('', $uri->getSegment(2));
199+
$this->assertSame('9', $onlyURI->getSegment(1));
200+
}
201+
183202
public function testHasMoreDefaultsToFalse()
184203
{
185204
$this->assertFalse($this->pager->hasMore('foo'));
@@ -463,8 +482,8 @@ public function testBasedURI()
463482

464483
Services::injectMock('request', $request);
465484

466-
$this->config = new Pager();
467-
$this->pager = new \CodeIgniter\Pager\Pager($this->config, Services::renderer());
485+
$this->config = new PagerConfig();
486+
$this->pager = new Pager($this->config, Services::renderer());
468487

469488
$_GET['page_foo'] = 2;
470489

0 commit comments

Comments
 (0)