diff --git a/src/Bundle/ChillEventBundle/Search/EventSearch.php b/src/Bundle/ChillEventBundle/Search/EventSearch.php index 90eca34bc..a7ac22592 100644 --- a/src/Bundle/ChillEventBundle/Search/EventSearch.php +++ b/src/Bundle/ChillEventBundle/Search/EventSearch.php @@ -113,27 +113,23 @@ class EventSearch extends AbstractSearch ] ); } + // format is "json" + $results = []; + $search = $this->search($terms, $start, $limit, $options); - if ('json' === $format) { - $results = []; - $search = $this->search($terms, $start, $limit, $options); - - foreach ($search as $item) { - $results[] = [ - 'id' => $item->getId(), - 'text' => $item->getDate()->format('d/m/Y, H:i') . ' → ' . - // $item->getType()->getName()['fr'] . ': ' . // display the type of event - $item->getName(), - ]; - } - - return [ - 'results' => $results, - 'pagination' => [ - 'more' => $paginator->hasNextPage(), - ], + foreach ($search as $item) { + $results[] = [ + 'id' => $item->getId(), + 'text' => $item->getDate()->format('d/m/Y, H:i') . ' → ' . + // $item->getType()->getName()['fr'] . ': ' . // display the type of event + $item->getName(), ]; } + + return [ + 'results' => $results, + 'more' => $paginator->hasNextPage(), + ]; } public function supports($domain, $format) diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php index a6688fca2..3cff6583e 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php @@ -211,7 +211,7 @@ trait AddWidgetConfigurationTrait * * @throws InvalidConfigurationException if a service's tag does not have the "alias" key * - * @return type + * @return array */ protected function getWidgetAliasesbyPlace($place, ContainerBuilder $containerBuilder) { diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php index aca165652..a21f49b2c 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/MultipleObjectsToIdTransformer.php @@ -31,8 +31,6 @@ class MultipleObjectsToIdTransformer implements DataTransformerInterface * Transforms a string (id) to an object (item). * * @param mixed $array - * - * @return ArrayCollection */ public function reverseTransform($array) { @@ -53,10 +51,8 @@ class MultipleObjectsToIdTransformer implements DataTransformerInterface * Transforms an object (use) to a string (id). * * @param array $array - * - * @return ArrayCollection */ - public function transform($array) + public function transform($array): array { $ret = []; diff --git a/src/Bundle/ChillMainBundle/Search/SearchInterface.php b/src/Bundle/ChillMainBundle/Search/SearchInterface.php index 7fced2ff9..a7cd285fe 100644 --- a/src/Bundle/ChillMainBundle/Search/SearchInterface.php +++ b/src/Bundle/ChillMainBundle/Search/SearchInterface.php @@ -71,9 +71,9 @@ interface SearchInterface * @param array $terms the string to search * @param int $start the first result (for pagination) * @param int $limit the number of result (for pagination) - * @param string $format The format for result + * @param "html"|"json" $format The format for result * - * @return string, an HTML string + * @return string|array a string if format is html, an array if format is json */ public function renderResult(array $terms, $start = 0, $limit = 50, array $options = [], $format = 'html'); diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php index 768b35a75..828f53757 100644 --- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php +++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php @@ -63,6 +63,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface * * @param User $user The user * @param array $centers a list of centers which are going to be filtered + * @param mixed $role */ public function filterReachableCenters(User $user, array $centers, $role): array { diff --git a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php index 3de2fd4f1..7cd1849a3 100644 --- a/src/Bundle/ChillPersonBundle/Search/PersonSearch.php +++ b/src/Bundle/ChillPersonBundle/Search/PersonSearch.php @@ -203,15 +203,6 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf return true; } - /** - * (non-PHPdoc). - * - * @see \Chill\MainBundle\Search\SearchInterface::renderResult() - * - * @param mixed $start - * @param mixed $limit - * @param mixed $format - */ public function renderResult(array $terms, $start = 0, $limit = 50, array $options = [], $format = 'html') { $terms = $this->findAdditionnalInDefault($terms); @@ -236,15 +227,13 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf ] ); } - - if ('json' === $format) { - return [ - 'results' => $this->search($terms, $start, $limit, array_merge($options, ['simplify' => true])), - 'pagination' => [ - 'more' => $paginator->hasNextPage(), - ], - ]; - } + // format is "json" + return [ + 'results' => $this->search($terms, $start, $limit, array_merge($options, ['simplify' => true])), + 'pagination' => [ + 'more' => $paginator->hasNextPage(), + ], + ]; } public function supports($domain, $format) diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php index 5a46edad8..ae967ea8d 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartySearch.php @@ -100,6 +100,9 @@ class ThirdPartySearch implements SearchInterface 'more' => $paginator->hasNextPage(), ]; } + if ('html' === $format) { + throw new \UnexpectedValueException("format not supported"); + } } public function supports($domain, $format): bool