Skip to content

Commit

Permalink
Leverage PHP8's get_debug_type()
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Mar 16, 2020
1 parent f74473e commit bb88d58
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Authentication/AuthenticationProviderManager.php
Expand Up @@ -65,7 +65,7 @@ public function authenticate(TokenInterface $token)

foreach ($this->providers as $provider) {
if (!$provider instanceof AuthenticationProviderInterface) {
throw new \InvalidArgumentException(sprintf('Provider "%s" must implement the AuthenticationProviderInterface.', \get_class($provider)));
throw new \InvalidArgumentException(sprintf('Provider "%s" must implement the AuthenticationProviderInterface.', get_debug_type($provider)));
}

if (!$provider->supports($token)) {
Expand Down
Expand Up @@ -52,7 +52,7 @@ public function authenticate(TokenInterface $token)
$user = $token->getUser();

if (!$token->getUser() instanceof UserInterface) {
throw new LogicException(sprintf('Method "%s::getUser()" must return a "%s" instance, "%s" returned.', \get_class($token), UserInterface::class, \is_object($user) ? \get_class($user) : \gettype($user)));
throw new LogicException(sprintf('Method "%s::getUser()" must return a "%s" instance, "%s" returned.', get_debug_type($token), UserInterface::class, get_debug_type($user)));
}

$this->userChecker->checkPreAuth($user);
Expand Down
2 changes: 1 addition & 1 deletion Encoder/EncoderFactory.php
Expand Up @@ -50,7 +50,7 @@ public function getEncoder($user)
}

if (null === $encoderKey) {
throw new \RuntimeException(sprintf('No encoder has been configured for account "%s".', \is_object($user) ? \get_class($user) : $user));
throw new \RuntimeException(sprintf('No encoder has been configured for account "%s".', \is_object($user) ? get_debug_type($user) : $user));
}

if (!$this->encoders[$encoderKey] instanceof PasswordEncoderInterface) {
Expand Down
2 changes: 1 addition & 1 deletion User/ChainUserProvider.php
Expand Up @@ -91,7 +91,7 @@ public function refreshUser(UserInterface $user)
$e->setUsername($user->getUsername());
throw $e;
} else {
throw new UnsupportedUserException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', \get_class($user)));
throw new UnsupportedUserException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', get_debug_type($user)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion User/InMemoryUserProvider.php
Expand Up @@ -74,7 +74,7 @@ public function loadUserByUsername(string $username)
public function refreshUser(UserInterface $user)
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
}

$storedUser = $this->getUser($user->getUsername());
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -18,6 +18,7 @@
"require": {
"php": "^7.2.5",
"symfony/event-dispatcher-contracts": "^1.1|^2",
"symfony/polyfill-php80": "^1.15",
"symfony/service-contracts": "^1.1.6|^2",
"symfony/deprecation-contracts": "^2.1"
},
Expand Down

0 comments on commit bb88d58

Please sign in to comment.