Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8b924c

Browse files
javiereguiluzfabpot
authored andcommitted
Standardize the name of the exception variables
1 parent c95d86c commit e8b924c

30 files changed

+91
-95
lines changed

src/Symfony/Bundle/TwigBundle/TwigEngine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function render($name, array $parameters = array())
7979
try {
8080
// try to get the real file name of the template where the error occurred
8181
$e->setTemplateFile(sprintf('%s', $this->locator->locate($this->parser->parse($e->getTemplateFile()))));
82-
} catch (\Exception $ex) {
82+
} catch (\Exception $e2) {
8383
}
8484
}
8585

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ protected function finalizeValue($value)
256256

257257
try {
258258
$value[$name] = $child->finalize($value[$name]);
259-
} catch (UnsetKeyException $unset) {
259+
} catch (UnsetKeyException $e) {
260260
unset($value[$name]);
261261
}
262262
}

src/Symfony/Component/Config/Definition/BaseNode.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,10 @@ final public function finalize($value)
302302
foreach ($this->finalValidationClosures as $closure) {
303303
try {
304304
$value = $closure($value);
305-
} catch (Exception $correctEx) {
306-
throw $correctEx;
307-
} catch (\Exception $invalid) {
308-
throw new InvalidConfigurationException(sprintf(
309-
'Invalid configuration for path "%s": %s',
310-
$this->getPath(),
311-
$invalid->getMessage()
312-
), $invalid->getCode(), $invalid);
305+
} catch (Exception $e) {
306+
throw $e;
307+
} catch (\Exception $e) {
308+
throw new InvalidConfigurationException(sprintf('Invalid configuration for path "%s": %s', $this->getPath(), $e->getMessage()), $e->getCode(), $e);
313309
}
314310
}
315311

src/Symfony/Component/Config/Definition/PrototypedArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ protected function finalizeValue($value)
211211
$this->prototype->setName($k);
212212
try {
213213
$value[$k] = $this->prototype->finalize($v);
214-
} catch (UnsetKeyException $unset) {
214+
} catch (UnsetKeyException $e) {
215215
unset($value[$k]);
216216
}
217217
}

src/Symfony/Component/Console/Helper/DialogHelper.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,18 @@ private function hasSttyAvailable()
452452
*/
453453
private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
454454
{
455-
$error = null;
455+
$e = null;
456456
while (false === $attempts || $attempts--) {
457-
if (null !== $error) {
458-
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
457+
if (null !== $e) {
458+
$output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
459459
}
460460

461461
try {
462462
return call_user_func($validator, $interviewer());
463-
} catch (\Exception $error) {
463+
} catch (\Exception $e) {
464464
}
465465
}
466466

467-
throw $error;
467+
throw $e;
468468
}
469469
}

src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function process(ContainerBuilder $container)
4747
foreach ($definition->getMethodCalls() as $call) {
4848
try {
4949
$calls[] = array($call[0], $this->processArguments($call[1], true));
50-
} catch (RuntimeException $ignore) {
50+
} catch (RuntimeException $e) {
5151
// this call is simply removed
5252
}
5353
}
@@ -58,7 +58,7 @@ public function process(ContainerBuilder $container)
5858
try {
5959
$value = $this->processArguments(array($value), true);
6060
$properties[$name] = reset($value);
61-
} catch (RuntimeException $ignore) {
61+
} catch (RuntimeException $e) {
6262
// ignore property
6363
}
6464
}

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function collect(Request $request, Response $response, \Exception $except
125125
'file' => $r->getFileName(),
126126
'line' => $r->getStartLine(),
127127
);
128-
} catch (\ReflectionException $re) {
128+
} catch (\ReflectionException $e) {
129129
if (is_callable($controller)) {
130130
// using __call or __callStatic
131131
$this->data['controller'] = array(

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/ContainerAwareHttpKernelTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ public function testHandleRestoresThePreviousRequestOnException($type)
137137
try {
138138
$kernel->handle($request, $type);
139139
$this->fail('->handle() suppresses the controller exception');
140-
} catch (\PHPUnit_Framework_Exception $exception) {
141-
throw $exception;
142-
} catch (\Exception $actual) {
143-
$this->assertSame($expected, $actual, '->handle() throws the controller exception');
140+
} catch (\PHPUnit_Framework_Exception $e) {
141+
throw $e;
142+
} catch (\Exception $e) {
143+
$this->assertSame($expected, $e, '->handle() throws the controller exception');
144144
}
145145
}
146146

src/Symfony/Component/Security/Acl/Dbal/AclProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ public function findAcls(array $oids, array $sids = array())
177177
if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) {
178178
try {
179179
$loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);
180-
} catch (AclNotFoundException $aclNotFoundexception) {
180+
} catch (AclNotFoundException $e) {
181181
if ($result->count()) {
182182
$partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
183183
$partialResultException->setPartialResult($result);
184184
throw $partialResultException;
185185
} else {
186-
throw $aclNotFoundexception;
186+
throw $e;
187187
}
188188
}
189189
foreach ($loadedBatch as $loadedOid) {

src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public function createAcl(ObjectIdentityInterface $oid)
6262
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
6363

6464
$this->connection->commit();
65-
} catch (\Exception $failed) {
65+
} catch (\Exception $e) {
6666
$this->connection->rollBack();
6767

68-
throw $failed;
68+
throw $e;
6969
}
7070

7171
// re-read the ACL from the database to ensure proper caching, etc.
@@ -90,10 +90,10 @@ public function deleteAcl(ObjectIdentityInterface $oid)
9090
$this->deleteObjectIdentity($oidPK);
9191

9292
$this->connection->commit();
93-
} catch (\Exception $failed) {
93+
} catch (\Exception $e) {
9494
$this->connection->rollBack();
9595

96-
throw $failed;
96+
throw $e;
9797
}
9898

