mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
Development
- Removed unused exception from PHP-docs. - Fixed types not same as declared. - Fixed issues with reg-ex and php-unit tests. - Removed unnecessary type casting. - Declared functions as static (better scoping + performance). - Moved `\is_callable($callback) === false` as the execution costs less than previous in `Router.php`. - Changed `ob_get_contents` to `ob_get_clean`. - Added type hints to methods.
This commit is contained in:
@@ -20,7 +20,7 @@ class Url implements \JsonSerializable
|
||||
/**
|
||||
* Url constructor.
|
||||
*
|
||||
* @param string $url
|
||||
* @param ?string $url
|
||||
* @throws MalformedUrlException
|
||||
*/
|
||||
public function __construct(?string $url)
|
||||
@@ -385,7 +385,7 @@ class Url implements \JsonSerializable
|
||||
{
|
||||
$encodedUrl = preg_replace_callback(
|
||||
'/[^:\/@?&=#]+/u',
|
||||
function ($matches) {
|
||||
static function ($matches) {
|
||||
return urlencode($matches[0]);
|
||||
},
|
||||
$url
|
||||
@@ -412,7 +412,7 @@ class Url implements \JsonSerializable
|
||||
if (\count($getParams) !== 0) {
|
||||
|
||||
if ($includeEmpty === false) {
|
||||
$getParams = array_filter($getParams, function ($item) {
|
||||
$getParams = array_filter($getParams, static function ($item) {
|
||||
return (trim($item) !== '');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user