Skip to content

Commit

Permalink
Cast to string the user identifier (#297)
Browse files Browse the repository at this point in the history
* Cast to string the user identifier

Since the DH\Auditor\User\User constructor requires the first argument to be string or null, I have an UserInterface implementation where $tokenUser->getId() returns int, so there will be an exception. The check is on DH\AuditorBundle\User\UserProvider: if (method_exists($tokenUser, 'getId')) { $identifier = $tokenUser->getId(); }. To be safe, it is better to cast the getId() value to string, IMHO.

* Fix PHP-CS-Fixer cast_spaces issue
  • Loading branch information
samuel4x4 authored Feb 4, 2022
1 parent a1ab25d commit 34029c5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/User/UserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __invoke(): ?AuditorUserInterface
return null;
}

return new User($identifier, $username);
return new User((string) $identifier, $username);
}

private function getTokenUser(): ?UserInterface
Expand Down

0 comments on commit 34029c5

Please sign in to comment.