apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -27,10 +27,6 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
use function key;
use function reset;
/**
* Class SearchController.
*/
@@ -50,8 +46,7 @@ class SearchController extends AbstractController
$search = $this->searchProvider
->getHasAdvancedFormByName($name);
} catch (\Chill\MainBundle\Search\UnknowSearchNameException) {
throw $this->createNotFoundException('no advanced search for '
. "{$name}");
throw $this->createNotFoundException('no advanced search for '."{$name}");
}
if ($request->query->has('q')) {
@@ -96,7 +91,7 @@ class SearchController extends AbstractController
$advancedSearchProviders = $searchProvider
->getHasAdvancedFormSearchServices();
if (count($advancedSearchProviders) === 1) {
if (1 === \count($advancedSearchProviders)) {
return $this->redirectToRoute('chill_main_advanced_search', [
'name' => array_key_first($advancedSearchProviders),
]);
@@ -119,7 +114,7 @@ class SearchController extends AbstractController
'@ChillMain/Search/error.html.twig',
[
'message' => $this->translator->trans('Your search is empty. '
. 'Please provide search terms.'),
.'Please provide search terms.'),
'pattern' => $pattern,
]
);
@@ -138,7 +133,7 @@ class SearchController extends AbstractController
if (null === $name) {
if ('json' === $_format) {
return new JsonResponse('Currently, we still do not aggregate results '
. 'from different providers', JsonResponse::HTTP_BAD_REQUEST);
.'from different providers', JsonResponse::HTTP_BAD_REQUEST);
}
// no specific search selected. Rendering result in "preview" mode
@@ -166,7 +161,7 @@ class SearchController extends AbstractController
), ];
if ('json' === $_format) {
return new JsonResponse(reset($results));
return new JsonResponse(\reset($results));
}
}
} catch (UnknowSearchDomainException $ex) {
@@ -174,18 +169,18 @@ class SearchController extends AbstractController
'@ChillMain/Search/error.html.twig',
[
'message' => $this->translator->trans('The domain %domain% '
. 'is unknow. Please check your search.', ['%domain%' => $ex->getDomain()]),
.'is unknow. Please check your search.', ['%domain%' => $ex->getDomain()]),
'pattern' => $pattern,
]
);
} catch (UnknowSearchNameException $ex) {
throw $this->createNotFoundException('The name ' . $ex->getName() . ' is not found');
throw $this->createNotFoundException('The name '.$ex->getName().' is not found');
} catch (ParsingException $ex) {
return $this->render(
'@ChillMain/Search/error.html.twig',
[
'message' => $this->translator->trans('Invalid terms') .
': ' . $this->translator->trans($ex->getMessage()),
'message' => $this->translator->trans('Invalid terms').
': '.$this->translator->trans($ex->getMessage()),
'pattern' => $pattern,
]
);
@@ -202,13 +197,12 @@ class SearchController extends AbstractController
*/
public function searchApi(Request $request, mixed $_format): JsonResponse
{
//TODO this is an incomplete implementation
// TODO this is an incomplete implementation
$query = $request->query->get('q', '');
$types = $request->query->get('type', []);
if (count($types) === 0) {
throw new BadRequestHttpException('The request must contains at '
. ' one type');
if (0 === \count($types)) {
throw new BadRequestHttpException('The request must contains at one type');
}
try {