Skip to content

Commit

Permalink
Upgrade coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Aug 24, 2024
1 parent 6881992 commit a0e971a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Attributes/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
66 changes: 33 additions & 33 deletions src/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -206,7 +206,7 @@ protected function getRouteNotFound() : ?Route
*
* @param array<int,string> $httpMethods The HTTP Methods
* @param string $path The URL path
* @param array<int,string>|Closure|string $action The Route action
* @param Closure|array<int,string>|string $action The Route action
* @param string|null $name The Route name
*
* @see Method::DELETE
Expand All @@ -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) {
Expand All @@ -233,15 +233,15 @@ public function add(

/**
* @param string $path
* @param array<int,string>|Closure|string $action
* @param Closure|array<int,string>|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);
Expand All @@ -256,16 +256,16 @@ protected function makeRoute(
/**
* @param string $method
* @param string $path
* @param array<int,string>|Closure|string $action
* @param Closure|array<int,string>|string $action
* @param string|null $name
*
* @return Route
*/
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);
}
Expand Down Expand Up @@ -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<int,string>|Closure|string $action The Route action
* @param Closure|array<int,string>|string $action The Route action
* @param string|null $name The Route name
*
* @see Method::GET
Expand All @@ -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);
}
Expand All @@ -317,7 +317,7 @@ public function get(
* Adds a Route to match the HTTP POST Method.
*
* @param string $path The URL path
* @param array<int,string>|Closure|string $action The Route action
* @param Closure|array<int,string>|string $action The Route action
* @param string|null $name The Route name
*
* @see Method::POST
Expand All @@ -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);
}
Expand All @@ -336,7 +336,7 @@ public function post(
* Adds a Route to match the HTTP PUT Method.
*
* @param string $path The URL path
* @param array<int,string>|Closure|string $action The Route action
* @param Closure|array<int,string>|string $action The Route action
* @param string|null $name The Route name
*
* @see Method::PUT
Expand All @@ -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);
}
Expand All @@ -355,7 +355,7 @@ public function put(
* Adds a Route to match the HTTP PATCH Method.
*
* @param string $path The URL path
* @param array<int,string>|Closure|string $action The Route action
* @param Closure|array<int,string>|string $action The Route action
* @param string|null $name The Route name
*
* @see Method::PATCH
Expand All @@ -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);
}
Expand All @@ -374,7 +374,7 @@ public function patch(
* Adds a Route to match the HTTP DELETE Method.
*
* @param string $path The URL path
* @param array<int,string>|Closure|string $action The Route action
* @param Closure|array<int,string>|string $action The Route action
* @param string|null $name The Route name
*
* @see Method::DELETE
Expand All @@ -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);
}
Expand All @@ -393,7 +393,7 @@ public function delete(
* Adds a Route to match the HTTP OPTIONS Method.
*
* @param string $path The URL path
* @param array<int,string>|Closure|string $action The Route action
* @param Closure|array<int,string>|string $action The Route action
* @param string|null $name The Route name
*
* @see Method::OPTIONS
Expand All @@ -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);
}
Expand All @@ -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(
Expand All @@ -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<array<mixed|Route>|Route> $routes The Routes to be grouped
* @param array<Route|array<Route|mixed>> $routes The Routes to be grouped
* @param array<string,mixed> $options Custom options passed to the Routes
*
* @return array<array<mixed|Route>|Route> The same $routes with updated paths and options
* @return array<Route|array<Route|mixed>> The same $routes with updated paths and options
*/
public function group(string $basePath, array $routes, array $options = []) : array
{
Expand All @@ -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<array<mixed|Route>|Route> $routes The Routes
* @param array<Route|array<Route|mixed>> $routes The Routes
*
* @return array<array<mixed|Route>|Route> The same $routes with updated actions
* @return array<Route|array<Route|mixed>> The same $routes with updated actions
*/
public function namespace(string $namespace, array $routes) : array
{
Expand Down
10 changes: 5 additions & 5 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit a0e971a

Please sign in to comment.