Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit d588ca8

Browse files
committed
Merge branch '3.4' into 4.4
* 3.4: Fix quotes in exception messages
2 parents a8f1f90 + 29cc2e7 commit d588ca8

11 files changed

+19
-19
lines changed

Core/Authentication/Token/AbstractToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(array $roles = [])
4141
if (\is_string($role)) {
4242
$role = new Role($role, false);
4343
} elseif (!$role instanceof Role) {
44-
throw new \InvalidArgumentException(sprintf('$roles must be an array of strings, but got %s.', \gettype($role)));
44+
throw new \InvalidArgumentException(sprintf('$roles must be an array of strings, but got "%s".', \gettype($role)));
4545
}
4646

4747
$this->roles[] = $role;

Core/Authorization/AccessDecisionManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(iterable $voters = [], string $strategy = self::STRA
5858
public function decide(TokenInterface $token, array $attributes, $object = null)
5959
{
6060
if (\count($attributes) > 1) {
61-
@trigger_error(sprintf('Passing more than one Security attribute to %s() is deprecated since Symfony 4.4. Use multiple decide() calls or the expression language (e.g. "is_granted(...) or is_granted(...)") instead.', __METHOD__), E_USER_DEPRECATED);
61+
@trigger_error(sprintf('Passing more than one Security attribute to "%s()" is deprecated since Symfony 4.4. Use multiple "decide()" calls or the expression language (e.g. "is_granted(...) or is_granted(...)") instead.', __METHOD__), E_USER_DEPRECATED);
6262
}
6363

6464
return $this->{$this->strategy}($token, $attributes, $object);

Guard/GuardAuthenticatorHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function handleAuthenticationSuccess(TokenInterface $token, Request $requ
8282
return $response;
8383
}
8484

85-
throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null or a Response object. You returned %s.', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response)));
85+
throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationSuccess()" method must return null or a Response object. You returned "%s".', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response)));
8686
}
8787

8888
/**
@@ -112,7 +112,7 @@ public function handleAuthenticationFailure(AuthenticationException $authenticat
112112
return $response;
113113
}
114114

115-
throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationFailure method must return null or a Response object. You returned %s.', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response)));
115+
throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationFailure()" method must return null or a Response object. You returned "%s".', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response)));
116116
}
117117

118118
/**

Guard/Provider/GuardAuthenticationProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,20 @@ private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator
105105
$user = $guardAuthenticator->getUser($token->getCredentials(), $this->userProvider);
106106

107107
if (null === $user) {
108-
throw new UsernameNotFoundException(sprintf('Null returned from %s::getUser().', \get_class($guardAuthenticator)));
108+
throw new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator)));
109109
}
110110

111111
if (!$user instanceof UserInterface) {
112-
throw new \UnexpectedValueException(sprintf('The %s::getUser() method must return a UserInterface. You returned %s.', \get_class($guardAuthenticator), \is_object($user) ? \get_class($user) : \gettype($user)));
112+
throw new \UnexpectedValueException(sprintf('The "%s::getUser()" method must return a UserInterface. You returned "%s".', \get_class($guardAuthenticator), \is_object($user) ? \get_class($user) : \gettype($user)));
113113
}
114114

115115
$this->userChecker->checkPreAuth($user);
116116
if (true !== $checkCredentialsResult = $guardAuthenticator->checkCredentials($token->getCredentials(), $user)) {
117117
if (false !== $checkCredentialsResult) {
118-
@trigger_error(sprintf('%s::checkCredentials() must return a boolean value. You returned %s. This behavior is deprecated in Symfony 4.4 and will trigger a TypeError in Symfony 5.', \get_class($guardAuthenticator), \is_object($checkCredentialsResult) ? \get_class($checkCredentialsResult) : \gettype($checkCredentialsResult)), E_USER_DEPRECATED);
118+
@trigger_error(sprintf('"%s::checkCredentials()" must return a boolean value. You returned "%s". This behavior is deprecated in Symfony 4.4 and will trigger a TypeError in Symfony 5.', \get_class($guardAuthenticator), \is_object($checkCredentialsResult) ? \get_class($checkCredentialsResult) : \gettype($checkCredentialsResult)), E_USER_DEPRECATED);
119119
}
120120

121-
throw new BadCredentialsException(sprintf('Authentication failed because %s::checkCredentials() did not return true.', \get_class($guardAuthenticator)));
121+
throw new BadCredentialsException(sprintf('Authentication failed because "%s::checkCredentials()" did not return true.', \get_class($guardAuthenticator)));
122122
}
123123
if ($this->userProvider instanceof PasswordUpgraderInterface && $guardAuthenticator instanceof PasswordAuthenticatedInterface && null !== $this->passwordEncoder && (null !== $password = $guardAuthenticator->getPassword($token->getCredentials())) && method_exists($this->passwordEncoder, 'needsRehash') && $this->passwordEncoder->needsRehash($user)) {
124124
$this->userProvider->upgradePassword($user, $this->passwordEncoder->encodePassword($user, $password));
@@ -128,7 +128,7 @@ private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator
128128
// turn the UserInterface into a TokenInterface
129129
$authenticatedToken = $guardAuthenticator->createAuthenticatedToken($user, $this->providerKey);
130130
if (!$authenticatedToken instanceof TokenInterface) {
131-
throw new \UnexpectedValueException(sprintf('The %s::createAuthenticatedToken() method must return a TokenInterface. You returned %s.', \get_class($guardAuthenticator), \is_object($authenticatedToken) ? \get_class($authenticatedToken) : \gettype($authenticatedToken)));
131+
throw new \UnexpectedValueException(sprintf('The "%s::createAuthenticatedToken()" method must return a TokenInterface. You returned "%s".', \get_class($guardAuthenticator), \is_object($authenticatedToken) ? \get_class($authenticatedToken) : \gettype($authenticatedToken)));
132132
}
133133

134134
return $authenticatedToken;

Http/Authentication/SimpleAuthenticationHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token)
6262
}
6363

6464
if (null !== $response) {
65-
throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null to use the default success handler, or a Response object.', \get_class($this->simpleAuthenticator)));
65+
throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationSuccess()" method must return null to use the default success handler, or a Response object.', \get_class($this->simpleAuthenticator)));
6666
}
6767
}
6868

@@ -89,7 +89,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
8989
}
9090

9191
if (null !== $response) {
92-
throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationFailure method must return null to use the default failure handler, or a Response object.', \get_class($this->simpleAuthenticator)));
92+
throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationFailure()" method must return null to use the default failure handler, or a Response object.', \get_class($this->simpleAuthenticator)));
9393
}
9494
}
9595

Http/Firewall/ExceptionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private function startAuthentication(Request $request, AuthenticationException $
216216
if (!$response instanceof Response) {
217217
$given = \is_object($response) ? \get_class($response) : \gettype($response);
218218

219-
throw new \LogicException(sprintf('The %s::start() method must return a Response object (%s returned).', \get_class($this->authenticationEntryPoint), $given));
219+
throw new \LogicException(sprintf('The "%s::start()" method must return a Response object ("%s" returned).', \get_class($this->authenticationEntryPoint), $given));
220220
}
221221

222222
return $response;

Http/Firewall/RemoteUserAuthenticationListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
4141
protected function getPreAuthenticatedData(Request $request)
4242
{
4343
if (!$request->server->has($this->userKey)) {
44-
throw new BadCredentialsException(sprintf('User key was not found: %s.', $this->userKey));
44+
throw new BadCredentialsException(sprintf('User key was not found: "%s".', $this->userKey));
4545
}
4646

4747
return [$request->server->get($this->userKey), null];

Http/Firewall/SimplePreAuthenticationListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function authenticate(RequestEvent $event)
146146
if ($response instanceof Response) {
147147
$event->setResponse($response);
148148
} elseif (null !== $response) {
149-
throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationFailure method must return null or a Response object.', \get_class($this->simpleAuthenticator)));
149+
throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationFailure()" method must return null or a Response object.', \get_class($this->simpleAuthenticator)));
150150
}
151151
}
152152

@@ -158,7 +158,7 @@ public function authenticate(RequestEvent $event)
158158
if ($response instanceof Response) {
159159
$event->setResponse($response);
160160
} elseif (null !== $response) {
161-
throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null or a Response object.', \get_class($this->simpleAuthenticator)));
161+
throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationSuccess()" method must return null or a Response object.', \get_class($this->simpleAuthenticator)));
162162
}
163163
}
164164
}

Http/Firewall/X509AuthenticationListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function getPreAuthenticatedData(Request $request)
5252
}
5353

5454
if (null === $user) {
55-
throw new BadCredentialsException(sprintf('SSL credentials not found: %s, %s.', $this->userKey, $this->credentialKey));
55+
throw new BadCredentialsException(sprintf('SSL credentials not found: "%s", "%s".', $this->userKey, $this->credentialKey));
5656
}
5757

5858
return [$user, $request->server->get($this->credentialKey, '')];

Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function testOnAuthenticationSuccessCallsSimpleAuthenticator()
8484
public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsReturned()
8585
{
8686
$this->expectException('UnexpectedValueException');
87-
$this->expectExceptionMessage('onAuthenticationSuccess method must return null to use the default success handler, or a Response object');
87+
$this->expectExceptionMessage('onAuthenticationSuccess()" method must return null to use the default success handler, or a Response object');
8888
$this->successHandler->expects($this->never())
8989
->method('onAuthenticationSuccess');
9090

@@ -152,7 +152,7 @@ public function testOnAuthenticationFailureCallsSimpleAuthenticator()
152152
public function testOnAuthenticationFailureThrowsAnExceptionIfNonResponseIsReturned()
153153
{
154154
$this->expectException('UnexpectedValueException');
155-
$this->expectExceptionMessage('onAuthenticationFailure method must return null to use the default failure handler, or a Response object');
155+
$this->expectExceptionMessage('onAuthenticationFailure()" method must return null to use the default failure handler, or a Response object');
156156
$this->failureHandler->expects($this->never())
157157
->method('onAuthenticationFailure');
158158

Http/Tests/Firewall/ExceptionListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testExceptionWhenEntryPointReturnsBadValue()
8383
$listener->onKernelException($event);
8484
// the exception has been replaced by our LogicException
8585
$this->assertInstanceOf('LogicException', $event->getThrowable());
86-
$this->assertStringEndsWith('start() method must return a Response object (string returned).', $event->getThrowable()->getMessage());
86+
$this->assertStringEndsWith('start()" method must return a Response object ("string" returned).', $event->getThrowable()->getMessage());
8787
}
8888

8989
/**

0 commit comments

Comments
 (0)