diff --git a/Command/DebugCommand.php b/Command/DebugCommand.php index 510a22fd..320de536 100644 --- a/Command/DebugCommand.php +++ b/Command/DebugCommand.php @@ -113,8 +113,8 @@ protected function outputMailer($name) $tableRows[] = ['Name', $name]; $tableRows[] = ['Service', $service]; - $tableRows[] = ['Class', get_class($mailer)]; - $tableRows[] = ['Transport', sprintf('%s (%s)', sprintf('swiftmailer.mailer.%s.transport.name', $name), get_class($transport))]; + $tableRows[] = ['Class', \get_class($mailer)]; + $tableRows[] = ['Transport', sprintf('%s (%s)', sprintf('swiftmailer.mailer.%s.transport.name', $name), \get_class($transport))]; $tableRows[] = ['Spool', $spool]; if ($this->getContainer()->hasParameter(sprintf('swiftmailer.spool.%s.file.path', $name))) { $tableRows[] = ['Spool file', $this->getContainer()->getParameter(sprintf('swiftmailer.spool.%s.file.path', $name))]; diff --git a/DataCollector/MessageDataCollector.php b/DataCollector/MessageDataCollector.php index a4f5b85a..594a4d71 100644 --- a/DataCollector/MessageDataCollector.php +++ b/DataCollector/MessageDataCollector.php @@ -110,7 +110,7 @@ public function getMailers() public function getMailerData($name) { if (!isset($this->data['mailer'][$name])) { - throw new \LogicException(sprintf('Missing "%s" data in "%s".', $name, get_class($this))); + throw new \LogicException(sprintf('Missing "%s" data in "%s".', $name, \get_class($this))); } return $this->data['mailer'][$name]; diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 02d8ee18..e1c11db5 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -50,7 +50,7 @@ public function getConfigTreeBuilder() ->end() ->beforeNormalization() ->ifTrue(function ($v) { - return is_array($v) && !array_key_exists('mailers', $v) && !array_key_exists('mailer', $v); + return \is_array($v) && !\array_key_exists('mailers', $v) && !\array_key_exists('mailer', $v); }) ->then(function ($v) { $mailer = []; diff --git a/DependencyInjection/SwiftmailerExtension.php b/DependencyInjection/SwiftmailerExtension.php index 778c8167..6419ca91 100644 --- a/DependencyInjection/SwiftmailerExtension.php +++ b/DependencyInjection/SwiftmailerExtension.php @@ -118,7 +118,7 @@ protected function configureMailer($name, array $mailer, ContainerBuilder $conta $container->setParameter(sprintf('swiftmailer.mailer.%s.transport.name', $name), $transport); - $transportId = in_array($transport, ['smtp', 'sendmail', 'null']) + $transportId = \in_array($transport, ['smtp', 'sendmail', 'null']) ? sprintf('swiftmailer.mailer.%s.transport.%s', $name, $transport) : $transport; @@ -333,7 +333,7 @@ protected function configureMailerAntiFlood($name, array $mailer, ContainerBuild protected function configureMailerDeliveryAddress($name, array $mailer, ContainerBuilder $container, $isDefaultMailer = false) { - if (count($mailer['delivery_addresses']) > 0) { + if (\count($mailer['delivery_addresses']) > 0) { $container->setParameter(sprintf('swiftmailer.mailer.%s.single_address', $name), $mailer['delivery_addresses'][0]); $container->setParameter(sprintf('swiftmailer.mailer.%s.delivery_addresses', $name), $mailer['delivery_addresses']); $container->setParameter(sprintf('swiftmailer.mailer.%s.delivery_whitelist', $name), $mailer['delivery_whitelist']); diff --git a/DependencyInjection/SwiftmailerTransportFactory.php b/DependencyInjection/SwiftmailerTransportFactory.php index 563a0873..dc73b68e 100644 --- a/DependencyInjection/SwiftmailerTransportFactory.php +++ b/DependencyInjection/SwiftmailerTransportFactory.php @@ -148,11 +148,11 @@ public static function resolveOptions(array $options) */ public static function validateConfig($options) { - if (!in_array($options['encryption'], ['tls', 'ssl', null], true)) { + if (!\in_array($options['encryption'], ['tls', 'ssl', null], true)) { throw new \InvalidArgumentException(sprintf('The %s encryption is not supported', $options['encryption'])); } - if (!in_array($options['auth_mode'], ['plain', 'login', 'cram-md5', 'ntlm', null], true)) { + if (!\in_array($options['auth_mode'], ['plain', 'login', 'cram-md5', 'ntlm', null], true)) { throw new \InvalidArgumentException(sprintf('The %s authentication mode is not supported', $options['auth_mode'])); } } diff --git a/SwiftmailerBundle.php b/SwiftmailerBundle.php index 5a4b61cc..5dc6b5cd 100644 --- a/SwiftmailerBundle.php +++ b/SwiftmailerBundle.php @@ -31,7 +31,7 @@ public function build(ContainerBuilder $container) // Older supported versions of Symfony don't have the parent class that EnsureNoHotPathPass extends from. // But they don't have the hot_path optimization either, so not being able to register our pass is not an issue. - if (\class_exists('Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass')) { + if (class_exists('Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass')) { $container->addCompilerPass(new EnsureNoHotPathPass(), PassConfig::TYPE_AFTER_REMOVING); } } diff --git a/Tests/Command/SendEmailCommandTest.php b/Tests/Command/SendEmailCommandTest.php index f141da25..14ce2a0d 100644 --- a/Tests/Command/SendEmailCommandTest.php +++ b/Tests/Command/SendEmailCommandTest.php @@ -56,7 +56,7 @@ public function testTimeLimitNull() $container = $this->buildContainer($spoolTransport, $realTransport); $this->executeCommand($container); - $this->assertSame(null, $spool->getTimeLimit()); + $this->assertNull($spool->getTimeLimit()); } public function testMessageLimitInteger() @@ -84,7 +84,7 @@ public function testMessageLimitNull() $container = $this->buildContainer($spoolTransport, $realTransport); $this->executeCommand($container); - $this->assertSame(null, $spool->getMessageLimit()); + $this->assertNull($spool->getMessageLimit()); } public function testRecoverLoadbalancedTransportWithSpool() @@ -129,11 +129,11 @@ private function buildContainer(\Swift_Transport $transport, \Swift_Transport $r /** * @return CommandTester */ - private function executeCommand(ContainerInterface $container, $input = array(), $options = array()) + private function executeCommand(ContainerInterface $container, $input = [], $options = []) { $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); $kernel->expects($this->any())->method('getContainer')->willReturn($container); - $kernel->expects($this->any())->method('getBundles')->willReturn(array()); + $kernel->expects($this->any())->method('getBundles')->willReturn([]); $application = new Application($kernel); $application->add(new SendEmailCommand()); @@ -149,12 +149,26 @@ private function executeCommand(ContainerInterface $container, $input = array(), */ private function configurableSpool(): \Swift_ConfigurableSpool { - return new class extends \Swift_ConfigurableSpool { - public function start() {} - public function stop() {} - public function isStarted() {} - public function queueMessage(\Swift_Mime_SimpleMessage $message) {} - public function flushQueue(\Swift_Transport $transport, &$failedRecipients = null) {} + return new class() extends \Swift_ConfigurableSpool { + public function start() + { + } + + public function stop() + { + } + + public function isStarted() + { + } + + public function queueMessage(\Swift_Mime_SimpleMessage $message) + { + } + + public function flushQueue(\Swift_Transport $transport, &$failedRecipients = null) + { + } }; } } diff --git a/Tests/DependencyInjection/Fixtures/config/php/sendmail_no_command.php b/Tests/DependencyInjection/Fixtures/config/php/sendmail_no_command.php index d1d41506..822b9c5f 100644 --- a/Tests/DependencyInjection/Fixtures/config/php/sendmail_no_command.php +++ b/Tests/DependencyInjection/Fixtures/config/php/sendmail_no_command.php @@ -1,6 +1,6 @@ loadFromExtension('swiftmailer', array( +$container->loadFromExtension('swiftmailer', [ 'transport' => 'sendmail', 'url' => '%env(SWIFTMAILER_URL)%', -)); +]); diff --git a/Tests/DependencyInjection/SwiftmailerExtensionTest.php b/Tests/DependencyInjection/SwiftmailerExtensionTest.php index 27d1e9ed..7dd9b6dc 100644 --- a/Tests/DependencyInjection/SwiftmailerExtensionTest.php +++ b/Tests/DependencyInjection/SwiftmailerExtensionTest.php @@ -99,7 +99,7 @@ public function testSendmailConfig($type) */ public function testSendmailDynamicConfigWithoutCommand($type) { - $container = $this->loadContainerFromFile('sendmail_no_command', $type, array(), true); + $container = $this->loadContainerFromFile('sendmail_no_command', $type, [], true); $container->getAlias('swiftmailer.transport')->setPublic(true); /** @var \Swift_SendmailTransport $transport */