Skip to content

Commit

Permalink
Pager & Router typos changes
Browse files Browse the repository at this point in the history
  • Loading branch information
atishhamte committed Apr 19, 2019
1 parent 0ebf4f2 commit 999d9f1
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 42 deletions.
2 changes: 1 addition & 1 deletion system/CLI/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(CodeIgniter $app)
* @param boolean $useSafeOutput
*
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
* @throws \CodeIgniter\Router\RedirectException
* @throws \Exception
*/
public function run(bool $useSafeOutput = false)
{
Expand Down
4 changes: 2 additions & 2 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function useSafeOutput(bool $safe = true)
* @param boolean $returnResponse
*
* @return \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\Response|\CodeIgniter\HTTP\ResponseInterface|mixed
* @throws \CodeIgniter\Router\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
*/
protected function handleRequest(RouteCollectionInterface $routes = null, $cacheConfig, bool $returnResponse = false)
{
Expand Down Expand Up @@ -687,7 +687,7 @@ public function displayPerformanceMetrics(string $output): string
* of the config file.
*
* @return string
* @throws \CodeIgniter\Router\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
*/
protected function tryToRouteIt(RouteCollectionInterface $routes = null)
{
Expand Down
19 changes: 19 additions & 0 deletions system/Language/en/Redirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* Redirect language strings.
*
* @package CodeIgniter
* @author CodeIgniter Dev Team
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
* @since Version 3.0.0
* @filesource
*
* @codeCoverageIgnore
*/

return [
'forUnableToRedirect' => 'Unable to redirect to "{0}". Error status code "{1}"',
];
12 changes: 6 additions & 6 deletions system/Pager/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function makeLinks(int $page, int $perPage, int $total, string $template
*
* @return string
*/
protected function displayLinks(string $group, string $template)
protected function displayLinks(string $group, string $template): string
{
$pager = new PagerRenderer($this->getDetails($group));

Expand All @@ -191,7 +191,7 @@ protected function displayLinks(string $group, string $template)
* @param integer $total
* @param integer $segment
*
* @return mixed
* @return $this
*/
public function store(string $group, int $page, int $perPage, int $total, int $segment = 0)
{
Expand Down Expand Up @@ -304,7 +304,7 @@ public function getLastPage(string $group = 'default')
*
* @return integer
*/
public function getFirstPage(string $group = 'default')
public function getFirstPage(string $group = 'default'): int
{
$this->ensureGroup($group);

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

Expand Down Expand Up @@ -368,7 +368,7 @@ public function getPageURI(int $page = null, string $group = 'default', $returnO
*
* @return string|null
*/
public function getNextPageURI(string $group = 'default', $returnObject = false)
public function getNextPageURI(string $group = 'default', bool $returnObject = false)
{
$this->ensureGroup($group);

Expand Down Expand Up @@ -399,7 +399,7 @@ public function getNextPageURI(string $group = 'default', $returnObject = false)
*
* @return string|null
*/
public function getPreviousPageURI(string $group = 'default', $returnObject = false)
public function getPreviousPageURI(string $group = 'default', bool $returnObject = false)
{
$this->ensureGroup($group);

Expand Down
2 changes: 1 addition & 1 deletion system/Pager/PagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function getCurrentPage(string $group = 'default'): int;
*
* @return string|\CodeIgniter\HTTP\URI
*/
public function getPageURI(int $page = null, string $group = 'default', $returnObject = false);
public function getPageURI(int $page = null, string $group = 'default', bool $returnObject = false);

//--------------------------------------------------------------------

Expand Down
14 changes: 14 additions & 0 deletions system/Router/Exceptions/RedirectException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace CodeIgniter\Router\Exceptions;

/**
* Redirect exception
*/
class RedirectException extends \Exception
{
public static function forUnableToRedirect(string $route, string $code)
{
return new static(lang('Redirect.forUnableToRedirect', [$route, $code]));
}
}
10 changes: 5 additions & 5 deletions system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public function shouldAutoRoute(): bool
/**
* Returns the raw array of available routes.
*
* @param null $verb
* @param mixed $verb
*
* @return array
*/
Expand Down Expand Up @@ -619,9 +619,9 @@ public function map(array $routes = [], array $options = null): RouteCollectionI
* Example:
* $routes->add('news', 'Posts::index');
*
* @param string $from
* @param array|string $to
* @param $options
* @param string $from
* @param array|string $to
* @param array $options
*
* @return RouteCollectionInterface
*/
Expand Down Expand Up @@ -724,7 +724,7 @@ public function getRedirectCode(string $from): int
*
* @return void
*/
public function group($name, ...$params)
public function group(string $name, ...$params)
{
$oldGroup = $this->group;
$oldOptions = $this->currentOptions;
Expand Down
29 changes: 9 additions & 20 deletions system/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,9 @@
namespace CodeIgniter\Router;

use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\Router\Exceptions\RedirectException;
use CodeIgniter\Router\Exceptions\RouterException;

/**
* Routing exception
*/
class RedirectException extends \Exception
{

}

/**
* Request router.
*/
Expand Down Expand Up @@ -154,15 +147,11 @@ public function __construct(RouteCollectionInterface $routes)
//--------------------------------------------------------------------

/**
* Scans the URI and attempts to match the current URI to the
* one of the defined routes in the RouteCollection.
*
* This is the main entry point when using the Router.
* @param string|null $uri
*
* @param string $uri
*
* @return mixed
* @throws \CodeIgniter\Router\RedirectException
* @return mixed|string
* @throws \CodeIgniter\Router\Exceptions\RedirectException
* @throws \CodeIgniter\Exceptions\PageNotFoundException
*/
public function handle(string $uri = null)
{
Expand Down Expand Up @@ -394,7 +383,7 @@ public function getLocale()
* @param string $uri The URI path to compare against the routes
*
* @return boolean Whether the route was matched or not.
* @throws \CodeIgniter\Router\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
*/
protected function checkRoutes(string $uri): bool
{
Expand Down Expand Up @@ -491,7 +480,7 @@ protected function checkRoutes(string $uri): bool
// Is this route supposed to redirect to another?
if ($this->collection->isRedirect($key))
{
throw new RedirectException($val, $this->collection->getRedirectCode($key));
throw RedirectException::forUnableToRedirect($val, $this->collection->getRedirectCode($key));
}

$this->setRequest(explode('/', $val));
Expand Down Expand Up @@ -573,7 +562,7 @@ public function autoRoute(string $uri)
*
* @return array URI segments
*/
protected function validateRequest(array $segments)
protected function validateRequest(array $segments): array
{
$segments = array_filter($segments);

Expand Down Expand Up @@ -608,7 +597,7 @@ protected function validateRequest(array $segments)
* @param string|null $dir
* @param boolean|false $append
*/
protected function setDirectory(string $dir = null, $append = false)
protected function setDirectory(string $dir = null, bool $append = false)
{
$dir = ucfirst($dir);

Expand Down
14 changes: 7 additions & 7 deletions system/Test/FeatureTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function skipEvents()
* @param array|null $params
*
* @return \CodeIgniter\Test\FeatureResponse
* @throws \CodeIgniter\HTTP\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
* @throws \Exception
*/
public function call(string $method, string $path, array $params = null)
Expand Down Expand Up @@ -179,7 +179,7 @@ public function call(string $method, string $path, array $params = null)
* @param array|null $params
*
* @return \CodeIgniter\Test\FeatureResponse
* @throws \CodeIgniter\HTTP\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
* @throws \Exception
*/
public function get(string $path, array $params = null)
Expand All @@ -194,7 +194,7 @@ public function get(string $path, array $params = null)
* @param array|null $params
*
* @return \CodeIgniter\Test\FeatureResponse
* @throws \CodeIgniter\HTTP\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
* @throws \Exception
*/
public function post(string $path, array $params = null)
Expand All @@ -209,7 +209,7 @@ public function post(string $path, array $params = null)
* @param array|null $params
*
* @return \CodeIgniter\Test\FeatureResponse
* @throws \CodeIgniter\HTTP\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
* @throws \Exception
*/
public function put(string $path, array $params = null)
Expand All @@ -224,7 +224,7 @@ public function put(string $path, array $params = null)
* @param array|null $params
*
* @return \CodeIgniter\Test\FeatureResponse
* @throws \CodeIgniter\HTTP\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
* @throws \Exception
*/
public function patch(string $path, array $params = null)
Expand All @@ -239,7 +239,7 @@ public function patch(string $path, array $params = null)
* @param array|null $params
*
* @return \CodeIgniter\Test\FeatureResponse
* @throws \CodeIgniter\HTTP\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
* @throws \Exception
*/
public function delete(string $path, array $params = null)
Expand All @@ -254,7 +254,7 @@ public function delete(string $path, array $params = null)
* @param array|null $params
*
* @return \CodeIgniter\Test\FeatureResponse
* @throws \CodeIgniter\HTTP\RedirectException
* @throws \CodeIgniter\Router\Exceptions\RedirectException
* @throws \Exception
*/
public function options(string $path, array $params = null)
Expand Down

0 comments on commit 999d9f1

Please sign in to comment.