diff --git a/be/app/Helper.php b/be/app/Helper.php index 5244853e..6e89de69 100644 --- a/be/app/Helper.php +++ b/be/app/Helper.php @@ -95,7 +95,6 @@ public static function abortAPI(int $errorCode): never throw new \InvalidArgumentException('Given error code doesn\'t existed'); } response()->json(compact('errorCode', 'errorInfo'), $statusCode)->throwResponse(); - exit; } /** diff --git a/be/app/Http/PostsQuery/BaseQuery.php b/be/app/Http/PostsQuery/BaseQuery.php index 975ecbba..5c611ccc 100644 --- a/be/app/Http/PostsQuery/BaseQuery.php +++ b/be/app/Http/PostsQuery/BaseQuery.php @@ -323,6 +323,7 @@ static function (string $postIDName) use ($result): array { * @param Collection $subReplies * @phpcs:ignore Generic.Files.LineLength.TooLong * @return Collection>>>>> + * @SuppressWarnings(PHPMD.CamelCaseParameterName) */ public static function nestPostsWithParent( Collection $threads, diff --git a/be/app/Http/PostsQuery/IndexQuery.php b/be/app/Http/PostsQuery/IndexQuery.php index 4f920b37..5f78ce6b 100644 --- a/be/app/Http/PostsQuery/IndexQuery.php +++ b/be/app/Http/PostsQuery/IndexQuery.php @@ -13,6 +13,9 @@ class IndexQuery extends BaseQuery { + /** + * @SuppressWarnings(PHPMD.ElseExpression) + */ public function query(QueryParams $params, ?string $cursor): self { /** @var array $flatParams key by param name */ diff --git a/be/app/Http/PostsQuery/QueryParams.php b/be/app/Http/PostsQuery/QueryParams.php index 024b7e7f..7521e3d3 100644 --- a/be/app/Http/PostsQuery/QueryParams.php +++ b/be/app/Http/PostsQuery/QueryParams.php @@ -70,6 +70,9 @@ protected function getParamsIndexByName(string $name): array return array_keys(array_filter($this->params, static fn($p) => $p->name === $name)); } + /** + * @SuppressWarnings(PHPMD.ElseExpression) + */ public function addDefaultValueOnUniqueParams(): void { $uniqueParamsDefaultValue = [ diff --git a/be/app/Http/PostsQuery/SearchQuery.php b/be/app/Http/PostsQuery/SearchQuery.php index 77b5f22b..f59ac3a7 100644 --- a/be/app/Http/PostsQuery/SearchQuery.php +++ b/be/app/Http/PostsQuery/SearchQuery.php @@ -156,12 +156,9 @@ private static function applyTextMatchParamOnQuery( trim("$not LIKE"), $subParams['matchBy'] === 'implicit' ? "%$keyword%" : $keyword ); - if ($subParams['spaceSplit']) { // split multiple search keyword by space char - foreach (explode(' ', $value) as $splitedKeyword) { - $addMatchKeyword($splitedKeyword); - } - } else { - $addMatchKeyword($value); + // split multiple search keyword by space char when $subParams['spaceSplit'] == true + foreach ($subParams['spaceSplit'] ? explode(' ', $value) : [$value] as $keyword) { + $addMatchKeyword($keyword); } }); }