From a0e971a78d28bb81e0f86adae0c8f6b0fd359090 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Sat, 24 Aug 2024 15:19:49 -0300 Subject: [PATCH] Upgrade coding standard --- composer.json | 2 +- src/Attributes/Route.php | 2 +- src/RouteCollection.php | 66 ++++++++++++++++++++-------------------- src/Router.php | 10 +++--- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/composer.json b/composer.json index 17b3ef7..663387c 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ }, "require-dev": { "ext-xdebug": "*", - "aplus/coding-standard": "^2.0", + "aplus/coding-standard": "^2.8", "ergebnis/composer-normalize": "^2.25", "jetbrains/phpstorm-attributes": "^1.0", "phpmd/phpmd": "^2.13", diff --git a/src/Attributes/Route.php b/src/Attributes/Route.php index fb5fc89..7e2309c 100644 --- a/src/Attributes/Route.php +++ b/src/Attributes/Route.php @@ -44,7 +44,7 @@ public function __construct( array | string $methods, string $path, string $arguments = '*', - string $name = null, + ?string $name = null, array | string $origins = [], ) { $methods = (array) $methods; diff --git a/src/RouteCollection.php b/src/RouteCollection.php index 6579819..6121a9c 100644 --- a/src/RouteCollection.php +++ b/src/RouteCollection.php @@ -51,7 +51,7 @@ class RouteCollection implements \Countable, \JsonSerializable * `{scheme}://{hostname}[:{port}]` * @param string|null $name The collection name */ - public function __construct(Router $router, string $origin, string $name = null) + public function __construct(Router $router, string $origin, ?string $name = null) { $this->router = $router; $this->setOrigin($origin); @@ -206,7 +206,7 @@ protected function getRouteNotFound() : ?Route * * @param array $httpMethods The HTTP Methods * @param string $path The URL path - * @param array|Closure|string $action The Route action + * @param Closure|array|string $action The Route action * @param string|null $name The Route name * * @see Method::DELETE @@ -221,8 +221,8 @@ protected function getRouteNotFound() : ?Route public function add( array $httpMethods, string $path, - array | Closure | string $action, - string $name = null + Closure | array | string $action, + ?string $name = null ) : Route { $route = $this->makeRoute($path, $action, $name); foreach ($httpMethods as $method) { @@ -233,15 +233,15 @@ public function add( /** * @param string $path - * @param array|Closure|string $action + * @param Closure|array|string $action * @param string|null $name * * @return Route */ protected function makeRoute( string $path, - array | Closure | string $action, - string $name = null + Closure | array | string $action, + ?string $name = null ) : Route { if (\is_array($action)) { $action = $this->makeRouteActionFromArray($action); @@ -256,7 +256,7 @@ protected function makeRoute( /** * @param string $method * @param string $path - * @param array|Closure|string $action + * @param Closure|array|string $action * @param string|null $name * * @return Route @@ -264,8 +264,8 @@ protected function makeRoute( protected function addSimple( string $method, string $path, - array | Closure | string $action, - string $name = null + Closure | array | string $action, + ?string $name = null ) : Route { return $this->routes[$method][] = $this->makeRoute($path, $action, $name); } @@ -298,7 +298,7 @@ protected function makeRouteActionFromArray(array $action) : string * Adds a Route to match the HTTP GET Method. * * @param string $path The URL path - * @param array|Closure|string $action The Route action + * @param Closure|array|string $action The Route action * @param string|null $name The Route name * * @see Method::GET @@ -307,8 +307,8 @@ protected function makeRouteActionFromArray(array $action) : string */ public function get( string $path, - array | Closure | string $action, - string $name = null + Closure | array | string $action, + ?string $name = null ) : Route { return $this->addSimple('GET', $path, $action, $name); } @@ -317,7 +317,7 @@ public function get( * Adds a Route to match the HTTP POST Method. * * @param string $path The URL path - * @param array|Closure|string $action The Route action + * @param Closure|array|string $action The Route action * @param string|null $name The Route name * * @see Method::POST @@ -326,8 +326,8 @@ public function get( */ public function post( string $path, - array | Closure | string $action, - string $name = null + Closure | array | string $action, + ?string $name = null ) : Route { return $this->addSimple('POST', $path, $action, $name); } @@ -336,7 +336,7 @@ public function post( * Adds a Route to match the HTTP PUT Method. * * @param string $path The URL path - * @param array|Closure|string $action The Route action + * @param Closure|array|string $action The Route action * @param string|null $name The Route name * * @see Method::PUT @@ -345,8 +345,8 @@ public function post( */ public function put( string $path, - array | Closure | string $action, - string $name = null + Closure | array | string $action, + ?string $name = null ) : Route { return $this->addSimple('PUT', $path, $action, $name); } @@ -355,7 +355,7 @@ public function put( * Adds a Route to match the HTTP PATCH Method. * * @param string $path The URL path - * @param array|Closure|string $action The Route action + * @param Closure|array|string $action The Route action * @param string|null $name The Route name * * @see Method::PATCH @@ -364,8 +364,8 @@ public function put( */ public function patch( string $path, - array | Closure | string $action, - string $name = null + Closure | array | string $action, + ?string $name = null ) : Route { return $this->addSimple('PATCH', $path, $action, $name); } @@ -374,7 +374,7 @@ public function patch( * Adds a Route to match the HTTP DELETE Method. * * @param string $path The URL path - * @param array|Closure|string $action The Route action + * @param Closure|array|string $action The Route action * @param string|null $name The Route name * * @see Method::DELETE @@ -383,8 +383,8 @@ public function patch( */ public function delete( string $path, - array | Closure | string $action, - string $name = null + Closure | array | string $action, + ?string $name = null ) : Route { return $this->addSimple('DELETE', $path, $action, $name); } @@ -393,7 +393,7 @@ public function delete( * Adds a Route to match the HTTP OPTIONS Method. * * @param string $path The URL path - * @param array|Closure|string $action The Route action + * @param Closure|array|string $action The Route action * @param string|null $name The Route name * * @see Method::OPTIONS @@ -402,8 +402,8 @@ public function delete( */ public function options( string $path, - array | Closure | string $action, - string $name = null + Closure | array | string $action, + ?string $name = null ) : Route { return $this->addSimple('OPTIONS', $path, $action, $name); } @@ -422,7 +422,7 @@ public function redirect( string $path, string $location, int $code = Status::TEMPORARY_REDIRECT, - string $name = null + ?string $name = null ) : Route { $response = $this->router->getResponse(); return $this->addSimple( @@ -442,10 +442,10 @@ static function (array $args) use ($response, $location, $code) : void { * Groups many Routes into a URL path. * * @param string $basePath The URL path to group in - * @param array|Route> $routes The Routes to be grouped + * @param array> $routes The Routes to be grouped * @param array $options Custom options passed to the Routes * - * @return array|Route> The same $routes with updated paths and options + * @return array> The same $routes with updated paths and options */ public function group(string $basePath, array $routes, array $options = []) : array { @@ -471,9 +471,9 @@ public function group(string $basePath, array $routes, array $options = []) : ar * Updates Routes actions, which are strings, prepending a namespace. * * @param string $namespace The namespace - * @param array|Route> $routes The Routes + * @param array> $routes The Routes * - * @return array|Route> The same $routes with updated actions + * @return array> The same $routes with updated actions */ public function namespace(string $namespace, array $routes) : array { diff --git a/src/Router.php b/src/Router.php index 418e7a6..73cf92e 100644 --- a/src/Router.php +++ b/src/Router.php @@ -79,7 +79,7 @@ class Router implements \JsonSerializable * @param Response $response * @param Language|null $language */ - public function __construct(Response $response, Language $language = null) + public function __construct(Response $response, ?Language $language = null) { $this->response = $response; if ($language) { @@ -108,7 +108,7 @@ public function getResponse() : Response return $this->response; } - public function setLanguage(Language $language = null) : static + public function setLanguage(?Language $language = null) : static { $this->language = $language ?? new Language(); $this->language->addDirectory(__DIR__ . '/Languages'); @@ -244,7 +244,7 @@ public function getRouteNotFound() : Route * * @return static */ - public function addPlaceholder(array | string $placeholder, string $pattern = null) : static + public function addPlaceholder(array | string $placeholder, ?string $pattern = null) : static { if (\is_array($placeholder)) { foreach ($placeholder as $key => $value) { @@ -338,7 +338,7 @@ public function fillPlaceholders(string $string, string ...$arguments) : string * * @return static */ - public function serve(?string $origin, callable $callable, string $collectionName = null) : static + public function serve(?string $origin, callable $callable, ?string $collectionName = null) : static { if (isset($this->debugCollector)) { $start = \microtime(true); @@ -360,7 +360,7 @@ public function serve(?string $origin, callable $callable, string $collectionNam protected function addServedCollection( ?string $origin, callable $callable, - string $collectionName = null + ?string $collectionName = null ) : static { if ($origin === null) { $origin = $this->response->getRequest()->getUrl()->getOrigin(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy