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

Commit 29cc2e7

Browse files
committed
Fix quotes in exception messages
1 parent 931ca20 commit 29cc2e7

13 files changed

+21
-21
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);
4343
} elseif (!$role instanceof RoleInterface) {
44-
throw new \InvalidArgumentException(sprintf('$roles must be an array of strings or Role instances, but got %s.', \gettype($role)));
44+
throw new \InvalidArgumentException(sprintf('$roles must be an array of strings or Role instances, but got "%s".', \gettype($role)));
4545
}
4646

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

Core/Authorization/AccessDecisionManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct($voters = [], $strategy = self::STRATEGY_AFFIRMATIVE
6262
*/
6363
public function setVoters(array $voters)
6464
{
65-
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Pass the voters to the constructor instead.', __METHOD__), E_USER_DEPRECATED);
65+
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 3.3 and will be removed in 4.0. Pass the voters to the constructor instead.', __METHOD__), E_USER_DEPRECATED);
6666

6767
$this->voters = $voters;
6868
}
@@ -197,6 +197,6 @@ private function vote($voter, TokenInterface $token, $subject, $attributes)
197197
return $voter->vote($token, $subject, $attributes);
198198
}
199199

200-
throw new LogicException(sprintf('%s should implement the %s interface when used as voter.', \get_class($voter), VoterInterface::class));
200+
throw new LogicException(sprintf('"%s" should implement the "%s" interface when used as voter.', \get_class($voter), VoterInterface::class));
201201
}
202202
}

Core/Tests/Authorization/AccessDecisionManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected function getVoter($vote)
143143
public function testVotingWrongTypeNoVoteMethod()
144144
{
145145
$exception = LogicException::class;
146-
$message = sprintf('stdClass should implement the %s interface when used as voter.', VoterInterface::class);
146+
$message = sprintf('"stdClass" should implement the "%s" interface when used as voter.', VoterInterface::class);
147147

148148
$this->expectException($exception);
149149
$this->expectExceptionMessage($message);

Guard/Authenticator/AbstractFormLoginAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
6464
@trigger_error(sprintf('The AbstractFormLoginAuthenticator::onAuthenticationSuccess() implementation was deprecated in Symfony 3.1 and will be removed in Symfony 4.0. You should implement this method yourself in %s and remove getDefaultSuccessRedirectUrl().', static::class), E_USER_DEPRECATED);
6565

6666
if (!method_exists($this, 'getDefaultSuccessRedirectUrl')) {
67-
throw new \Exception(sprintf('You must implement onAuthenticationSuccess() or getDefaultSuccessRedirectUrl() in %s.', static::class));
67+
throw new \Exception(sprintf('You must implement onAuthenticationSuccess() or getDefaultSuccessRedirectUrl() in "%s".', static::class));
6868
}
6969

7070
$targetPath = null;

Guard/GuardAuthenticatorHandler.php

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

84-
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)));
84+
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)));
8585
}
8686

8787
/**
@@ -119,7 +119,7 @@ public function handleAuthenticationFailure(AuthenticationException $authenticat
119119
return $response;
120120
}
121121

122-
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)));
122+
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)));
123123
}
124124

125125
/**

Guard/Provider/GuardAuthenticationProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,23 @@ private function authenticateViaGuard($guardAuthenticator, PreAuthenticationGuar
101101
$user = $guardAuthenticator->getUser($token->getCredentials(), $this->userProvider);
102102

103103
if (null === $user) {
104-
throw new UsernameNotFoundException(sprintf('Null returned from %s::getUser().', \get_class($guardAuthenticator)));
104+
throw new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator)));
105105
}
106106

107107
if (!$user instanceof UserInterface) {
108-
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)));
108+
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)));
109109
}
110110

111111
$this->userChecker->checkPreAuth($user);
112112
if (true !== $guardAuthenticator->checkCredentials($token->getCredentials(), $user)) {
113-
throw new BadCredentialsException(sprintf('Authentication failed because %s::checkCredentials() did not return true.', \get_class($guardAuthenticator)));
113+
throw new BadCredentialsException(sprintf('Authentication failed because "%s"::checkCredentials() did not return true.', \get_class($guardAuthenticator)));
114114
}
115115
$this->userChecker->checkPostAuth($user);
116116

117117
// turn the UserInterface into a TokenInterface
118118
$authenticatedToken = $guardAuthenticator->createAuthenticatedToken($user, $this->providerKey);
119119
if (!$authenticatedToken instanceof TokenInterface) {
120-
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)));
120+
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)));
121121
}
122122

123123
return $authenticatedToken;

Http/Authentication/SimpleAuthenticationHandler.php

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

6666
if (null !== $response) {
67-
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)));
67+
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)));
6868
}
6969
}
7070

@@ -91,7 +91,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
9191
}
9292

9393
if (null !== $response) {
94-
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)));
94+
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)));
9595
}
9696
}
9797

Http/Firewall/ExceptionListener.php

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

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

218218
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
@@ -120,7 +120,7 @@ public function handle(GetResponseEvent $event)
120120
if ($response instanceof Response) {
121121
$event->setResponse($response);
122122
} elseif (null !== $response) {
123-
throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationFailure method must return null or a Response object.', \get_class($this->simpleAuthenticator)));
123+
throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationFailure()" method must return null or a Response object.', \get_class($this->simpleAuthenticator)));
124124
}
125125
}
126126

@@ -132,7 +132,7 @@ public function handle(GetResponseEvent $event)
132132
if ($response instanceof Response) {
133133
$event->setResponse($response);
134134
} elseif (null !== $response) {
135-
throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null or a Response object.', \get_class($this->simpleAuthenticator)));
135+
throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationSuccess()" method must return null or a Response object.', \get_class($this->simpleAuthenticator)));
136136
}
137137
}
138138
}

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
@@ -81,7 +81,7 @@ public function testOnAuthenticationSuccessCallsSimpleAuthenticator()
8181
public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsReturned()
8282
{
8383
$this->expectException('UnexpectedValueException');
84-
$this->expectExceptionMessage('onAuthenticationSuccess method must return null to use the default success handler, or a Response object');
84+
$this->expectExceptionMessage('onAuthenticationSuccess()" method must return null to use the default success handler, or a Response object');
8585
$this->successHandler->expects($this->never())
8686
->method('onAuthenticationSuccess');
8787

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

Http/Tests/Firewall/ExceptionListenerTest.php

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

9292
/**

0 commit comments

Comments
 (0)