Skip to content

Commit 999d9f1

Browse files
committed
Pager & Router typos changes
1 parent 0ebf4f2 commit 999d9f1

9 files changed

Lines changed: 64 additions & 42 deletions

File tree

system/CLI/Console.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function __construct(CodeIgniter $app)
7373
* @param boolean $useSafeOutput
7474
*
7575
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
76-
* @throws \CodeIgniter\Router\RedirectException
76+
* @throws \Exception
7777
*/
7878
public function run(bool $useSafeOutput = false)
7979
{

system/CodeIgniter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public function useSafeOutput(bool $safe = true)
281281
* @param boolean $returnResponse
282282
*
283283
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
284-
* @throws \CodeIgniter\Router\RedirectException
284+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
285285
*/
286286
protected function handleRequest(RouteCollectionInterface $routes = null, $cacheConfig, bool $returnResponse = false)
287287
{
@@ -687,7 +687,7 @@ public function displayPerformanceMetrics(string $output): string
687687
* of the config file.
688688
*
689689
* @return string
690-
* @throws \CodeIgniter\Router\RedirectException
690+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
691691
*/
692692
protected function tryToRouteIt(RouteCollectionInterface $routes = null)
693693
{

system/Language/en/Redirect.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/**
4+
* Redirect language strings.
5+
*
6+
* @package CodeIgniter
7+
* @author CodeIgniter Dev Team
8+
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
9+
* @license https://opensource.org/licenses/MIT MIT License
10+
* @link https://codeigniter.com
11+
* @since Version 3.0.0
12+
* @filesource
13+
*
14+
* @codeCoverageIgnore
15+
*/
16+
17+
return [
18+
'forUnableToRedirect' => 'Unable to redirect to "{0}". Error status code "{1}"',
19+
];

system/Pager/Pager.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function makeLinks(int $page, int $perPage, int $total, string $template
166166
*
167167
* @return string
168168
*/
169-
protected function displayLinks(string $group, string $template)
169+
protected function displayLinks(string $group, string $template): string
170170
{
171171
$pager = new PagerRenderer($this->getDetails($group));
172172

@@ -191,7 +191,7 @@ protected function displayLinks(string $group, string $template)
191191
* @param integer $total
192192
* @param integer $segment
193193
*
194-
* @return mixed
194+
* @return $this
195195
*/
196196
public function store(string $group, int $page, int $perPage, int $total, int $segment = 0)
197197
{
@@ -304,7 +304,7 @@ public function getLastPage(string $group = 'default')
304304
*
305305
* @return integer
306306
*/
307-
public function getFirstPage(string $group = 'default')
307+
public function getFirstPage(string $group = 'default'): int
308308
{
309309
$this->ensureGroup($group);
310310

@@ -323,7 +323,7 @@ public function getFirstPage(string $group = 'default')
323323
*
324324
* @return string|\CodeIgniter\HTTP\URI
325325
*/
326-
public function getPageURI(int $page = null, string $group = 'default', $returnObject = false)
326+
public function getPageURI(int $page = null, string $group = 'default', bool $returnObject = false)
327327
{
328328
$this->ensureGroup($group);
329329

@@ -368,7 +368,7 @@ public function getPageURI(int $page = null, string $group = 'default', $returnO
368368
*
369369
* @return string|null
370370
*/
371-
public function getNextPageURI(string $group = 'default', $returnObject = false)
371+
public function getNextPageURI(string $group = 'default', bool $returnObject = false)
372372
{
373373
$this->ensureGroup($group);
374374

@@ -399,7 +399,7 @@ public function getNextPageURI(string $group = 'default', $returnObject = false)
399399
*
400400
* @return string|null
401401
*/
402-
public function getPreviousPageURI(string $group = 'default', $returnObject = false)
402+
public function getPreviousPageURI(string $group = 'default', bool $returnObject = false)
403403
{
404404
$this->ensureGroup($group);
405405

system/Pager/PagerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function getCurrentPage(string $group = 'default'): int;
141141
*
142142
* @return string|\CodeIgniter\HTTP\URI
143143
*/
144-
public function getPageURI(int $page = null, string $group = 'default', $returnObject = false);
144+
public function getPageURI(int $page = null, string $group = 'default', bool $returnObject = false);
145145

146146
//--------------------------------------------------------------------
147147

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace CodeIgniter\Router\Exceptions;
4+
5+
/**
6+
* Redirect exception
7+
*/
8+
class RedirectException extends \Exception
9+
{
10+
public static function forUnableToRedirect(string $route, string $code)
11+
{
12+
return new static(lang('Redirect.forUnableToRedirect', [$route, $code]));
13+
}
14+
}

system/Router/RouteCollection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ public function shouldAutoRoute(): bool
511511
/**
512512
* Returns the raw array of available routes.
513513
*
514-
* @param null $verb
514+
* @param mixed $verb
515515
*
516516
* @return array
517517
*/
@@ -619,9 +619,9 @@ public function map(array $routes = [], array $options = null): RouteCollectionI
619619
* Example:
620620
* $routes->add('news', 'Posts::index');
621621
*
622-
* @param string $from
623-
* @param array|string $to
624-
* @param $options
622+
* @param string $from
623+
* @param array|string $to
624+
* @param array $options
625625
*
626626
* @return RouteCollectionInterface
627627
*/
@@ -724,7 +724,7 @@ public function getRedirectCode(string $from): int
724724
*
725725
* @return void
726726
*/
727-
public function group($name, ...$params)
727+
public function group(string $name, ...$params)
728728
{
729729
$oldGroup = $this->group;
730730
$oldOptions = $this->currentOptions;

system/Router/Router.php

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,9 @@
3939
namespace CodeIgniter\Router;
4040

4141
use CodeIgniter\Exceptions\PageNotFoundException;
42+
use CodeIgniter\Router\Exceptions\RedirectException;
4243
use CodeIgniter\Router\Exceptions\RouterException;
4344

44-
/**
45-
* Routing exception
46-
*/
47-
class RedirectException extends \Exception
48-
{
49-
50-
}
51-
5245
/**
5346
* Request router.
5447
*/
@@ -154,15 +147,11 @@ public function __construct(RouteCollectionInterface $routes)
154147
//--------------------------------------------------------------------
155148

156149
/**
157-
* Scans the URI and attempts to match the current URI to the
158-
* one of the defined routes in the RouteCollection.
159-
*
160-
* This is the main entry point when using the Router.
150+
* @param string|null $uri
161151
*
162-
* @param string $uri
163-
*
164-
* @return mixed
165-
* @throws \CodeIgniter\Router\RedirectException
152+
* @return mixed|string
153+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
154+
* @throws \CodeIgniter\Exceptions\PageNotFoundException
166155
*/
167156
public function handle(string $uri = null)
168157
{
@@ -394,7 +383,7 @@ public function getLocale()
394383
* @param string $uri The URI path to compare against the routes
395384
*
396385
* @return boolean Whether the route was matched or not.
397-
* @throws \CodeIgniter\Router\RedirectException
386+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
398387
*/
399388
protected function checkRoutes(string $uri): bool
400389
{
@@ -491,7 +480,7 @@ protected function checkRoutes(string $uri): bool
491480
// Is this route supposed to redirect to another?
492481
if ($this->collection->isRedirect($key))
493482
{
494-
throw new RedirectException($val, $this->collection->getRedirectCode($key));
483+
throw RedirectException::forUnableToRedirect($val, $this->collection->getRedirectCode($key));
495484
}
496485

497486
$this->setRequest(explode('/', $val));
@@ -573,7 +562,7 @@ public function autoRoute(string $uri)
573562
*
574563
* @return array URI segments
575564
*/
576-
protected function validateRequest(array $segments)
565+
protected function validateRequest(array $segments): array
577566
{
578567
$segments = array_filter($segments);
579568

@@ -608,7 +597,7 @@ protected function validateRequest(array $segments)
608597
* @param string|null $dir
609598
* @param boolean|false $append
610599
*/
611-
protected function setDirectory(string $dir = null, $append = false)
600+
protected function setDirectory(string $dir = null, bool $append = false)
612601
{
613602
$dir = ucfirst($dir);
614603

system/Test/FeatureTestCase.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function skipEvents()
138138
* @param array|null $params
139139
*
140140
* @return \CodeIgniter\Test\FeatureResponse
141-
* @throws \CodeIgniter\HTTP\RedirectException
141+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
142142
* @throws \Exception
143143
*/
144144
public function call(string $method, string $path, array $params = null)
@@ -179,7 +179,7 @@ public function call(string $method, string $path, array $params = null)
179179
* @param array|null $params
180180
*
181181
* @return \CodeIgniter\Test\FeatureResponse
182-
* @throws \CodeIgniter\HTTP\RedirectException
182+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
183183
* @throws \Exception
184184
*/
185185
public function get(string $path, array $params = null)
@@ -194,7 +194,7 @@ public function get(string $path, array $params = null)
194194
* @param array|null $params
195195
*
196196
* @return \CodeIgniter\Test\FeatureResponse
197-
* @throws \CodeIgniter\HTTP\RedirectException
197+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
198198
* @throws \Exception
199199
*/
200200
public function post(string $path, array $params = null)
@@ -209,7 +209,7 @@ public function post(string $path, array $params = null)
209209
* @param array|null $params
210210
*
211211
* @return \CodeIgniter\Test\FeatureResponse
212-
* @throws \CodeIgniter\HTTP\RedirectException
212+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
213213
* @throws \Exception
214214
*/
215215
public function put(string $path, array $params = null)
@@ -224,7 +224,7 @@ public function put(string $path, array $params = null)
224224
* @param array|null $params
225225
*
226226
* @return \CodeIgniter\Test\FeatureResponse
227-
* @throws \CodeIgniter\HTTP\RedirectException
227+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
228228
* @throws \Exception
229229
*/
230230
public function patch(string $path, array $params = null)
@@ -239,7 +239,7 @@ public function patch(string $path, array $params = null)
239239
* @param array|null $params
240240
*
241241
* @return \CodeIgniter\Test\FeatureResponse
242-
* @throws \CodeIgniter\HTTP\RedirectException
242+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
243243
* @throws \Exception
244244
*/
245245
public function delete(string $path, array $params = null)
@@ -254,7 +254,7 @@ public function delete(string $path, array $params = null)
254254
* @param array|null $params
255255
*
256256
* @return \CodeIgniter\Test\FeatureResponse
257-
* @throws \CodeIgniter\HTTP\RedirectException
257+
* @throws \CodeIgniter\Router\Exceptions\RedirectException
258258
* @throws \Exception
259259
*/
260260
public function options(string $path, array $params = null)

0 commit comments

Comments
 (0)