Skip to content

Commit

Permalink
uneeded array_values
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Apr 3, 2024
1 parent 383866d commit 12d41a9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
9 changes: 9 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ parameters:
- src/Configuration.php
- src/Mapping/Annotation/Router.php
- src/Route/RouteResolver.php
# Slim's invokation strategy
- message: '/^Parameter #1 \$callable \(callable\(Psr\\Http\\Message\\ServerRequestInterface\): mixed\) of method Jgut\\Slim\\Routing\\Strategy\\RequestHandler::__invoke\(\) should be contravariant with parameter \$callable \(callable\(\): mixed\) of method Slim\\Interfaces\\InvocationStrategyInterface::__invoke\(\)$/'
path: src/Strategy/RequestHandler.php
- message: '/^Parameter #1 \$callable \(callable\(Psr\\Http\\Message\\ServerRequestInterface, Psr\\Http\\Message\\ResponseInterface, array<string, mixed>\): mixed\) of method Jgut\\Slim\\Routing\\Strategy\\RequestResponse::__invoke\(\) should be contravariant with parameter \$callable \(callable\(\): mixed\) of method Slim\\Interfaces\\InvocationStrategyInterface::__invoke\(\)$/'
path: src/Strategy/RequestResponse.php
- message: '/^Parameter #1 \$callable \(callable\(Psr\\Http\\Message\\ServerRequestInterface, Psr\\Http\\Message\\ResponseInterface\): mixed\) of method Jgut\\Slim\\Routing\\Strategy\\RequestResponseArgs::__invoke\(\) should be contravariant with parameter \$callable \(callable\(\): mixed\) of method Slim\\Interfaces\\InvocationStrategyInterface::__invoke\(\)$/'
path: src/Strategy/RequestResponseArgs.php
- message: '/^Parameter #1 \$callable \(callable\(Psr\\Http\\Message\\ServerRequestInterface, Psr\\Http\\Message\\ResponseInterface\): mixed\) of method Jgut\\Slim\\Routing\\Strategy\\RequestResponseNamedArgs::__invoke\(\) should be contravariant with parameter \$callable \(callable\(\): mixed\) of method Slim\\Interfaces\\InvocationStrategyInterface::__invoke\(\)$/'
path: src/Strategy/RequestResponseNamedArgs.php
# Slim's route
- message: '/^Parameter #3 \$callable of method Slim\\Routing\\Route::__construct\(\) expects \(callable\(\): mixed\)\|string, array{string, string}\|\(callable\(\): mixed\)\|string given\.$/'
path: src/Route/Route.php
Expand Down
4 changes: 2 additions & 2 deletions src/Console/AbstractRoutingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class AbstractRoutingCommand extends Command
*/
final protected function getTableRows(array $routes): array
{
return array_values(array_map(
return array_map(
static function (RouteInterface $route): array {
$xmlHttpRequest = false;
if ($route instanceof Route) {
Expand All @@ -50,6 +50,6 @@ static function (RouteInterface $route): array {
];
},
$routes,
));
);
}
}
2 changes: 1 addition & 1 deletion src/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function getMetadata(): array
$routes[] = $this->getRoutesMetadata($class, $groups);
}

return \count($routes) > 0 ? array_values(array_merge(...$routes)) : [];
return \count($routes) > 0 ? array_merge(...$routes) : [];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Mapping/Driver/AttributeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getMetadata(): array
$routes[] = $this->getRoutesMetadata($class, $groups);
}

return \count($routes) > 0 ? array_values(array_merge(...$routes)) : [];
return \count($routes) > 0 ? array_merge(...$routes) : [];
}

/**
Expand Down Expand Up @@ -245,7 +245,7 @@ private function populateTransformer(
}

$metadata->setParameters($parameters);
$metadata->setTransformers(array_values($transformers));
$metadata->setTransformers($transformers);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Mapping/Driver/FileMappingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected function getRoutesMetadata(array $mappingData, ?GroupMetadata $group =
}
}

return \count($routes) > 0 ? array_values(array_merge(...$routes)) : [];
return \count($routes) > 0 ? array_merge(...$routes) : [];
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Route/RouteResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getMiddleware(RouteMetadata $route): array
));
array_unshift($middleware, $route->getMiddlewares());

return array_values(array_merge(...$middleware));
return array_merge(...$middleware);
}

/**
Expand Down Expand Up @@ -249,9 +249,9 @@ static function (array $itemA, array $itemB) use ($sortFunction): int {
},
);

return array_values(array_map(
return array_map(
static fn(array $item): RouteMetadata => $item[1],
$sortArray,
));
);
}
}

0 comments on commit 12d41a9

Please sign in to comment.