Skip to content

Commit a0e971a

Browse files
committed
Upgrade coding standard
1 parent 6881992 commit a0e971a

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"require-dev": {
4242
"ext-xdebug": "*",
43-
"aplus/coding-standard": "^2.0",
43+
"aplus/coding-standard": "^2.8",
4444
"ergebnis/composer-normalize": "^2.25",
4545
"jetbrains/phpstorm-attributes": "^1.0",
4646
"phpmd/phpmd": "^2.13",

src/Attributes/Route.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(
4444
array | string $methods,
4545
string $path,
4646
string $arguments = '*',
47-
string $name = null,
47+
?string $name = null,
4848
array | string $origins = [],
4949
) {
5050
$methods = (array) $methods;

src/RouteCollection.php

+33-33
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class RouteCollection implements \Countable, \JsonSerializable
5151
* `{scheme}://{hostname}[:{port}]`
5252
* @param string|null $name The collection name
5353
*/
54-
public function __construct(Router $router, string $origin, string $name = null)
54+
public function __construct(Router $router, string $origin, ?string $name = null)
5555
{
5656
$this->router = $router;
5757
$this->setOrigin($origin);
@@ -206,7 +206,7 @@ protected function getRouteNotFound() : ?Route
206206
*
207207
* @param array<int,string> $httpMethods The HTTP Methods
208208
* @param string $path The URL path
209-
* @param array<int,string>|Closure|string $action The Route action
209+
* @param Closure|array<int,string>|string $action The Route action
210210
* @param string|null $name The Route name
211211
*
212212
* @see Method::DELETE
@@ -221,8 +221,8 @@ protected function getRouteNotFound() : ?Route
221221
public function add(
222222
array $httpMethods,
223223
string $path,
224-
array | Closure | string $action,
225-
string $name = null
224+
Closure | array | string $action,
225+
?string $name = null
226226
) : Route {
227227
$route = $this->makeRoute($path, $action, $name);
228228
foreach ($httpMethods as $method) {
@@ -233,15 +233,15 @@ public function add(
233233

234234
/**
235235
* @param string $path
236-
* @param array<int,string>|Closure|string $action
236+
* @param Closure|array<int,string>|string $action
237237
* @param string|null $name
238238
*
239239
* @return Route
240240
*/
241241
protected function makeRoute(
242242
string $path,
243-
array | Closure | string $action,
244-
string $name = null
243+
Closure | array | string $action,
244+
?string $name = null
245245
) : Route {
246246
if (\is_array($action)) {
247247
$action = $this->makeRouteActionFromArray($action);
@@ -256,16 +256,16 @@ protected function makeRoute(
256256
/**
257257
* @param string $method
258258
* @param string $path
259-
* @param array<int,string>|Closure|string $action
259+
* @param Closure|array<int,string>|string $action
260260
* @param string|null $name
261261
*
262262
* @return Route
263263
*/
264264
protected function addSimple(
265265
string $method,
266266
string $path,
267-
array | Closure | string $action,
268-
string $name = null
267+
Closure | array | string $action,
268+
?string $name = null
269269
) : Route {
270270
return $this->routes[$method][] = $this->makeRoute($path, $action, $name);
271271
}
@@ -298,7 +298,7 @@ protected function makeRouteActionFromArray(array $action) : string
298298
* Adds a Route to match the HTTP GET Method.
299299
*
300300
* @param string $path The URL path
301-
* @param array<int,string>|Closure|string $action The Route action
301+
* @param Closure|array<int,string>|string $action The Route action
302302
* @param string|null $name The Route name
303303
*
304304
* @see Method::GET
@@ -307,8 +307,8 @@ protected function makeRouteActionFromArray(array $action) : string
307307
*/
308308
public function get(
309309
string $path,
310-
array | Closure | string $action,
311-
string $name = null
310+
Closure | array | string $action,
311+
?string $name = null
312312
) : Route {
313313
return $this->addSimple('GET', $path, $action, $name);
314314
}
@@ -317,7 +317,7 @@ public function get(
317317
* Adds a Route to match the HTTP POST Method.
318318
*
319319
* @param string $path The URL path
320-
* @param array<int,string>|Closure|string $action The Route action
320+
* @param Closure|array<int,string>|string $action The Route action
321321
* @param string|null $name The Route name
322322
*
323323
* @see Method::POST
@@ -326,8 +326,8 @@ public function get(
326326
*/
327327
public function post(
328328
string $path,
329-
array | Closure | string $action,
330-
string $name = null
329+
Closure | array | string $action,
330+
?string $name = null
331331
) : Route {
332332
return $this->addSimple('POST', $path, $action, $name);
333333
}
@@ -336,7 +336,7 @@ public function post(
336336
* Adds a Route to match the HTTP PUT Method.
337337
*
338338
* @param string $path The URL path
339-
* @param array<int,string>|Closure|string $action The Route action
339+
* @param Closure|array<int,string>|string $action The Route action
340340
* @param string|null $name The Route name
341341
*
342342
* @see Method::PUT
@@ -345,8 +345,8 @@ public function post(
345345
*/
346346
public function put(
347347
string $path,
348-
array | Closure | string $action,
349-
string $name = null
348+
Closure | array | string $action,
349+
?string $name = null
350350
) : Route {
351351
return $this->addSimple('PUT', $path, $action, $name);
352352
}
@@ -355,7 +355,7 @@ public function put(
355355
* Adds a Route to match the HTTP PATCH Method.
356356
*
357357
* @param string $path The URL path
358-
* @param array<int,string>|Closure|string $action The Route action
358+
* @param Closure|array<int,string>|string $action The Route action
359359
* @param string|null $name The Route name
360360
*
361361
* @see Method::PATCH
@@ -364,8 +364,8 @@ public function put(
364364
*/
365365
public function patch(
366366
string $path,
367-
array | Closure | string $action,
368-
string $name = null
367+
Closure | array | string $action,
368+
?string $name = null
369369
) : Route {
370370
return $this->addSimple('PATCH', $path, $action, $name);
371371
}
@@ -374,7 +374,7 @@ public function patch(
374374
* Adds a Route to match the HTTP DELETE Method.
375375
*
376376
* @param string $path The URL path
377-
* @param array<int,string>|Closure|string $action The Route action
377+
* @param Closure|array<int,string>|string $action The Route action
378378
* @param string|null $name The Route name
379379
*
380380
* @see Method::DELETE
@@ -383,8 +383,8 @@ public function patch(
383383
*/
384384
public function delete(
385385
string $path,
386-
array | Closure | string $action,
387-
string $name = null
386+
Closure | array | string $action,
387+
?string $name = null
388388
) : Route {
389389
return $this->addSimple('DELETE', $path, $action, $name);
390390
}
@@ -393,7 +393,7 @@ public function delete(
393393
* Adds a Route to match the HTTP OPTIONS Method.
394394
*
395395
* @param string $path The URL path
396-
* @param array<int,string>|Closure|string $action The Route action
396+
* @param Closure|array<int,string>|string $action The Route action
397397
* @param string|null $name The Route name
398398
*
399399
* @see Method::OPTIONS
@@ -402,8 +402,8 @@ public function delete(
402402
*/
403403
public function options(
404404
string $path,
405-
array | Closure | string $action,
406-
string $name = null
405+
Closure | array | string $action,
406+
?string $name = null
407407
) : Route {
408408
return $this->addSimple('OPTIONS', $path, $action, $name);
409409
}
@@ -422,7 +422,7 @@ public function redirect(
422422
string $path,
423423
string $location,
424424
int $code = Status::TEMPORARY_REDIRECT,
425-
string $name = null
425+
?string $name = null
426426
) : Route {
427427
$response = $this->router->getResponse();
428428
return $this->addSimple(
@@ -442,10 +442,10 @@ static function (array $args) use ($response, $location, $code) : void {
442442
* Groups many Routes into a URL path.
443443
*
444444
* @param string $basePath The URL path to group in
445-
* @param array<array<mixed|Route>|Route> $routes The Routes to be grouped
445+
* @param array<Route|array<Route|mixed>> $routes The Routes to be grouped
446446
* @param array<string,mixed> $options Custom options passed to the Routes
447447
*
448-
* @return array<array<mixed|Route>|Route> The same $routes with updated paths and options
448+
* @return array<Route|array<Route|mixed>> The same $routes with updated paths and options
449449
*/
450450
public function group(string $basePath, array $routes, array $options = []) : array
451451
{
@@ -471,9 +471,9 @@ public function group(string $basePath, array $routes, array $options = []) : ar
471471
* Updates Routes actions, which are strings, prepending a namespace.
472472
*
473473
* @param string $namespace The namespace
474-
* @param array<array<mixed|Route>|Route> $routes The Routes
474+
* @param array<Route|array<Route|mixed>> $routes The Routes
475475
*
476-
* @return array<array<mixed|Route>|Route> The same $routes with updated actions
476+
* @return array<Route|array<Route|mixed>> The same $routes with updated actions
477477
*/
478478
public function namespace(string $namespace, array $routes) : array
479479
{

src/Router.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Router implements \JsonSerializable
7979
* @param Response $response
8080
* @param Language|null $language
8181
*/
82-
public function __construct(Response $response, Language $language = null)
82+
public function __construct(Response $response, ?Language $language = null)
8383
{
8484
$this->response = $response;
8585
if ($language) {
@@ -108,7 +108,7 @@ public function getResponse() : Response
108108
return $this->response;
109109
}
110110

111-
public function setLanguage(Language $language = null) : static
111+
public function setLanguage(?Language $language = null) : static
112112
{
113113
$this->language = $language ?? new Language();
114114
$this->language->addDirectory(__DIR__ . '/Languages');
@@ -244,7 +244,7 @@ public function getRouteNotFound() : Route
244244
*
245245
* @return static
246246
*/
247-
public function addPlaceholder(array | string $placeholder, string $pattern = null) : static
247+
public function addPlaceholder(array | string $placeholder, ?string $pattern = null) : static
248248
{
249249
if (\is_array($placeholder)) {
250250
foreach ($placeholder as $key => $value) {
@@ -338,7 +338,7 @@ public function fillPlaceholders(string $string, string ...$arguments) : string
338338
*
339339
* @return static
340340
*/
341-
public function serve(?string $origin, callable $callable, string $collectionName = null) : static
341+
public function serve(?string $origin, callable $callable, ?string $collectionName = null) : static
342342
{
343343
if (isset($this->debugCollector)) {
344344
$start = \microtime(true);
@@ -360,7 +360,7 @@ public function serve(?string $origin, callable $callable, string $collectionNam
360360
protected function addServedCollection(
361361
?string $origin,
362362
callable $callable,
363-
string $collectionName = null
363+
?string $collectionName = null
364364
) : static {
365365
if ($origin === null) {
366366
$origin = $this->response->getRequest()->getUrl()->getOrigin();

0 commit comments

Comments
 (0)