From 88bf10f171cb3bfa21eff95c93fd7c39f00baa07 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 08:32:23 +0100 Subject: [PATCH 1/2] Fix quotes in exception messages --- DataCollector/SecurityDataCollector.php | 2 +- DependencyInjection/Compiler/AddSecurityVotersPass.php | 2 +- Security/FirewallContext.php | 2 +- .../DependencyInjection/Compiler/AddSecurityVotersPassTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DataCollector/SecurityDataCollector.php b/DataCollector/SecurityDataCollector.php index 8bca2b2c..925d682c 100644 --- a/DataCollector/SecurityDataCollector.php +++ b/DataCollector/SecurityDataCollector.php @@ -121,7 +121,7 @@ public function collect(Request $request, Response $response, \Exception $except $extractRoles = function ($role) { if (!$role instanceof RoleInterface && !$role instanceof Role) { - throw new \InvalidArgumentException(sprintf('Roles must be instances of %s or %s (%s given).', RoleInterface::class, Role::class, \is_object($role) ? \get_class($role) : \gettype($role))); + throw new \InvalidArgumentException(sprintf('Roles must be instances of "%s" or "%s" ("%s" given).', RoleInterface::class, Role::class, \is_object($role) ? \get_class($role) : \gettype($role))); } return $role->getRole(); diff --git a/DependencyInjection/Compiler/AddSecurityVotersPass.php b/DependencyInjection/Compiler/AddSecurityVotersPass.php index 07b2eaee..b0171266 100644 --- a/DependencyInjection/Compiler/AddSecurityVotersPass.php +++ b/DependencyInjection/Compiler/AddSecurityVotersPass.php @@ -51,7 +51,7 @@ public function process(ContainerBuilder $container) if (!method_exists($class, 'vote')) { // in case the vote method is completely missing, to prevent exceptions when voting - throw new LogicException(sprintf('%s should implement the %s interface when used as voter.', $class, VoterInterface::class)); + throw new LogicException(sprintf('"%s" should implement the "%s" interface when used as voter.', $class, VoterInterface::class)); } } diff --git a/Security/FirewallContext.php b/Security/FirewallContext.php index ecbaf596..20fb7d9d 100644 --- a/Security/FirewallContext.php +++ b/Security/FirewallContext.php @@ -41,7 +41,7 @@ public function __construct($listeners, ExceptionListener $exceptionListener = n $this->logoutListener = $logoutListener; $this->config = $config; } else { - throw new \InvalidArgumentException(sprintf('Argument 3 passed to %s() must be instance of %s or null, %s given.', __METHOD__, LogoutListener::class, \is_object($logoutListener) ? \get_class($logoutListener) : \gettype($logoutListener))); + throw new \InvalidArgumentException(sprintf('Argument 3 passed to "%s()" must be instance of "%s" or null, "%s" given.', __METHOD__, LogoutListener::class, \is_object($logoutListener) ? \get_class($logoutListener) : \gettype($logoutListener))); } } diff --git a/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php b/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php index 48a03b3a..c9386dba 100644 --- a/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php +++ b/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php @@ -97,7 +97,7 @@ public function testVoterMissingInterface() public function testVoterMissingInterfaceAndMethod() { $exception = LogicException::class; - $message = 'stdClass should implement the Symfony\Component\Security\Core\Authorization\Voter\VoterInterface interface when used as voter.'; + $message = '"stdClass" should implement the "Symfony\Component\Security\Core\Authorization\Voter\VoterInterface" interface when used as voter.'; $this->expectException($exception); $this->expectExceptionMessage($message); From 9b10ee960bcfab0dea8afda2971115c05295db1e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 10:45:04 +0100 Subject: [PATCH 2/2] Fix quotes in exception messages --- DependencyInjection/Compiler/AddSecurityVotersPass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/Compiler/AddSecurityVotersPass.php b/DependencyInjection/Compiler/AddSecurityVotersPass.php index 87103c37..c3c7b86a 100644 --- a/DependencyInjection/Compiler/AddSecurityVotersPass.php +++ b/DependencyInjection/Compiler/AddSecurityVotersPass.php @@ -52,7 +52,7 @@ public function process(ContainerBuilder $container) $class = $container->getParameterBag()->resolveValue($definition->getClass()); if (!is_a($class, VoterInterface::class, true)) { - throw new LogicException(sprintf('%s must implement the %s when used as a voter.', $class, VoterInterface::class)); + throw new LogicException(sprintf('"%s" must implement the "%s" when used as a voter.', $class, VoterInterface::class)); } if ($debug) {