From a52b673cf4c7e26bd65dff1c783c5087685d5d24 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Mon, 13 Oct 2025 13:47:29 +0200 Subject: [PATCH] Function findByIdAsArray return null when user is not found --- Repository/UserRepository.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Repository/UserRepository.php b/Repository/UserRepository.php index befe695..2aa8e3b 100644 --- a/Repository/UserRepository.php +++ b/Repository/UserRepository.php @@ -282,9 +282,9 @@ SQL; * Find user by id as array * * @param integer $id The user id - * @return array The article array + * @return ?array The article array */ - public function findByIdAsArray(int $id): array { + public function findByIdAsArray(int $id): ?array { //Set the request $req = <<addScalarResult('kt_titles', 'kt_titles', 'string'); //Get data - $data = $this->_em + if (($data = $this->_em ->createNativeQuery($req, $rsm) ->setParameter('id', $id) - ->getOneOrNullResult(); + ->getOneOrNullResult()) === null) { + //Return null + return $data; + } //Set return $return = [ -- 2.41.3