From 9bfe26ed243540d0631381d469731aa1b0ee2b64 Mon Sep 17 00:00:00 2001
From: Tobias Gross-Vogt <tgros@tugraz.at>
Date: Wed, 25 May 2022 10:31:11 +0200
Subject: [PATCH] added assertion; non-null return type for method never
 returning null

---
 src/Service/LDAPApi.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/Service/LDAPApi.php b/src/Service/LDAPApi.php
index 4197f4e..a614894 100644
--- a/src/Service/LDAPApi.php
+++ b/src/Service/LDAPApi.php
@@ -238,7 +238,7 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
         return $persons;
     }
 
-    private function getPersonUserItem(string $identifier): ?User
+    private function getPersonUserItem(string $identifier): User
     {
         $preEvent = new PersonUserItemPreEvent($identifier);
         $this->dispatcher->dispatch($preEvent, PersonUserItemPreEvent::NAME);
@@ -258,6 +258,8 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
                 throw new NotFoundHttpException(sprintf("Person with id '%s' could not be found!", $identifier));
             }
 
+            assert($identifier === $user->getFirstAttribute($this->identifierAttributeName));
+
             /* @var User $user */
             return $user;
         } catch (\Adldap\Auth\BindException $e) {
-- 
GitLab