9999
// evict the ACL from the in-memory identity map
@@ -324,10 +324,10 @@ public function updateAcl(MutableAclInterface $acl)
324324
}
325325

326326
$this->connection->commit();
327-
} catch (\Exception $failed) {
327+
} catch (\Exception $e) {
328328
$this->connection->rollBack();
329329

330-
throw $failed;
330+
throw $e;
331331
}
332332

333333
$this->propertyChanges->offsetSet($acl, array());

src/Symfony/Component/Security/Acl/Domain/ObjectIdentity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public static function fromDomainObject($domainObject)
6868
} elseif (method_exists($domainObject, 'getId')) {
6969
return new self((string) $domainObject->getId(), ClassUtils::getRealClass($domainObject));
7070
}
71-
} catch (\InvalidArgumentException $invalid) {
72-
throw new InvalidDomainObjectException($invalid->getMessage(), 0, $invalid);
71+
} catch (\InvalidArgumentException $e) {
72+
throw new InvalidDomainObjectException($e->getMessage(), 0, $e);
7373
}
7474

7575
throw new InvalidDomainObjectException('$domainObject must either implement the DomainObjectInterface, or have a method named "getId".');

src/Symfony/Component/Security/Acl/Domain/ObjectIdentityRetrievalStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function getObjectIdentity($domainObject)
2828
{
2929
try {
3030
return ObjectIdentity::fromDomainObject($domainObject);
31-
} catch (InvalidDomainObjectException $failed) {
31+
} catch (InvalidDomainObjectException $e) {
3232
return;
3333
}
3434
}

src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ public function isGranted(AclInterface $acl, array $masks, array $sids, $adminis
5555
}
5656

5757
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
58-
} catch (NoAceFoundException $noObjectAce) {
58+
} catch (NoAceFoundException $e) {
5959
$aces = $acl->getClassAces();
6060

6161
if (!$aces) {
62-
throw $noObjectAce;
62+
throw $e;
6363
}
6464

6565
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
6666
}
67-
} catch (NoAceFoundException $noClassAce) {
67+
} catch (NoAceFoundException $e) {
6868
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
6969
return $parentAcl->isGranted($masks, $sids, $administrativeMode);
7070
}
7171

72-
throw $noClassAce;
72+
throw $e;
7373
}
7474
}
7575

@@ -86,20 +86,20 @@ public function isFieldGranted(AclInterface $acl, $field, array $masks, array $s
8686
}
8787

8888
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
89-
} catch (NoAceFoundException $noObjectAces) {
89+
} catch (NoAceFoundException $e) {
9090
$aces = $acl->getClassFieldAces($field);
9191
if (!$aces) {
92-
throw $noObjectAces;
92+
throw $e;
9393
}
9494

9595
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
9696
}
97-
} catch (NoAceFoundException $noClassAces) {
97+
} catch (NoAceFoundException $e) {
9898
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
9999
return $parentAcl->isFieldGranted($field, $masks, $sids, $administrativeMode);
100100
}
101101

102-
throw $noClassAces;
102+
throw $e;
103103
}
104104
}
105105

src/Symfony/Component/Security/Acl/Domain/SecurityIdentityRetrievalStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getSecurityIdentities(TokenInterface $token)
5151
if (!$token instanceof AnonymousToken) {
5252
try {
5353
$sids[] = UserSecurityIdentity::fromToken($token);
54-
} catch (\InvalidArgumentException $invalid) {
54+
} catch (\InvalidArgumentException $e) {
5555
// ignore, user has no user security identity
5656
}
5757
}

src/Symfony/Component/Security/Acl/Permission/MaskBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function getPattern()
132132
if ('1' === $bitmask[$i]) {
133133
try {
134134
$pattern[$i] = self::getCode(1 << ($length - $i - 1));
135-
} catch (\Exception $notPredefined) {
135+
} catch (\Exception $e) {
136136
$pattern[$i] = self::ON;
137137
}
138138
}

src/Symfony/Component/Security/Acl/Voter/AclVoter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ public function vote(TokenInterface $token, $object, array $attributes)
113113
}
114114

