From 59d8bf75b214a179912ddbd0affbc4b642a09036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 19 Mar 2026 17:15:23 +0100 Subject: [PATCH] Refactor `PersonACLAwareRepository` to simplify condition handling in search clause construction - Replaced `count` check with an `empty` comparison for clarity. - Streamlined conditional logic for search clause initialization. - Removed unnecessary `isset` check before applying `andWhereClause`. --- .../Repository/PersonACLAwareRepository.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index 0aab3faf3..b8b575008 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -169,8 +169,10 @@ final readonly class PersonACLAwareRepository implements PersonACLAwareRepositor if (null !== $phonenumber) { $personPhoneClause = "person.phonenumber LIKE '%' || ? || '%' OR person.mobilenumber LIKE '%' || ? || '%' OR EXISTS (SELECT 1 FROM chill_person_phone where person_id = person.id AND phonenumber LIKE '%' || ? || '%')"; - if (count($andWhereSearchClauseArgs) > 0) { + if ([] !== $andWhereSearchClauseArgs) { $initialSearchClause = '(('.\implode(' AND ', $andWhereSearchClause).') OR '.$personPhoneClause.')'; + } else { + $initialSearchClause = $personPhoneClause; } $andWhereSearchClauseArgs = [...$andWhereSearchClauseArgs, $phonenumber, $phonenumber, $phonenumber]; @@ -181,12 +183,10 @@ final readonly class PersonACLAwareRepository implements PersonACLAwareRepositor $initialSearchClause = \implode(' AND ', $andWhereSearchClause); } - if (isset($initialSearchClause)) { - $query->andWhereClause( - $initialSearchClause, - $andWhereSearchClauseArgs - ); - } + $query->andWhereClause( + $initialSearchClause, + $andWhereSearchClauseArgs + ); $query ->setSelectPertinence(\implode(' + ', $pertinence), $pertinenceArgs);