This PHP code part is valid:
$user = $this->getDoctrine()->getRepository(User::class)->find(
$this->request->query->get('id')
);
$this->getDoctrine() return a ManagerRegistry instance.
But the final $user does not seems to be typed:
Call to an undefined method object::getUsername().
Using the EntityManagerInterface directly make things working.