115115
return self::ACCESS_DENIED;
116-
} catch (AclNotFoundException $noAcl) {
116+
} catch (AclNotFoundException $e) {
117117
if (null !== $this->logger) {
118118
$this->logger->debug('No ACL found for the object identity. Voting to deny access.');
119119
}
120120

121121
return self::ACCESS_DENIED;
122-
} catch (NoAceFoundException $noAce) {
122+
} catch (NoAceFoundException $e) {
123123
if (null !== $this->logger) {
124124
$this->logger->debug('ACL found, no ACE applicable. Voting to deny access.');
125125
}

src/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ protected function retrieveUser($username, UsernamePasswordToken $token)
8787
}
8888

8989
return $user;
90-
} catch (UsernameNotFoundException $notFound) {
91-
$notFound->setUsername($username);
92-
throw $notFound;
93-
} catch (\Exception $repositoryProblem) {
94-
$ex = new AuthenticationServiceException($repositoryProblem->getMessage(), 0, $repositoryProblem);
95-
$ex->setToken($token);
96-
throw $ex;
90+
} catch (UsernameNotFoundException $e) {
91+
$e->setUsername($username);
92+
throw $e;
93+
} catch (\Exception $e) {
94+
$e = new AuthenticationServiceException($e->getMessage(), 0, $e);
95+
$e->setToken($token);
96+
throw $e;
9797
}
9898
}
9999
}

src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ public function authenticate(TokenInterface $token)
6868

6969
try {
7070
$user = $this->retrieveUser($username, $token);
71-
} catch (UsernameNotFoundException $notFound) {
71+
} catch (UsernameNotFoundException $e) {
7272
if ($this->hideUserNotFoundExceptions) {
73-
throw new BadCredentialsException('Bad credentials', 0, $notFound);
73+
throw new BadCredentialsException('Bad credentials', 0, $e);
7474
}
75-
$notFound->setUsername($username);
75+
$e->setUsername($username);
7676

77-
throw $notFound;
77+
throw $e;
7878
}
7979

8080
if (!$user instanceof UserInterface) {

src/Symfony/Component/Security/Core/User/ChainUserProvider.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function loadUserByUsername($username)
4747
foreach ($this->providers as $provider) {
4848
try {
4949
return $provider->loadUserByUsername($username);
50-
} catch (UsernameNotFoundException $notFound) {
50+
} catch (UsernameNotFoundException $e) {
5151
// try next one
5252
}
5353
}
@@ -67,18 +67,18 @@ public function refreshUser(UserInterface $user)
6767
foreach ($this->providers as $provider) {
6868
try {
6969
return $provider->refreshUser($user);
70-
} catch (UnsupportedUserException $unsupported) {
70+
} catch (UnsupportedUserException $e) {
7171
// try next one
72-
} catch (UsernameNotFoundException $notFound) {
72+
} catch (UsernameNotFoundException $e) {
7373
$supportedUserFound = true;
7474
// try next one
7575
}
7676
}
7777

7878
if ($supportedUserFound) {
79-
$ex = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername()));
80-
$ex->setUsername($user->getUsername());
81-
throw $ex;
79+
$e = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername()));
80+
$e->setUsername($user->getUsername());
81+
throw $e;
8282
} else {
8383
throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', get_class($user)));
8484
}

src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ final public function handle(GetResponseEvent $event)
6262

6363
try {
6464
list($user, $credentials) = $this->getPreAuthenticatedData($request);
65-
} catch (BadCredentialsException $exception) {
66-
$this->clearToken($exception);
65+
} catch (BadCredentialsException $e) {
66+
$this->clearToken($e);
6767

6868
return;
6969
}
@@ -90,8 +90,8 @@ final public function handle(GetResponseEvent $event)
9090
$loginEvent = new InteractiveLoginEvent($request, $token);
9191
$this->dispatcher->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $loginEvent);
9292
}
93-
} catch (AuthenticationException $failed) {
94-
$this->clearToken($failed);
93+
} catch (AuthenticationException $e) {
94+
$this->clearToken($e);
9595
}
9696
}
9797

src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,21 @@ public function handle(GetResponseEvent $event)
7373
try {
7474
$token = $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $request->headers->get('PHP_AUTH_PW'), $this->providerKey));
7575
$this->securityContext->setToken($token);
76-
} catch (AuthenticationException $failed) {
76+
} catch (AuthenticationException $e) {
7777
$token = $this->securityContext->getToken();
7878
if ($token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey()) {
7979
$this->securityContext->setToken(null);
8080
}
8181

8282
if (null !== $this->logger) {
83-
$this->logger->info(sprintf('Authentication request failed for user "%s": %s', $username, $failed->getMessage()));
83+
$this->logger->info(sprintf('Authentication request failed for user "%s": %s', $username, $e->getMessage()));
8484
}
8585

8686
if ($this->ignoreFailure) {
8787
return;
8888
}
8989

90-
$event->setResponse($this->authenticationEntryPoint->start($request, $failed));
90+
$event->setResponse($this->authenticationEntryPoint->start($request, $e));
9191
}
9292
}
9393
}

0 commit comments

Comments
 (0)