From 383ae4ebb8e9011dd7d168a5ac2dbf3bf60cbe34 Mon Sep 17 00:00:00 2001 From: Karoly Gossler Date: Wed, 14 Feb 2024 08:36:00 +0100 Subject: [PATCH] apply fix --- lib/classes/Swift.php | 2 +- lib/classes/Swift/Attachment.php | 2 +- .../AbstractFilterableInputStream.php | 4 +- .../Swift/ByteStream/FileByteStream.php | 2 +- .../ByteStream/TemporaryFileByteStream.php | 4 +- lib/classes/Swift/CharacterReader.php | 7 +- .../GenericFixedWidthReader.php | 1 - .../Swift/CharacterReader/Utf8Reader.php | 1 - .../SimpleCharacterReaderFactory.php | 6 +- .../CharacterStream/ArrayCharacterStream.php | 4 +- .../CharacterStream/NgCharacterStream.php | 6 +- lib/classes/Swift/DependencyContainer.php | 20 +- lib/classes/Swift/EmbeddedFile.php | 2 +- lib/classes/Swift/Encoder/Base64Encoder.php | 4 +- lib/classes/Swift/Encoder/QpEncoder.php | 4 +- lib/classes/Swift/Events/Event.php | 2 - lib/classes/Swift/Events/SendEvent.php | 10 +- lib/classes/Swift/FailoverTransport.php | 2 +- lib/classes/Swift/FileSpool.php | 4 +- lib/classes/Swift/InputByteStream.php | 8 +- lib/classes/Swift/IoException.php | 2 +- lib/classes/Swift/KeyCache.php | 6 +- lib/classes/Swift/KeyCache/ArrayKeyCache.php | 2 +- lib/classes/Swift/KeyCache/DiskKeyCache.php | 12 +- lib/classes/Swift/KeyCache/NullKeyCache.php | 2 +- .../KeyCache/SimpleKeyCacheInputStream.php | 6 +- lib/classes/Swift/LoadBalancedTransport.php | 2 +- lib/classes/Swift/MemorySpool.php | 2 +- lib/classes/Swift/Message.php | 2 +- .../ContentEncoder/NativeQpContentEncoder.php | 4 +- .../ContentEncoder/PlainContentEncoder.php | 4 +- .../Mime/ContentEncoder/QpContentEncoder.php | 4 +- .../ContentEncoder/QpContentEncoderProxy.php | 12 - lib/classes/Swift/Mime/Header.php | 16 +- .../Swift/Mime/Headers/AbstractHeader.php | 14 +- .../Mime/Headers/IdentificationHeader.php | 8 +- .../Swift/Mime/Headers/MailboxHeader.php | 24 +- .../Mime/Headers/ParameterizedHeader.php | 14 +- lib/classes/Swift/Mime/Headers/PathHeader.php | 4 +- .../Swift/Mime/Headers/UnstructuredHeader.php | 2 +- lib/classes/Swift/Mime/MimePart.php | 1 - .../Swift/Mime/SimpleHeaderFactory.php | 4 +- lib/classes/Swift/Mime/SimpleHeaderSet.php | 2 +- lib/classes/Swift/Mime/SimpleMessage.php | 28 +-- lib/classes/Swift/Mime/SimpleMimeEntity.php | 17 +- lib/classes/Swift/MimePart.php | 2 +- lib/classes/Swift/OutputByteStream.php | 8 +- lib/classes/Swift/Plugins/AntiFloodPlugin.php | 2 +- lib/classes/Swift/Plugins/DecoratorPlugin.php | 4 +- .../Swift/Plugins/RedirectingPlugin.php | 8 - lib/classes/Swift/Plugins/Reporter.php | 4 +- lib/classes/Swift/Plugins/ReporterPlugin.php | 6 +- lib/classes/Swift/Plugins/ThrottlerPlugin.php | 8 +- lib/classes/Swift/Preferences.php | 2 +- .../Swift/ReplacementFilterFactory.php | 3 - lib/classes/Swift/SendmailTransport.php | 2 +- lib/classes/Swift/Signers/DKIMSigner.php | 12 +- lib/classes/Swift/Signers/DomainKeySigner.php | 19 +- lib/classes/Swift/Signers/OpenDKIMSigner.php | 10 +- lib/classes/Swift/Signers/SMimeSigner.php | 32 +-- lib/classes/Swift/SmtpTransport.php | 10 +- lib/classes/Swift/StreamFilter.php | 6 - lib/classes/Swift/SwiftException.php | 2 +- .../Swift/Transport/AbstractSmtpTransport.php | 19 +- .../Esmtp/Auth/CramMd5Authenticator.php | 3 - .../Esmtp/Auth/LoginAuthenticator.php | 3 - .../Esmtp/Auth/NTLMAuthenticator.php | 14 +- .../Esmtp/Auth/PlainAuthenticator.php | 3 - .../Esmtp/Auth/XOAuth2Authenticator.php | 3 - .../Swift/Transport/EsmtpTransport.php | 14 +- .../Swift/Transport/FailoverTransport.php | 3 - lib/classes/Swift/Transport/IoBuffer.php | 5 +- .../Swift/Transport/LoadBalancedTransport.php | 5 +- lib/classes/Swift/Transport/NullTransport.php | 5 +- .../Swift/Transport/SendmailTransport.php | 6 +- .../Swift/Transport/SpoolTransport.php | 5 +- lib/classes/Swift/Transport/StreamBuffer.php | 3 +- lib/classes/Swift/TransportException.php | 2 +- lib/preferences.php | 6 +- tests/IdenticalBinaryConstraint.php | 2 +- tests/SwiftMailerSmokeTestCase.php | 6 +- tests/SwiftMailerTestCase.php | 6 +- .../FileByteStreamAcceptanceTest.php | 4 +- ...leCharacterReaderFactoryAcceptanceTest.php | 2 +- .../DependencyContainerAcceptanceTest.php | 2 +- .../Encoder/Base64EncoderAcceptanceTest.php | 4 +- .../Swift/Encoder/QpEncoderAcceptanceTest.php | 4 +- .../Encoder/Rfc2231EncoderAcceptanceTest.php | 4 +- .../KeyCache/ArrayKeyCacheAcceptanceTest.php | 42 ++-- .../KeyCache/DiskKeyCacheAcceptanceTest.php | 40 ++-- .../Swift/MessageAcceptanceTest.php | 2 +- .../Swift/Mime/AttachmentAcceptanceTest.php | 24 +- .../Base64ContentEncoderAcceptanceTest.php | 4 +- .../NativeQpContentEncoderAcceptanceTest.php | 6 +- .../PlainContentEncoderAcceptanceTest.php | 6 +- .../QpContentEncoderAcceptanceTest.php | 8 +- .../Swift/Mime/EmbeddedFileAcceptanceTest.php | 24 +- .../Base64HeaderEncoderAcceptanceTest.php | 2 +- .../Swift/Mime/MimePartAcceptanceTest.php | 24 +- .../Mime/SimpleMessageAcceptanceTest.php | 90 ++++---- .../AbstractStreamBufferAcceptanceTest.php | 4 +- .../BasicSocketAcceptanceTest.php | 2 +- .../StreamBuffer/SocketTimeoutTest.php | 4 +- .../StreamBuffer/SslSocketAcceptanceTest.php | 4 +- tests/bug/Swift/Bug111Test.php | 2 +- tests/bug/Swift/Bug118Test.php | 2 +- tests/bug/Swift/Bug206Test.php | 2 +- tests/bug/Swift/Bug274Test.php | 4 +- tests/bug/Swift/Bug34Test.php | 82 +++---- tests/bug/Swift/Bug35Test.php | 80 +++---- tests/bug/Swift/Bug38Test.php | 4 +- tests/bug/Swift/Bug518Test.php | 4 +- tests/bug/Swift/Bug51Test.php | 8 +- tests/bug/Swift/Bug534Test.php | 2 +- tests/bug/Swift/Bug650Test.php | 2 +- tests/bug/Swift/Bug71Test.php | 2 +- tests/bug/Swift/Bug76Test.php | 6 +- ...FileByteStreamConsecutiveReadCallsTest.php | 8 +- .../smoke/Swift/Smoke/AttachmentSmokeTest.php | 6 +- tests/smoke/Swift/Smoke/BasicSmokeTest.php | 6 +- .../Smoke/HtmlWithAttachmentSmokeTest.php | 4 +- .../Swift/Smoke/InternationalSmokeTest.php | 12 +- .../Swift/ByteStream/ArrayByteStreamTest.php | 25 ++- .../GenericFixedWidthReaderTest.php | 12 +- .../CharacterReader/UsAsciiReaderTest.php | 8 +- .../Swift/CharacterReader/Utf8ReaderTest.php | 14 +- .../ArrayCharacterStreamTest.php | 28 +-- tests/unit/Swift/DependencyContainerTest.php | 4 +- .../unit/Swift/Encoder/Base64EncoderTest.php | 60 ++--- tests/unit/Swift/Encoder/QpEncoderTest.php | 22 +- .../unit/Swift/Encoder/Rfc2231EncoderTest.php | 6 +- tests/unit/Swift/Events/CommandEventTest.php | 2 +- tests/unit/Swift/Events/EventObjectTest.php | 2 +- tests/unit/Swift/Events/ResponseEventTest.php | 6 +- tests/unit/Swift/Events/SendEventTest.php | 12 +- .../Events/SimpleEventDispatcherTest.php | 2 +- .../Swift/Events/TransportChangeEventTest.php | 2 +- .../Events/TransportExceptionEventTest.php | 6 +- .../unit/Swift/KeyCache/ArrayKeyCacheTest.php | 42 ++-- .../SimpleKeyCacheInputStreamTest.php | 2 +- .../Mailer/ArrayRecipientIteratorTest.php | 2 +- tests/unit/Swift/MailerTest.php | 6 +- tests/unit/Swift/MessageTest.php | 2 +- .../Swift/Mime/AbstractMimeEntityTest.php | 168 +++++++------- tests/unit/Swift/Mime/AttachmentTest.php | 56 ++--- .../Base64ContentEncoderTest.php | 72 +++--- .../PlainContentEncoderTest.php | 22 +- .../ContentEncoder/QpContentEncoderTest.php | 16 +- tests/unit/Swift/Mime/EmbeddedFileTest.php | 10 +- .../HeaderEncoder/Base64HeaderEncoderTest.php | 4 +- .../HeaderEncoder/QpHeaderEncoderTest.php | 24 +- .../Swift/Mime/Headers/DateHeaderTest.php | 4 +- .../Mime/Headers/IdentificationHeaderTest.php | 8 +- .../Swift/Mime/Headers/MailboxHeaderTest.php | 54 ++--- .../Mime/Headers/ParameterizedHeaderTest.php | 64 +++--- .../Swift/Mime/Headers/PathHeaderTest.php | 8 +- .../Mime/Headers/UnstructuredHeaderTest.php | 64 +++--- tests/unit/Swift/Mime/IdGeneratorTest.php | 2 +- tests/unit/Swift/Mime/MimePartTest.php | 48 ++-- .../Swift/Mime/SimpleHeaderFactoryTest.php | 10 +- tests/unit/Swift/Mime/SimpleHeaderSetTest.php | 20 +- tests/unit/Swift/Mime/SimpleMessageTest.php | 144 ++++++------ .../Swift/Plugins/AntiFloodPluginTest.php | 2 +- .../Plugins/BandwidthMonitorPluginTest.php | 2 +- .../Swift/Plugins/DecoratorPluginTest.php | 20 +- tests/unit/Swift/Plugins/LoggerPluginTest.php | 2 +- .../Swift/Plugins/Loggers/ArrayLoggerTest.php | 8 +- .../Swift/Plugins/Loggers/EchoLoggerTest.php | 2 +- .../Swift/Plugins/PopBeforeSmtpPluginTest.php | 2 +- .../Swift/Plugins/RedirectingPluginTest.php | 2 +- .../unit/Swift/Plugins/ReporterPluginTest.php | 2 +- .../Plugins/Reporters/HitReporterTest.php | 24 +- .../Plugins/Reporters/HtmlReporterTest.php | 10 +- .../Swift/Plugins/ThrottlerPluginTest.php | 36 +-- tests/unit/Swift/Signers/DKIMSignerTest.php | 4 +- .../unit/Swift/Signers/OpenDKIMSignerTest.php | 4 +- tests/unit/Swift/Signers/SMimeSignerTest.php | 2 +- .../ByteArrayReplacementFilterTest.php | 36 +-- .../StringReplacementFilterFactoryTest.php | 4 +- .../StringReplacementFilterTest.php | 8 +- .../AbstractSmtpEventSupportTest.php | 18 +- .../unit/Swift/Transport/AbstractSmtpTest.php | 8 +- .../Esmtp/Auth/CramMd5AuthenticatorTest.php | 10 +- .../Esmtp/Auth/LoginAuthenticatorTest.php | 6 +- .../Esmtp/Auth/NTLMAuthenticatorTest.php | 16 +- .../Esmtp/Auth/PlainAuthenticatorTest.php | 14 +- .../Swift/Transport/Esmtp/AuthHandlerTest.php | 14 +- .../EsmtpTransport/ExtensionSupportTest.php | 12 +- .../Swift/Transport/EsmtpTransportTest.php | 8 +- .../Swift/Transport/FailoverTransportTest.php | 38 ++-- .../Transport/LoadBalancedTransportTest.php | 211 +++++++++--------- .../Swift/Transport/SendmailTransportTest.php | 6 +- .../unit/Swift/Transport/StreamBufferTest.php | 2 +- 193 files changed, 1290 insertions(+), 1390 deletions(-) diff --git a/lib/classes/Swift.php b/lib/classes/Swift.php index 51b19c9cb..7840d16d3 100644 --- a/lib/classes/Swift.php +++ b/lib/classes/Swift.php @@ -15,7 +15,7 @@ */ abstract class Swift { - const VERSION = '6.3.0'; + public const VERSION = '6.3.0'; public static $initialized = false; public static $inits = []; diff --git a/lib/classes/Swift/Attachment.php b/lib/classes/Swift/Attachment.php index b7df37515..909e794d1 100644 --- a/lib/classes/Swift/Attachment.php +++ b/lib/classes/Swift/Attachment.php @@ -30,7 +30,7 @@ public function __construct($data = null, $filename = null, $contentType = null) 'Swift_Mime_Attachment::__construct', Swift_DependencyContainer::getInstance() ->createDependenciesFor('mime.attachment') - ); + ); $this->setBody($data, $contentType); $this->setFilename($filename); diff --git a/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php b/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php index 3a69c15f1..d1d1479a9 100644 --- a/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php +++ b/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php @@ -76,9 +76,9 @@ public function removeFilter($key) * * @param string $bytes * - * @throws Swift_IoException - * * @return int + * + * @throws Swift_IoException */ public function write($bytes) { diff --git a/lib/classes/Swift/ByteStream/FileByteStream.php b/lib/classes/Swift/ByteStream/FileByteStream.php index f6391219e..542a64d79 100644 --- a/lib/classes/Swift/ByteStream/FileByteStream.php +++ b/lib/classes/Swift/ByteStream/FileByteStream.php @@ -31,7 +31,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl private $writer; /** If stream is seekable true/false, or null if not known */ - private $seekable = null; + private $seekable; /** * Create a new FileByteStream for $path. diff --git a/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php b/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php index 0dc61909d..af2d07c95 100644 --- a/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php +++ b/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php @@ -42,11 +42,11 @@ public function __destruct() public function __sleep() { - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + throw new BadMethodCallException('Cannot serialize '.__CLASS__); } public function __wakeup() { - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + throw new BadMethodCallException('Cannot unserialize '.__CLASS__); } } diff --git a/lib/classes/Swift/CharacterReader.php b/lib/classes/Swift/CharacterReader.php index 4267adbc5..db108eaf9 100644 --- a/lib/classes/Swift/CharacterReader.php +++ b/lib/classes/Swift/CharacterReader.php @@ -16,9 +16,9 @@ */ interface Swift_CharacterReader { - const MAP_TYPE_INVALID = 0x01; - const MAP_TYPE_FIXED_LEN = 0x02; - const MAP_TYPE_POSITIONS = 0x03; + public const MAP_TYPE_INVALID = 0x01; + public const MAP_TYPE_FIXED_LEN = 0x02; + public const MAP_TYPE_POSITIONS = 0x03; /** * Returns the complete character map. @@ -26,7 +26,6 @@ interface Swift_CharacterReader * @param string $string * @param int $startOffset * @param array $currentMap - * @param mixed $ignoredChars * * @return int */ diff --git a/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php b/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php index 3e055afd9..2ac64ad45 100644 --- a/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php +++ b/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php @@ -39,7 +39,6 @@ public function __construct($width) * @param string $string * @param int $startOffset * @param array $currentMap - * @param mixed $ignoredChars * * @return int */ diff --git a/lib/classes/Swift/CharacterReader/Utf8Reader.php b/lib/classes/Swift/CharacterReader/Utf8Reader.php index da37e0da9..5da2ef30e 100644 --- a/lib/classes/Swift/CharacterReader/Utf8Reader.php +++ b/lib/classes/Swift/CharacterReader/Utf8Reader.php @@ -78,7 +78,6 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader * @param string $string * @param int $startOffset * @param array $currentMap - * @param mixed $ignoredChars * * @return int */ diff --git a/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php b/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php index 86900894a..3fa27a687 100644 --- a/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php +++ b/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php @@ -71,7 +71,7 @@ public function init() 'constructor' => [], ]; - //7-8 bit charsets + // 7-8 bit charsets self::$map['(us-)?ascii'] = $singleByte; self::$map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; self::$map['windows-?125[0-9]'] = $singleByte; @@ -84,10 +84,10 @@ public function init() self::$map['(cork|t1)'] = $singleByte; self::$map['v?iscii'] = $singleByte; - //16 bits + // 16 bits self::$map['(ucs-?2|utf-?16)'] = $doubleByte; - //32 bits + // 32 bits self::$map['(ucs-?4|utf-?32)'] = $fourBytes; // Fallback diff --git a/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php b/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php index 5c2869455..a30971514 100644 --- a/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php +++ b/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php @@ -92,8 +92,8 @@ public function importByteStream(Swift_OutputByteStream $os) $size = \count($c); $need = $this->charReader ->validateByteSequence($c, $size); - if ($need > 0 && - false !== $bytes = $os->read($need)) { + if ($need > 0 + && false !== $bytes = $os->read($need)) { for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { $c[] = self::$byteMap[$bytes[$i]]; } diff --git a/lib/classes/Swift/CharacterStream/NgCharacterStream.php b/lib/classes/Swift/CharacterStream/NgCharacterStream.php index 7578dda9c..57ad3d054 100644 --- a/lib/classes/Swift/CharacterStream/NgCharacterStream.php +++ b/lib/classes/Swift/CharacterStream/NgCharacterStream.php @@ -52,8 +52,6 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream /** * Map. - * - * @var mixed */ private $map; @@ -165,8 +163,8 @@ public function read($length) case Swift_CharacterReader::MAP_TYPE_FIXED_LEN: $len = $length * $this->map; $ret = substr($this->datas, - $this->currentPos * $this->map, - $len); + $this->currentPos * $this->map, + $len); $this->currentPos += $length; break; diff --git a/lib/classes/Swift/DependencyContainer.php b/lib/classes/Swift/DependencyContainer.php index 3cc885ec0..61e8b5d89 100644 --- a/lib/classes/Swift/DependencyContainer.php +++ b/lib/classes/Swift/DependencyContainer.php @@ -16,22 +16,22 @@ class Swift_DependencyContainer { /** Constant for literal value types */ - const TYPE_VALUE = 0x00001; + public const TYPE_VALUE = 0x00001; /** Constant for new instance types */ - const TYPE_INSTANCE = 0x00010; + public const TYPE_INSTANCE = 0x00010; /** Constant for shared instance types */ - const TYPE_SHARED = 0x00100; + public const TYPE_SHARED = 0x00100; /** Constant for aliases */ - const TYPE_ALIAS = 0x01000; + public const TYPE_ALIAS = 0x01000; /** Constant for arrays */ - const TYPE_ARRAY = 0x10000; + public const TYPE_ARRAY = 0x10000; /** Singleton instance */ - private static $instance = null; + private static $instance; /** The data container */ private $store = []; @@ -94,8 +94,6 @@ public function has($itemName) * * @param string $itemName * - * @return mixed - * * @throws Swift_DependencyException If the dependency is not found */ public function lookup($itemName) @@ -161,8 +159,6 @@ public function register($itemName) * * {@link register()} must be called before this will work. * - * @param mixed $value - * * @return $this */ public function asValue($value) @@ -271,8 +267,6 @@ public function withDependencies(array $lookups) * * @see withDependencies(), addConstructorLookup() * - * @param mixed $value - * * @return $this */ public function addConstructorValue($value) @@ -326,7 +320,7 @@ private function createNewInstance($itemName) if ($reflector->getConstructor()) { return $reflector->newInstanceArgs( $this->createDependenciesFor($itemName) - ); + ); } return $reflector->newInstance(); diff --git a/lib/classes/Swift/EmbeddedFile.php b/lib/classes/Swift/EmbeddedFile.php index b4d79d72e..60440e172 100644 --- a/lib/classes/Swift/EmbeddedFile.php +++ b/lib/classes/Swift/EmbeddedFile.php @@ -30,7 +30,7 @@ public function __construct($data = null, $filename = null, $contentType = null) 'Swift_Mime_EmbeddedFile::__construct', Swift_DependencyContainer::getInstance() ->createDependenciesFor('mime.embeddedfile') - ); + ); $this->setBody($data); $this->setFilename($filename); diff --git a/lib/classes/Swift/Encoder/Base64Encoder.php b/lib/classes/Swift/Encoder/Base64Encoder.php index b1eedaa05..82277d48c 100644 --- a/lib/classes/Swift/Encoder/Base64Encoder.php +++ b/lib/classes/Swift/Encoder/Base64Encoder.php @@ -40,10 +40,10 @@ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) if (0 != $firstLineOffset) { $firstLine = substr( $encodedString, 0, $maxLineLength - $firstLineOffset - )."\r\n"; + )."\r\n"; $encodedString = substr( $encodedString, $maxLineLength - $firstLineOffset - ); + ); } return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n")); diff --git a/lib/classes/Swift/Encoder/QpEncoder.php b/lib/classes/Swift/Encoder/QpEncoder.php index f078d6d7c..5623510ef 100644 --- a/lib/classes/Swift/Encoder/QpEncoder.php +++ b/lib/classes/Swift/Encoder/QpEncoder.php @@ -106,7 +106,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder * @param Swift_CharacterStream $charStream to use for reading characters * @param Swift_StreamFilter $filter if input should be canonicalized */ - public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null) + public function __construct(Swift_CharacterStream $charStream, ?Swift_StreamFilter $filter = null) { $this->charStream = $charStream; if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { @@ -280,7 +280,7 @@ protected function standardize($string) { $string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string - ); + ); switch ($end = \ord(substr($string, -1))) { case 0x09: case 0x20: diff --git a/lib/classes/Swift/Events/Event.php b/lib/classes/Swift/Events/Event.php index 720b15637..d3270241d 100644 --- a/lib/classes/Swift/Events/Event.php +++ b/lib/classes/Swift/Events/Event.php @@ -24,8 +24,6 @@ public function getSource(); /** * Prevent this Event from bubbling any further up the stack. - * - * @param bool $cancel, optional */ public function cancelBubble($cancel = true); diff --git a/lib/classes/Swift/Events/SendEvent.php b/lib/classes/Swift/Events/SendEvent.php index a435691e0..5abecbc74 100644 --- a/lib/classes/Swift/Events/SendEvent.php +++ b/lib/classes/Swift/Events/SendEvent.php @@ -16,19 +16,19 @@ class Swift_Events_SendEvent extends Swift_Events_EventObject { /** Sending has yet to occur */ - const RESULT_PENDING = 0x0001; + public const RESULT_PENDING = 0x0001; /** Email is spooled, ready to be sent */ - const RESULT_SPOOLED = 0x0011; + public const RESULT_SPOOLED = 0x0011; /** Sending was successful */ - const RESULT_SUCCESS = 0x0010; + public const RESULT_SUCCESS = 0x0010; /** Sending worked, but there were some failures */ - const RESULT_TENTATIVE = 0x0100; + public const RESULT_TENTATIVE = 0x0100; /** Sending failed */ - const RESULT_FAILED = 0x1000; + public const RESULT_FAILED = 0x1000; /** * The Message being sent. diff --git a/lib/classes/Swift/FailoverTransport.php b/lib/classes/Swift/FailoverTransport.php index 7ecb1d392..2f7e8d699 100644 --- a/lib/classes/Swift/FailoverTransport.php +++ b/lib/classes/Swift/FailoverTransport.php @@ -26,7 +26,7 @@ public function __construct($transports = []) 'Swift_Transport_FailoverTransport::__construct', Swift_DependencyContainer::getInstance() ->createDependenciesFor('transport.failover') - ); + ); $this->setTransports($transports); } diff --git a/lib/classes/Swift/FileSpool.php b/lib/classes/Swift/FileSpool.php index 7af8471c9..42387a965 100644 --- a/lib/classes/Swift/FileSpool.php +++ b/lib/classes/Swift/FileSpool.php @@ -85,9 +85,9 @@ public function setRetryLimit($limit) * * @param Swift_Mime_SimpleMessage $message The message to store * - * @throws Swift_IoException - * * @return bool + * + * @throws Swift_IoException */ public function queueMessage(Swift_Mime_SimpleMessage $message) { diff --git a/lib/classes/Swift/InputByteStream.php b/lib/classes/Swift/InputByteStream.php index 379a5a178..aa57daf59 100644 --- a/lib/classes/Swift/InputByteStream.php +++ b/lib/classes/Swift/InputByteStream.php @@ -30,9 +30,9 @@ interface Swift_InputByteStream * * @param string $bytes * - * @throws Swift_IoException - * * @return int + * + * @throws Swift_IoException */ public function write($bytes); @@ -49,8 +49,6 @@ public function commit(); * * The stream acts as an observer, receiving all data that is written. * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @param Swift_InputByteStream $is */ public function bind(self $is); @@ -60,8 +58,6 @@ public function bind(self $is); * If $is is not bound, no errors will be raised. * If the stream currently has any buffered data it will be written to $is * before unbinding occurs. - * - * @param Swift_InputByteStream $is */ public function unbind(self $is); diff --git a/lib/classes/Swift/IoException.php b/lib/classes/Swift/IoException.php index 5452bd416..121de0a53 100644 --- a/lib/classes/Swift/IoException.php +++ b/lib/classes/Swift/IoException.php @@ -21,7 +21,7 @@ class Swift_IoException extends Swift_SwiftException * @param string $message * @param int $code */ - public function __construct($message, $code = 0, Exception $previous = null) + public function __construct($message, $code = 0, ?Exception $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/lib/classes/Swift/KeyCache.php b/lib/classes/Swift/KeyCache.php index 87f6a0742..d7cc98b72 100644 --- a/lib/classes/Swift/KeyCache.php +++ b/lib/classes/Swift/KeyCache.php @@ -16,10 +16,10 @@ interface Swift_KeyCache { /** Mode for replacing existing cached data */ - const MODE_WRITE = 1; + public const MODE_WRITE = 1; /** Mode for appending data to the end of existing cached data */ - const MODE_APPEND = 2; + public const MODE_APPEND = 2; /** * Set a string into the cache under $itemKey for the namespace $nsKey. @@ -56,7 +56,7 @@ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $o * * @return Swift_InputByteStream */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $is = null); + public function getInputByteStream($nsKey, $itemKey, ?Swift_InputByteStream $is = null); /** * Get data back out of the cache as a string. diff --git a/lib/classes/Swift/KeyCache/ArrayKeyCache.php b/lib/classes/Swift/KeyCache/ArrayKeyCache.php index e8fef1c95..44765b768 100644 --- a/lib/classes/Swift/KeyCache/ArrayKeyCache.php +++ b/lib/classes/Swift/KeyCache/ArrayKeyCache.php @@ -105,7 +105,7 @@ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $o * * @return Swift_InputByteStream */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + public function getInputByteStream($nsKey, $itemKey, ?Swift_InputByteStream $writeThrough = null) { $is = clone $this->stream; $is->setKeyCache($this); diff --git a/lib/classes/Swift/KeyCache/DiskKeyCache.php b/lib/classes/Swift/KeyCache/DiskKeyCache.php index 33b6367cb..d765c5a16 100644 --- a/lib/classes/Swift/KeyCache/DiskKeyCache.php +++ b/lib/classes/Swift/KeyCache/DiskKeyCache.php @@ -16,13 +16,13 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache { /** Signal to place pointer at start of file */ - const POSITION_START = 0; + public const POSITION_START = 0; /** Signal to place pointer at end of file */ - const POSITION_END = 1; + public const POSITION_END = 1; /** Signal to leave pointer in whatever position it currently is */ - const POSITION_CURRENT = 2; + public const POSITION_CURRENT = 2; /** * An InputStream for cloning. @@ -128,7 +128,7 @@ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $o * * @return Swift_InputByteStream */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + public function getInputByteStream($nsKey, $itemKey, ?Swift_InputByteStream $writeThrough = null) { $is = clone $this->stream; $is->setKeyCache($this); @@ -147,9 +147,9 @@ public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writ * @param string $nsKey * @param string $itemKey * - * @throws Swift_IoException - * * @return string + * + * @throws Swift_IoException */ public function getString($nsKey, $itemKey) { diff --git a/lib/classes/Swift/KeyCache/NullKeyCache.php b/lib/classes/Swift/KeyCache/NullKeyCache.php index 957b1b2a0..6bddd9ec1 100644 --- a/lib/classes/Swift/KeyCache/NullKeyCache.php +++ b/lib/classes/Swift/KeyCache/NullKeyCache.php @@ -52,7 +52,7 @@ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $o * * @return Swift_InputByteStream */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + public function getInputByteStream($nsKey, $itemKey, ?Swift_InputByteStream $writeThrough = null) { } diff --git a/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php b/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php index 03bab481e..f1d5cd984 100644 --- a/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php +++ b/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php @@ -25,7 +25,7 @@ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCach private $itemKey; /** A stream to write through on each write() */ - private $writeThrough = null; + private $writeThrough; /** * Set the KeyCache to wrap. @@ -49,11 +49,11 @@ public function setWriteThroughStream(Swift_InputByteStream $is) * @param string $bytes * @param Swift_InputByteStream $is optional */ - public function write($bytes, Swift_InputByteStream $is = null) + public function write($bytes, ?Swift_InputByteStream $is = null) { $this->keyCache->setString( $this->nsKey, $this->itemKey, $bytes, Swift_KeyCache::MODE_APPEND - ); + ); if (isset($is)) { $is->write($bytes); } diff --git a/lib/classes/Swift/LoadBalancedTransport.php b/lib/classes/Swift/LoadBalancedTransport.php index 2a87f1ad1..e65e1e2c9 100644 --- a/lib/classes/Swift/LoadBalancedTransport.php +++ b/lib/classes/Swift/LoadBalancedTransport.php @@ -26,7 +26,7 @@ public function __construct($transports = []) 'Swift_Transport_LoadBalancedTransport::__construct', Swift_DependencyContainer::getInstance() ->createDependenciesFor('transport.loadbalanced') - ); + ); $this->setTransports($transports); } diff --git a/lib/classes/Swift/MemorySpool.php b/lib/classes/Swift/MemorySpool.php index e3b0894d8..83cea3fb1 100644 --- a/lib/classes/Swift/MemorySpool.php +++ b/lib/classes/Swift/MemorySpool.php @@ -59,7 +59,7 @@ public function setFlushRetries($retries) */ public function queueMessage(Swift_Mime_SimpleMessage $message) { - //clone the message to make sure it is not changed while in the queue + // clone the message to make sure it is not changed while in the queue $this->messages[] = clone $message; return true; diff --git a/lib/classes/Swift/Message.php b/lib/classes/Swift/Message.php index f8e4bb14c..818d18b86 100644 --- a/lib/classes/Swift/Message.php +++ b/lib/classes/Swift/Message.php @@ -46,7 +46,7 @@ public function __construct($subject = null, $body = null, $contentType = null, 'Swift_Mime_SimpleMessage::__construct', Swift_DependencyContainer::getInstance() ->createDependenciesFor('mime.message') - ); + ); if (!isset($charset)) { $charset = Swift_DependencyContainer::getInstance() diff --git a/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php b/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php index 8dfea605f..8c967d20b 100644 --- a/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php +++ b/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php @@ -80,9 +80,9 @@ public function getName() * @param int $firstLineOffset if first line needs to be shorter * @param int $maxLineLength 0 indicates the default length for this encoding * - * @throws RuntimeException - * * @return string + * + * @throws RuntimeException */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) { diff --git a/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php b/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php index 72592fc58..4beb366aa 100644 --- a/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php +++ b/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php @@ -130,7 +130,7 @@ private function safeWordwrap($string, $length = 75, $le = "\r\n") $lines[] = ''; $currentLine = &$lines[$lineCount++]; - //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine); + // $chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine); $chunks = preg_split('/(?<=\s)/', $originalLine); foreach ($chunks as $chunk) { @@ -159,6 +159,6 @@ private function canonicalize($string) ["\r\n", "\r", "\n"], ["\n", "\n", "\r\n"], $string - ); + ); } } diff --git a/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php index 465ffd878..716d92a09 100644 --- a/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php +++ b/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php @@ -24,7 +24,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder * @param Swift_StreamFilter $filter if canonicalization should occur * @param bool $dotEscape if dot stuffing workaround must be enabled */ - public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null, $dotEscape = false) + public function __construct(Swift_CharacterStream $charStream, ?Swift_StreamFilter $filter = null, $dotEscape = false) { $this->dotEscape = $dotEscape; parent::__construct($charStream, $filter); @@ -45,7 +45,7 @@ protected function initSafeMap() parent::initSafeMap(); if ($this->dotEscape) { /* Encode . as =2e for buggy remote servers */ - unset($this->safeMap[0x2e]); + unset($this->safeMap[0x2E]); } } diff --git a/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php index f3ece43ae..265c98896 100644 --- a/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php +++ b/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -53,34 +53,22 @@ public function __clone() $this->nativeEncoder = clone $this->nativeEncoder; } - /** - * {@inheritdoc} - */ public function charsetChanged($charset) { $this->charset = $charset; $this->safeEncoder->charsetChanged($charset); } - /** - * {@inheritdoc} - */ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) { $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength); } - /** - * {@inheritdoc} - */ public function getName() { return 'quoted-printable'; } - /** - * {@inheritdoc} - */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) { return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength); diff --git a/lib/classes/Swift/Mime/Header.php b/lib/classes/Swift/Mime/Header.php index ca712f35a..380436298 100644 --- a/lib/classes/Swift/Mime/Header.php +++ b/lib/classes/Swift/Mime/Header.php @@ -16,22 +16,22 @@ interface Swift_Mime_Header { /** Text headers */ - const TYPE_TEXT = 2; + public const TYPE_TEXT = 2; /** headers (text + params) */ - const TYPE_PARAMETERIZED = 6; + public const TYPE_PARAMETERIZED = 6; /** Mailbox and address headers */ - const TYPE_MAILBOX = 8; + public const TYPE_MAILBOX = 8; /** Date and time headers */ - const TYPE_DATE = 16; + public const TYPE_DATE = 16; /** Identification headers */ - const TYPE_ID = 32; + public const TYPE_ID = 32; /** Address path headers */ - const TYPE_PATH = 64; + public const TYPE_PATH = 64; /** * Get the type of Header that this instance represents. @@ -47,8 +47,6 @@ public function getFieldType(); * Set the model for the field body. * * The actual types needed will vary depending upon the type of Header. - * - * @param mixed $model */ public function setFieldBodyModel($model); @@ -63,8 +61,6 @@ public function setCharset($charset); * Get the model for the field body. * * The return type depends on the specifics of the Header. - * - * @return mixed */ public function getFieldBodyModel(); diff --git a/lib/classes/Swift/Mime/Headers/AbstractHeader.php b/lib/classes/Swift/Mime/Headers/AbstractHeader.php index 25740d115..11b4b1357 100644 --- a/lib/classes/Swift/Mime/Headers/AbstractHeader.php +++ b/lib/classes/Swift/Mime/Headers/AbstractHeader.php @@ -15,7 +15,7 @@ */ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header { - const PHRASE_PATTERN = '(?:(?:(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]+(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?)|(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?"((?:(?:[ \t]*(?:\r\n))?[ \t])?(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21\x23-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])))*(?:(?:[ \t]*(?:\r\n))?[ \t])?"(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?))+?)'; + public const PHRASE_PATTERN = '(?:(?:(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]+(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?)|(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?"((?:(?:[ \t]*(?:\r\n))?[ \t])?(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21\x23-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])))*(?:(?:[ \t]*(?:\r\n))?[ \t])?"(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?))+?)'; /** * The name of this Header. @@ -57,7 +57,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header * * @var string */ - private $cachedValue = null; + private $cachedValue; /** * Set the character set used in this Header. @@ -200,7 +200,7 @@ protected function setFieldName($name) * * @return string */ - protected function createPhrase(Swift_Mime_Header $header, $string, $charset, Swift_Mime_HeaderEncoder $encoder = null, $shorten = false) + protected function createPhrase(Swift_Mime_Header $header, $string, $charset, ?Swift_Mime_HeaderEncoder $encoder = null, $shorten = false) { // Treat token as exactly what was given $phraseStr = $string; @@ -344,10 +344,10 @@ protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) } $encodingWrapperLength = \strlen( '=?'.$charsetDecl.'?'.$this->encoder->getName().'??=' - ); + ); if ($firstLineOffset >= 75) { - //Does this logic need to be here? + // Does this logic need to be here? $firstLineOffset = 0; } @@ -457,8 +457,8 @@ private function tokensToString(array $tokens) // Build all tokens back into compliant header foreach ($tokens as $i => $token) { // Line longer than specified maximum or token was just a new line - if (("\r\n" == $token) || - ($i > 0 && \strlen($currentLine.$token) > $this->lineLength) + if (("\r\n" == $token) + || ($i > 0 && \strlen($currentLine.$token) > $this->lineLength) && 0 < \strlen($currentLine)) { $headerLines[] = ''; $currentLine = &$headerLines[$lineCount++]; diff --git a/lib/classes/Swift/Mime/Headers/IdentificationHeader.php b/lib/classes/Swift/Mime/Headers/IdentificationHeader.php index 4fcdff418..e73249448 100644 --- a/lib/classes/Swift/Mime/Headers/IdentificationHeader.php +++ b/lib/classes/Swift/Mime/Headers/IdentificationHeader.php @@ -42,7 +42,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac * * @param string $name */ - public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) + public function __construct($name, EmailValidator $emailValidator, ?Swift_AddressEncoder $addressEncoder = null) { $this->setFieldName($name); $this->emailValidator = $emailValidator; @@ -67,8 +67,6 @@ public function getFieldType() * * This method takes a string ID, or an array of IDs. * - * @param mixed $model - * * @throws Swift_RfcComplianceException */ public function setFieldBodyModel($model) @@ -152,9 +150,9 @@ public function getIds() * * @see toString() * - * @throws Swift_RfcComplianceException - * * @return string + * + * @throws Swift_RfcComplianceException */ public function getFieldBody() { diff --git a/lib/classes/Swift/Mime/Headers/MailboxHeader.php b/lib/classes/Swift/Mime/Headers/MailboxHeader.php index ddd5e8cff..500115204 100644 --- a/lib/classes/Swift/Mime/Headers/MailboxHeader.php +++ b/lib/classes/Swift/Mime/Headers/MailboxHeader.php @@ -39,7 +39,7 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader * * @param string $name of Header */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) + public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator, ?Swift_AddressEncoder $addressEncoder = null) { $this->setFieldName($name); $this->setEncoder($encoder); @@ -65,8 +65,6 @@ public function getFieldType() * * This method takes a string, or an array of addresses. * - * @param mixed $model - * * @throws Swift_RfcComplianceException */ public function setFieldBodyModel($model) @@ -79,9 +77,9 @@ public function setFieldBodyModel($model) * * This method returns an associative array like {@link getNameAddresses()} * - * @throws Swift_RfcComplianceException - * * @return array + * + * @throws Swift_RfcComplianceException */ public function getFieldBodyModel() { @@ -115,7 +113,7 @@ public function getFieldBodyModel() public function setNameAddresses($mailboxes) { $this->mailboxes = $this->normalizeMailboxes((array) $mailboxes); - $this->setCachedValue(null); //Clear any cached value + $this->setCachedValue(null); // Clear any cached value } /** @@ -139,9 +137,9 @@ public function setNameAddresses($mailboxes) * @see getNameAddresses() * @see toString() * - * @throws Swift_RfcComplianceException - * * @return string[] + * + * @throws Swift_RfcComplianceException */ public function getNameAddressStrings() { @@ -235,9 +233,9 @@ public function removeAddresses($addresses) * * @see toString() * - * @throws Swift_RfcComplianceException - * * @return string + * + * @throws Swift_RfcComplianceException */ public function getFieldBody() { @@ -262,7 +260,7 @@ protected function normalizeMailboxes(array $mailboxes) foreach ($mailboxes as $key => $value) { if (\is_string($key)) { - //key is email addr + // key is email addr $address = $key; $name = $value; } else { @@ -294,9 +292,9 @@ protected function createDisplayNameString($displayName, $shorten = false) * * @param string[] $mailboxes * - * @throws Swift_RfcComplianceException - * * @return string + * + * @throws Swift_RfcComplianceException */ protected function createMailboxListString(array $mailboxes) { diff --git a/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php b/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php index 47c15e6c0..d59a6c41d 100644 --- a/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php +++ b/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php @@ -20,7 +20,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct * * @var string */ - const TOKEN_REGEX = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)'; + public const TOKEN_REGEX = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)'; /** * The Encoder used to encode the parameters. @@ -41,7 +41,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct * * @param string $name */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder = null) + public function __construct($name, Swift_Mime_HeaderEncoder $encoder, ?Swift_Encoder $paramEncoder = null) { parent::__construct($name, $encoder); $this->paramEncoder = $paramEncoder; @@ -124,7 +124,7 @@ public function getParameters() * * @return string */ - public function getFieldBody() //TODO: Check caching here + public function getFieldBody() // TODO: Check caching here { $body = parent::getFieldBody(); foreach ($this->params as $name => $value) { @@ -158,7 +158,7 @@ protected function toTokens($string = null) $tokens[\count($tokens) - 1] .= ';'; $tokens = array_merge($tokens, $this->generateTokenLines( ' '.$this->createParameter($name, $value) - )); + )); } } @@ -192,7 +192,7 @@ private function createParameter($name, $value) $maxValueLength = $this->getMaxLineLength() - \strlen($name.'*N*="";') - 1; $firstLineOffset = \strlen( $this->getCharset()."'".$this->getLanguage()."'" - ); + ); } } @@ -201,7 +201,7 @@ private function createParameter($name, $value) if (isset($this->paramEncoder)) { $value = $this->paramEncoder->encodeString( $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() - ); + ); } else { // We have to go against RFC 2183/2231 in some areas for interoperability $value = $this->getTokenAsEncodedWord($origValue); @@ -223,7 +223,7 @@ private function createParameter($name, $value) } else { return $name.$this->getEndOfParameterValue( $valueLines[0], $encoded, true - ); + ); } } diff --git a/lib/classes/Swift/Mime/Headers/PathHeader.php b/lib/classes/Swift/Mime/Headers/PathHeader.php index 81b421ee7..c7071760c 100644 --- a/lib/classes/Swift/Mime/Headers/PathHeader.php +++ b/lib/classes/Swift/Mime/Headers/PathHeader.php @@ -39,7 +39,7 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader * * @param string $name */ - public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) + public function __construct($name, EmailValidator $emailValidator, ?Swift_AddressEncoder $addressEncoder = null) { $this->setFieldName($name); $this->emailValidator = $emailValidator; @@ -75,8 +75,6 @@ public function setFieldBodyModel($model) /** * Get the model for the field body. * This method returns a string email address. - * - * @return mixed */ public function getFieldBodyModel() { diff --git a/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php b/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php index 64f160dec..6464cbefc 100644 --- a/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php +++ b/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php @@ -101,7 +101,7 @@ public function getFieldBody() if (!$this->getCachedValue()) { $this->setCachedValue( $this->encodeWords($this, $this->value) - ); + ); } return $this->getCachedValue(); diff --git a/lib/classes/Swift/Mime/MimePart.php b/lib/classes/Swift/Mime/MimePart.php index d0b2e6586..a31fc966e 100644 --- a/lib/classes/Swift/Mime/MimePart.php +++ b/lib/classes/Swift/Mime/MimePart.php @@ -45,7 +45,6 @@ public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_Cont * Set the body of this entity, either as a string, or as an instance of * {@link Swift_OutputByteStream}. * - * @param mixed $body * @param string $contentType optional * @param string $charset optional * diff --git a/lib/classes/Swift/Mime/SimpleHeaderFactory.php b/lib/classes/Swift/Mime/SimpleHeaderFactory.php index ab3ce6b19..4e3740310 100644 --- a/lib/classes/Swift/Mime/SimpleHeaderFactory.php +++ b/lib/classes/Swift/Mime/SimpleHeaderFactory.php @@ -37,7 +37,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver * * @param string|null $charset */ - public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null, Swift_AddressEncoder $addressEncoder = null) + public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null, ?Swift_AddressEncoder $addressEncoder = null) { $this->encoder = $encoder; $this->paramEncoder = $paramEncoder; @@ -72,7 +72,7 @@ public function createMailboxHeader($name, $addresses = null) * * @return Swift_Mime_Header */ - public function createDateHeader($name, DateTimeInterface $dateTime = null) + public function createDateHeader($name, ?DateTimeInterface $dateTime = null) { $header = new Swift_Mime_Headers_DateHeader($name); if (isset($dateTime)) { diff --git a/lib/classes/Swift/Mime/SimpleHeaderSet.php b/lib/classes/Swift/Mime/SimpleHeaderSet.php index 5195bcf48..3af1a3e63 100644 --- a/lib/classes/Swift/Mime/SimpleHeaderSet.php +++ b/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -76,7 +76,7 @@ public function addMailboxHeader($name, $addresses = null) * * @param string $name */ - public function addDateHeader($name, DateTimeInterface $dateTime = null) + public function addDateHeader($name, ?DateTimeInterface $dateTime = null) { $this->storeHeader($name, $this->factory->createDateHeader($name, $dateTime)); } diff --git a/lib/classes/Swift/Mime/SimpleMessage.php b/lib/classes/Swift/Mime/SimpleMessage.php index 62da1650a..1ee73084f 100644 --- a/lib/classes/Swift/Mime/SimpleMessage.php +++ b/lib/classes/Swift/Mime/SimpleMessage.php @@ -15,11 +15,11 @@ */ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart { - const PRIORITY_HIGHEST = 1; - const PRIORITY_HIGH = 2; - const PRIORITY_NORMAL = 3; - const PRIORITY_LOW = 4; - const PRIORITY_LOWEST = 5; + public const PRIORITY_HIGHEST = 1; + public const PRIORITY_HIGH = 2; + public const PRIORITY_NORMAL = 3; + public const PRIORITY_LOW = 4; + public const PRIORITY_LOWEST = 5; /** * Create a new SimpleMessage with $headers, $encoder and $cache. @@ -219,8 +219,6 @@ public function setFrom($addresses, $name = null) /** * Get the from address of this message. - * - * @return mixed */ public function getFrom() { @@ -253,8 +251,7 @@ public function addReplyTo($address, $name = null) * If $name is passed and the first parameter is a string, this name will be * associated with the address. * - * @param mixed $addresses - * @param string $name optional + * @param string $name optional * * @return $this */ @@ -308,8 +305,7 @@ public function addTo($address, $name = null) * If $name is passed and the first parameter is a string, this name will be * associated with the address. * - * @param mixed $addresses - * @param string $name optional + * @param string $name optional * * @return $this */ @@ -360,8 +356,7 @@ public function addCc($address, $name = null) * If $name is passed and the first parameter is a string, this name will be * associated with the address. * - * @param mixed $addresses - * @param string $name optional + * @param string $name optional * * @return $this */ @@ -412,8 +407,7 @@ public function addBcc($address, $name = null) * If $name is passed and the first parameter is a string, this name will be * associated with the address. * - * @param mixed $addresses - * @param string $name optional + * @param string $name optional * * @return $this */ @@ -485,7 +479,7 @@ public function getPriority() { list($priority) = sscanf($this->getHeaderFieldModel('X-Priority'), '%[1-5]' - ); + ); return $priority ?? 3; } @@ -616,7 +610,7 @@ protected function becomeMimePart() { $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(), $this->getCache(), $this->getIdGenerator(), $this->userCharset - ); + ); $part->setContentType($this->userContentType); $part->setBody($this->getBody()); $part->setFormat($this->userFormat); diff --git a/lib/classes/Swift/Mime/SimpleMimeEntity.php b/lib/classes/Swift/Mime/SimpleMimeEntity.php index 03eaf472d..454b83c99 100644 --- a/lib/classes/Swift/Mime/SimpleMimeEntity.php +++ b/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -16,16 +16,16 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver { /** Main message document; there can only be one of these */ - const LEVEL_TOP = 16; + public const LEVEL_TOP = 16; /** An entity which nests with the same precedence as an attachment */ - const LEVEL_MIXED = 256; + public const LEVEL_MIXED = 256; /** An entity which nests with the same precedence as a mime part */ - const LEVEL_ALTERNATIVE = 4096; + public const LEVEL_ALTERNATIVE = 4096; /** An entity which nests with the same precedence as embedded content */ - const LEVEL_RELATED = 65536; + public const LEVEL_RELATED = 65536; /** A collection of Headers for this mime entity */ private $headers; @@ -306,7 +306,7 @@ public function setChildren(array $children, $compoundLevel = null) foreach ($children as $child) { $level = $this->getNeededChildLevel($child, $compoundLevel); if (empty($immediateChildren)) { - //first iteration + // first iteration $immediateChildren = [$child]; } else { $nextLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); @@ -368,7 +368,6 @@ public function getBody() * Set the body of this entity, either as a string, or as an instance of * {@link Swift_OutputByteStream}. * - * @param mixed $body * @param string $contentType optional * * @return $this @@ -434,9 +433,9 @@ public function getBoundary() * * @param string $boundary * - * @throws Swift_RfcComplianceException - * * @return $this + * + * @throws Swift_RfcComplianceException */ public function setBoundary($boundary) { @@ -637,7 +636,7 @@ protected function fixHeaders() if (\count($this->immediateChildren)) { $this->setHeaderParameter('Content-Type', 'boundary', $this->getBoundary() - ); + ); $this->headers->remove('Content-Transfer-Encoding'); } else { $this->setHeaderParameter('Content-Type', 'boundary', null); diff --git a/lib/classes/Swift/MimePart.php b/lib/classes/Swift/MimePart.php index 865b0ea6a..ed897f1c5 100644 --- a/lib/classes/Swift/MimePart.php +++ b/lib/classes/Swift/MimePart.php @@ -30,7 +30,7 @@ public function __construct($body = null, $contentType = null, $charset = null) 'Swift_Mime_MimePart::__construct', Swift_DependencyContainer::getInstance() ->createDependenciesFor('mime.part') - ); + ); if (!isset($charset)) { $charset = Swift_DependencyContainer::getInstance() diff --git a/lib/classes/Swift/OutputByteStream.php b/lib/classes/Swift/OutputByteStream.php index 1f26f9be5..60608f1e1 100644 --- a/lib/classes/Swift/OutputByteStream.php +++ b/lib/classes/Swift/OutputByteStream.php @@ -27,9 +27,9 @@ interface Swift_OutputByteStream * * @param int $length * - * @throws Swift_IoException - * * @return string|bool + * + * @throws Swift_IoException */ public function read($length); @@ -38,9 +38,9 @@ public function read($length); * * @param int $byteOffset * - * @throws Swift_IoException - * * @return bool + * + * @throws Swift_IoException */ public function setReadPointer($byteOffset); } diff --git a/lib/classes/Swift/Plugins/AntiFloodPlugin.php b/lib/classes/Swift/Plugins/AntiFloodPlugin.php index 5b1d7deef..a9e75e88b 100644 --- a/lib/classes/Swift/Plugins/AntiFloodPlugin.php +++ b/lib/classes/Swift/Plugins/AntiFloodPlugin.php @@ -50,7 +50,7 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_ * @param int $sleep time * @param Swift_Plugins_Sleeper $sleeper (not needed really) */ - public function __construct($threshold = 99, $sleep = 0, Swift_Plugins_Sleeper $sleeper = null) + public function __construct($threshold = 99, $sleep = 0, ?Swift_Plugins_Sleeper $sleeper = null) { $this->setThreshold($threshold); $this->setSleepTime($sleep); diff --git a/lib/classes/Swift/Plugins/DecoratorPlugin.php b/lib/classes/Swift/Plugins/DecoratorPlugin.php index 93124c9a5..266c3915c 100644 --- a/lib/classes/Swift/Plugins/DecoratorPlugin.php +++ b/lib/classes/Swift/Plugins/DecoratorPlugin.php @@ -87,7 +87,7 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) $replace = array_values($replacements); $bodyReplaced = str_replace( $search, $replace, $body - ); + ); if ($body != $bodyReplaced) { $this->originalBody = $body; $message->setBody($bodyReplaced); @@ -126,7 +126,7 @@ public function beforeSendPerformed(Swift_Events_SendEvent $evt) $body = $child->getBody(); $bodyReplaced = str_replace( $search, $replace, $body - ); + ); if ($body != $bodyReplaced) { $child->setBody($bodyReplaced); $this->originalChildBodies[$child->getId()] = $body; diff --git a/lib/classes/Swift/Plugins/RedirectingPlugin.php b/lib/classes/Swift/Plugins/RedirectingPlugin.php index f7373b242..cb0f323e5 100644 --- a/lib/classes/Swift/Plugins/RedirectingPlugin.php +++ b/lib/classes/Swift/Plugins/RedirectingPlugin.php @@ -17,8 +17,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener { /** * The recipient who will receive all messages. - * - * @var mixed */ private $recipient; @@ -31,8 +29,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener /** * Create a new RedirectingPlugin. - * - * @param mixed $recipient */ public function __construct($recipient, array $whitelist = []) { @@ -42,8 +38,6 @@ public function __construct($recipient, array $whitelist = []) /** * Set the recipient of all messages. - * - * @param mixed $recipient */ public function setRecipient($recipient) { @@ -52,8 +46,6 @@ public function setRecipient($recipient) /** * Get the recipient of all messages. - * - * @return mixed */ public function getRecipient() { diff --git a/lib/classes/Swift/Plugins/Reporter.php b/lib/classes/Swift/Plugins/Reporter.php index b88183397..388e3cf13 100644 --- a/lib/classes/Swift/Plugins/Reporter.php +++ b/lib/classes/Swift/Plugins/Reporter.php @@ -16,10 +16,10 @@ interface Swift_Plugins_Reporter { /** The recipient was accepted for delivery */ - const RESULT_PASS = 0x01; + public const RESULT_PASS = 0x01; /** The recipient could not be accepted */ - const RESULT_FAIL = 0x10; + public const RESULT_FAIL = 0x10; /** * Notifies this ReportNotifier that $address failed or succeeded. diff --git a/lib/classes/Swift/Plugins/ReporterPlugin.php b/lib/classes/Swift/Plugins/ReporterPlugin.php index c4a016520..1442ffbc2 100644 --- a/lib/classes/Swift/Plugins/ReporterPlugin.php +++ b/lib/classes/Swift/Plugins/ReporterPlugin.php @@ -45,13 +45,13 @@ public function sendPerformed(Swift_Events_SendEvent $evt) $message = $evt->getMessage(); $failures = array_flip($evt->getFailedRecipients()); foreach ((array) $message->getTo() as $address => $null) { - $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + $this->reporter->notify($message, $address, \array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS); } foreach ((array) $message->getCc() as $address => $null) { - $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + $this->reporter->notify($message, $address, \array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS); } foreach ((array) $message->getBcc() as $address => $null) { - $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + $this->reporter->notify($message, $address, \array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS); } } } diff --git a/lib/classes/Swift/Plugins/ThrottlerPlugin.php b/lib/classes/Swift/Plugins/ThrottlerPlugin.php index 83d304492..655eb26db 100644 --- a/lib/classes/Swift/Plugins/ThrottlerPlugin.php +++ b/lib/classes/Swift/Plugins/ThrottlerPlugin.php @@ -16,13 +16,13 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin implements Swift_Plugins_Sleeper, Swift_Plugins_Timer { /** Flag for throttling in bytes per minute */ - const BYTES_PER_MINUTE = 0x01; + public const BYTES_PER_MINUTE = 0x01; /** Flag for throttling in emails per second (Amazon SES) */ - const MESSAGES_PER_SECOND = 0x11; + public const MESSAGES_PER_SECOND = 0x11; /** Flag for throttling in emails per minute */ - const MESSAGES_PER_MINUTE = 0x10; + public const MESSAGES_PER_MINUTE = 0x10; /** * The Sleeper instance for sleeping. @@ -76,7 +76,7 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin * @param Swift_Plugins_Sleeper $sleeper (only needed in testing) * @param Swift_Plugins_Timer $timer (only needed in testing) */ - public function __construct($rate, $mode = self::BYTES_PER_MINUTE, Swift_Plugins_Sleeper $sleeper = null, Swift_Plugins_Timer $timer = null) + public function __construct($rate, $mode = self::BYTES_PER_MINUTE, ?Swift_Plugins_Sleeper $sleeper = null, ?Swift_Plugins_Timer $timer = null) { $this->rate = $rate; $this->mode = $mode; diff --git a/lib/classes/Swift/Preferences.php b/lib/classes/Swift/Preferences.php index 16103e110..48e290246 100644 --- a/lib/classes/Swift/Preferences.php +++ b/lib/classes/Swift/Preferences.php @@ -16,7 +16,7 @@ class Swift_Preferences { /** Singleton instance */ - private static $instance = null; + private static $instance; /** Constructor not to be used */ private function __construct() diff --git a/lib/classes/Swift/ReplacementFilterFactory.php b/lib/classes/Swift/ReplacementFilterFactory.php index 2897474e7..77ab67f8f 100644 --- a/lib/classes/Swift/ReplacementFilterFactory.php +++ b/lib/classes/Swift/ReplacementFilterFactory.php @@ -18,9 +18,6 @@ interface Swift_ReplacementFilterFactory /** * Create a filter to replace $search with $replace. * - * @param mixed $search - * @param mixed $replace - * * @return Swift_StreamFilter */ public function createFilter($search, $replace); diff --git a/lib/classes/Swift/SendmailTransport.php b/lib/classes/Swift/SendmailTransport.php index bb1559fc2..33daeaa0f 100644 --- a/lib/classes/Swift/SendmailTransport.php +++ b/lib/classes/Swift/SendmailTransport.php @@ -26,7 +26,7 @@ public function __construct($command = '/usr/sbin/sendmail -bs') 'Swift_Transport_SendmailTransport::__construct', Swift_DependencyContainer::getInstance() ->createDependenciesFor('transport.sendmail') - ); + ); $this->setCommand($command); } diff --git a/lib/classes/Swift/Signers/DKIMSigner.php b/lib/classes/Swift/Signers/DKIMSigner.php index ec82dc056..df88b1a86 100644 --- a/lib/classes/Swift/Signers/DKIMSigner.php +++ b/lib/classes/Swift/Signers/DKIMSigner.php @@ -98,8 +98,6 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner /** * When the signature has been applied (true means time()), false means not embedded. - * - * @var mixed */ protected $signatureTimestamp = true; @@ -159,7 +157,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner private $bodyCanonSpace = false; - private $bodyCanonLastChar = null; + private $bodyCanonLastChar; private $bodyCanonLine = ''; @@ -283,9 +281,9 @@ public function flushBuffers() * * @param string $hash 'rsa-sha1' or 'rsa-sha256' * - * @throws Swift_SwiftException - * * @return $this + * + * @throws Swift_SwiftException */ public function setHashAlgorithm($hash) { @@ -655,9 +653,9 @@ private function addToHeaderHash($header) } /** - * @throws Swift_SwiftException - * * @return string + * + * @throws Swift_SwiftException */ private function getEncryptedHash() { diff --git a/lib/classes/Swift/Signers/DomainKeySigner.php b/lib/classes/Swift/Signers/DomainKeySigner.php index 5e2b67b65..61f3db7d3 100644 --- a/lib/classes/Swift/Signers/DomainKeySigner.php +++ b/lib/classes/Swift/Signers/DomainKeySigner.php @@ -101,7 +101,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner private $bodyCanonSpace = false; - private $bodyCanonLastChar = null; + private $bodyCanonLastChar; private $bodyCanonLine = ''; @@ -151,10 +151,9 @@ public function reset() * @param string $bytes * * @return int + * @return $this * * @throws Swift_IoException - * - * @return $this */ public function write($bytes) { @@ -170,9 +169,9 @@ public function write($bytes) * For any bytes that are currently buffered inside the stream, force them * off the buffer. * - * @throws Swift_IoException - * * @return $this + * + * @throws Swift_IoException */ public function commit() { @@ -223,9 +222,9 @@ public function unbind(Swift_InputByteStream $is) * Flush the contents of the stream (empty it) and set the internal pointer * to the beginning. * - * @throws Swift_IoException - * * @return $this + * + * @throws Swift_IoException */ public function flushBuffers() { @@ -442,7 +441,7 @@ protected function canonicalizeBody($string) break; case ' ': case "\t": - case "\x09": //HTAB + case "\x09": // HTAB if ($nofws) { $this->bodyCanonSpace = true; break; @@ -485,9 +484,9 @@ private function startHash() } /** - * @throws Swift_SwiftException - * * @return string + * + * @throws Swift_SwiftException */ private function getEncryptedHash() { diff --git a/lib/classes/Swift/Signers/OpenDKIMSigner.php b/lib/classes/Swift/Signers/OpenDKIMSigner.php index 520bcc15e..c442507b0 100644 --- a/lib/classes/Swift/Signers/OpenDKIMSigner.php +++ b/lib/classes/Swift/Signers/OpenDKIMSigner.php @@ -20,14 +20,14 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { private $peclLoaded = false; - private $dkimHandler = null; + private $dkimHandler; private $dropFirstLF = true; - const CANON_RELAXED = 1; - const CANON_SIMPLE = 2; - const SIG_RSA_SHA1 = 3; - const SIG_RSA_SHA256 = 4; + public const CANON_RELAXED = 1; + public const CANON_SIMPLE = 2; + public const SIG_RSA_SHA1 = 3; + public const SIG_RSA_SHA256 = 4; public function __construct($privateKey, $domainName, $selector) { diff --git a/lib/classes/Swift/Signers/SMimeSigner.php b/lib/classes/Swift/Signers/SMimeSigner.php index 3dd3cd05f..5a99cf673 100644 --- a/lib/classes/Swift/Signers/SMimeSigner.php +++ b/lib/classes/Swift/Signers/SMimeSigner.php @@ -26,7 +26,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner protected $signOptions; protected $encryptOptions; protected $encryptCipher; - protected $extraCerts = null; + protected $extraCerts; protected $wrapFullMessage = false; /** @@ -266,14 +266,14 @@ protected function smimeSignMessage(Swift_Message $message) // Sign the message using openssl if (!openssl_pkcs7_sign( - $messageStream->getPath(), - $signedMessageStream->getPath(), - $this->signCertificate, - $this->signPrivateKey, - [], - $this->signOptions, - $this->extraCerts - ) + $messageStream->getPath(), + $signedMessageStream->getPath(), + $this->signCertificate, + $this->signPrivateKey, + [], + $this->signOptions, + $this->extraCerts + ) ) { throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); } @@ -324,13 +324,13 @@ protected function smimeEncryptMessage(Swift_Message $message) // Encrypt the message if (!openssl_pkcs7_encrypt( - $messageStream->getPath(), - $encryptedMessageStream->getPath(), - $this->encryptCert, - [], - 0, - $this->encryptCipher - ) + $messageStream->getPath(), + $encryptedMessageStream->getPath(), + $this->encryptCert, + [], + 0, + $this->encryptCipher + ) ) { throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string())); } diff --git a/lib/classes/Swift/SmtpTransport.php b/lib/classes/Swift/SmtpTransport.php index 9a5846ceb..3b2d17054 100644 --- a/lib/classes/Swift/SmtpTransport.php +++ b/lib/classes/Swift/SmtpTransport.php @@ -23,12 +23,12 @@ class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport { /** - * @param string $host - * @param int $port + * @param string $host + * @param int $port * @param string|null $encryption SMTP encryption mode: - * - null for plain SMTP (no encryption), - * - 'tls' for SMTP with STARTTLS (best effort encryption), - * - 'ssl' for SMTPS = SMTP over TLS (always encrypted). + * - null for plain SMTP (no encryption), + * - 'tls' for SMTP with STARTTLS (best effort encryption), + * - 'ssl' for SMTPS = SMTP over TLS (always encrypted) */ public function __construct($host = 'localhost', $port = 25, $encryption = null) { diff --git a/lib/classes/Swift/StreamFilter.php b/lib/classes/Swift/StreamFilter.php index 362be2e8d..ded1874ef 100644 --- a/lib/classes/Swift/StreamFilter.php +++ b/lib/classes/Swift/StreamFilter.php @@ -18,18 +18,12 @@ interface Swift_StreamFilter /** * Based on the buffer given, this returns true if more buffering is needed. * - * @param mixed $buffer - * * @return bool */ public function shouldBuffer($buffer); /** * Filters $buffer and returns the changes. - * - * @param mixed $buffer - * - * @return mixed */ public function filter($buffer); } diff --git a/lib/classes/Swift/SwiftException.php b/lib/classes/Swift/SwiftException.php index 15e68b18e..a453af79e 100644 --- a/lib/classes/Swift/SwiftException.php +++ b/lib/classes/Swift/SwiftException.php @@ -21,7 +21,7 @@ class Swift_SwiftException extends Exception * @param string $message * @param int $code */ - public function __construct($message, $code = 0, Exception $previous = null) + public function __construct($message, $code = 0, ?Exception $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/lib/classes/Swift/Transport/AbstractSmtpTransport.php b/lib/classes/Swift/Transport/AbstractSmtpTransport.php index d2dbd7a66..9f600dacb 100644 --- a/lib/classes/Swift/Transport/AbstractSmtpTransport.php +++ b/lib/classes/Swift/Transport/AbstractSmtpTransport.php @@ -30,7 +30,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport protected $addressEncoder; /** Whether the PIPELINING SMTP extension is enabled (RFC 2920) */ - protected $pipelining = null; + protected $pipelining; /** The pipelined commands waiting for response */ protected $pipeline = []; @@ -46,7 +46,7 @@ abstract protected function getBufferParams(); * * @param string $localDomain */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', ?Swift_AddressEncoder $addressEncoder = null) { $this->buffer = $buf; $this->eventDispatcher = $dispatcher; @@ -220,7 +220,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); } - $message->generateId(); //Make sure a new Message ID is used + $message->generateId(); // Make sure a new Message ID is used return $sent; } @@ -256,9 +256,6 @@ public function stop() $this->started = false; } - /** - * {@inheritdoc} - */ public function ping() { try { @@ -365,7 +362,7 @@ protected function doHeloCommand() { $this->executeCommand( sprintf("HELO %s\r\n", $this->domain), [250] - ); + ); } /** Send the MAIL FROM command */ @@ -374,7 +371,7 @@ protected function doMailFromCommand($address) $address = $this->addressEncoder->encodeString($address); $this->executeCommand( sprintf("MAIL FROM:<%s>\r\n", $address), [250], $failures, true - ); + ); } /** Send the RCPT TO command */ @@ -383,7 +380,7 @@ protected function doRcptToCommand($address) $address = $this->addressEncoder->encodeString($address); $this->executeCommand( sprintf("RCPT TO:<%s>\r\n", $address), [250, 251, 252], $failures, true, $address - ); + ); } /** Send the DATA command */ @@ -531,11 +528,11 @@ public function __destruct() public function __sleep() { - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + throw new BadMethodCallException('Cannot serialize '.__CLASS__); } public function __wakeup() { - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + throw new BadMethodCallException('Cannot unserialize '.__CLASS__); } } diff --git a/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php index bb3a16150..3ef184db1 100644 --- a/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php +++ b/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php @@ -25,9 +25,6 @@ public function getAuthKeyword() return 'CRAM-MD5'; } - /** - * {@inheritdoc} - */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { try { diff --git a/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php b/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php index 0b9d81b8a..c56920fb6 100644 --- a/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php +++ b/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php @@ -25,9 +25,6 @@ public function getAuthKeyword() return 'LOGIN'; } - /** - * {@inheritdoc} - */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { try { diff --git a/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php b/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php index 41931fdd2..ec4ed83b7 100644 --- a/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php +++ b/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php @@ -17,8 +17,8 @@ */ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Esmtp_Authenticator { - const NTLMSIG = "NTLMSSP\x00"; - const DESCONST = 'KGS!@#$%'; + public const NTLMSIG = "NTLMSSP\x00"; + public const DESCONST = 'KGS!@#$%'; /** * Get the name of the AUTH mechanism this Authenticator handles. @@ -31,9 +31,7 @@ public function getAuthKeyword() } /** - * {@inheritdoc} - * - * @throws \LogicException + * @throws LogicException */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { @@ -182,7 +180,7 @@ protected function readSubBlock($block) protected function sendMessage3($response, $username, $password, $timestamp, $client, Swift_Transport_SmtpAgent $agent, $v2 = true) { list($domain, $username) = $this->getDomainAndUsername($username); - //$challenge, $context, $targetInfoH, $targetName, $domainName, $workstation, $DNSDomainName, $DNSServerName, $blob, $ter + // $challenge, $context, $targetInfoH, $targetName, $domainName, $workstation, $DNSDomainName, $DNSServerName, $blob, $ter list($challenge, , , , , $workstation, , , $blob) = $this->parseMessage2($response); if (!$v2) { @@ -429,7 +427,7 @@ protected function createDesKey($key) $len = \strlen($key); for ($i = 1; $i < $len; ++$i) { list($high, $low) = str_split(bin2hex($key[$i])); - $v = $this->castToByte(\ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i)); + $v = $this->castToByte(\ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xF).dechex(hexdec($low) & 0xF)), $i)); $material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte } $material[] = str_pad(substr(dechex($this->castToByte(\ord($key[6]) << 1)), -2), 2, '0'); @@ -445,7 +443,7 @@ protected function createDesKey($key) if ($needsParity) { $material[$k] = dechex(hexdec($high) | 0x0).dechex(hexdec($low) | 0x1); } else { - $material[$k] = dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xe); + $material[$k] = dechex(hexdec($high) & 0xF).dechex(hexdec($low) & 0xE); } } diff --git a/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php b/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php index 41d0a50a8..96515829b 100644 --- a/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php +++ b/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php @@ -25,9 +25,6 @@ public function getAuthKeyword() return 'PLAIN'; } - /** - * {@inheritdoc} - */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { try { diff --git a/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php b/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php index 859f22f3d..33c04969f 100644 --- a/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php +++ b/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php @@ -35,9 +35,6 @@ public function getAuthKeyword() return 'XOAUTH2'; } - /** - * {@inheritdoc} - */ public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) { try { diff --git a/lib/classes/Swift/Transport/EsmtpTransport.php b/lib/classes/Swift/Transport/EsmtpTransport.php index 36545f51f..c695a9c60 100644 --- a/lib/classes/Swift/Transport/EsmtpTransport.php +++ b/lib/classes/Swift/Transport/EsmtpTransport.php @@ -51,7 +51,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo * @param Swift_Transport_EsmtpHandler[] $extensionHandlers * @param string $localDomain */ - public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) + public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', ?Swift_AddressEncoder $addressEncoder = null) { parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); $this->setExtensionHandlers($extensionHandlers); @@ -296,7 +296,7 @@ public function executeCommand($command, $codes = [], &$failures = null, $pipeli foreach ($this->getActiveHandlers() as $handler) { $response = $handler->onCommand( $this, $command, $codes, $failures, $stopSignal - ); + ); if ($stopSignal) { return $response; } @@ -311,7 +311,7 @@ public function __call($method, $args) foreach ($this->handlers as $handler) { if (\in_array(strtolower($method), array_map('strtolower', (array) $handler->exposeMixinMethods()) - )) { + )) { $return = \call_user_func_array([$handler, $method], $args); // Allow fluid method calls if (null === $return && 'set' == substr($method, 0, 3)) { @@ -336,7 +336,7 @@ protected function doHeloCommand() try { $response = $this->executeCommand( sprintf("EHLO %s\r\n", $this->domain), [250] - ); + ); } catch (Swift_TransportException $e) { return parent::doHeloCommand(); } @@ -352,7 +352,7 @@ protected function doHeloCommand() try { $response = $this->executeCommand( sprintf("EHLO %s\r\n", $this->domain), [250] - ); + ); } catch (Swift_TransportException $e) { return parent::doHeloCommand(); } @@ -384,7 +384,7 @@ protected function doMailFromCommand($address) $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; $this->executeCommand( sprintf("MAIL FROM:<%s>%s\r\n", $address, $paramStr), [250], $failures, true - ); + ); } /** Overridden to add Extension support */ @@ -399,7 +399,7 @@ protected function doRcptToCommand($address) $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; $this->executeCommand( sprintf("RCPT TO:<%s>%s\r\n", $address, $paramStr), [250, 251, 252], $failures, true, $address - ); + ); } /** Determine ESMTP capabilities by function group */ diff --git a/lib/classes/Swift/Transport/FailoverTransport.php b/lib/classes/Swift/Transport/FailoverTransport.php index 1a4b4754f..e69e4db0f 100644 --- a/lib/classes/Swift/Transport/FailoverTransport.php +++ b/lib/classes/Swift/Transport/FailoverTransport.php @@ -28,9 +28,6 @@ public function __construct() parent::__construct(); } - /** - * {@inheritdoc} - */ public function ping() { $maxTransports = \count($this->transports); diff --git a/lib/classes/Swift/Transport/IoBuffer.php b/lib/classes/Swift/Transport/IoBuffer.php index 50f1e5e40..90e2f7720 100644 --- a/lib/classes/Swift/Transport/IoBuffer.php +++ b/lib/classes/Swift/Transport/IoBuffer.php @@ -16,10 +16,10 @@ interface Swift_Transport_IoBuffer extends Swift_InputByteStream, Swift_OutputByteStream { /** A socket buffer over TCP */ - const TYPE_SOCKET = 0x0001; + public const TYPE_SOCKET = 0x0001; /** A process buffer with I/O support */ - const TYPE_PROCESS = 0x0010; + public const TYPE_PROCESS = 0x0010; /** * Perform any initialization needed, using the given $params. @@ -32,7 +32,6 @@ public function initialize(array $params); * Set an individual param on the buffer (e.g. switching to SSL). * * @param string $param - * @param mixed $value */ public function setParam($param, $value); diff --git a/lib/classes/Swift/Transport/LoadBalancedTransport.php b/lib/classes/Swift/Transport/LoadBalancedTransport.php index 0b5ba9d30..c1f766171 100644 --- a/lib/classes/Swift/Transport/LoadBalancedTransport.php +++ b/lib/classes/Swift/Transport/LoadBalancedTransport.php @@ -34,7 +34,7 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport * * @var Swift_Transport */ - protected $lastUsedTransport = null; + protected $lastUsedTransport; // needed as __construct is called from elsewhere explicitly public function __construct() @@ -100,9 +100,6 @@ public function stop() } } - /** - * {@inheritdoc} - */ public function ping() { foreach ($this->transports as $transport) { diff --git a/lib/classes/Swift/Transport/NullTransport.php b/lib/classes/Swift/Transport/NullTransport.php index 7d910db5a..612ec5fd5 100644 --- a/lib/classes/Swift/Transport/NullTransport.php +++ b/lib/classes/Swift/Transport/NullTransport.php @@ -50,9 +50,6 @@ public function stop() { } - /** - * {@inheritdoc} - */ public function ping() { return true; @@ -83,7 +80,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul \count((array) $message->getTo()) + \count((array) $message->getCc()) + \count((array) $message->getBcc()) - ); + ); return $count; } diff --git a/lib/classes/Swift/Transport/SendmailTransport.php b/lib/classes/Swift/Transport/SendmailTransport.php index 65a434d11..07a4dedd5 100644 --- a/lib/classes/Swift/Transport/SendmailTransport.php +++ b/lib/classes/Swift/Transport/SendmailTransport.php @@ -36,7 +36,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran * * @param string $localDomain */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', ?Swift_AddressEncoder $addressEncoder = null) { parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); } @@ -125,7 +125,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul $count = \count((array) $message->getTo()) + \count((array) $message->getCc()) + \count((array) $message->getBcc()) - ; + ; $message->toByteStream($buffer); $buffer->flushBuffers(); $buffer->setWriteTranslations([]); @@ -144,7 +144,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul $this->throwException(new Swift_TransportException( 'Unsupported sendmail command flags ['.$command.']. '. 'Must be one of "-bs" or "-t" but can include additional flags.' - )); + )); } return $count; diff --git a/lib/classes/Swift/Transport/SpoolTransport.php b/lib/classes/Swift/Transport/SpoolTransport.php index 0cb6a5b80..db9e9766d 100644 --- a/lib/classes/Swift/Transport/SpoolTransport.php +++ b/lib/classes/Swift/Transport/SpoolTransport.php @@ -24,7 +24,7 @@ class Swift_Transport_SpoolTransport implements Swift_Transport /** * Constructor. */ - public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift_Spool $spool = null) + public function __construct(Swift_Events_EventDispatcher $eventDispatcher, ?Swift_Spool $spool = null) { $this->eventDispatcher = $eventDispatcher; $this->spool = $spool; @@ -76,9 +76,6 @@ public function stop() { } - /** - * {@inheritdoc} - */ public function ping() { return true; diff --git a/lib/classes/Swift/Transport/StreamBuffer.php b/lib/classes/Swift/Transport/StreamBuffer.php index 70782ada0..7c39d96a0 100644 --- a/lib/classes/Swift/Transport/StreamBuffer.php +++ b/lib/classes/Swift/Transport/StreamBuffer.php @@ -64,7 +64,6 @@ public function initialize(array $params) * Set an individual param on the buffer (e.g. switching to SSL). * * @param string $param - * @param mixed $value */ public function setParam($param, $value) { @@ -138,7 +137,7 @@ public function setWriteTranslations(array $replacements) if (!isset($this->translations[$search])) { $this->addFilter( $this->replacementFactory->createFilter($search, $replace), $search - ); + ); $this->translations[$search] = true; } } diff --git a/lib/classes/Swift/TransportException.php b/lib/classes/Swift/TransportException.php index c7417455b..753fce8cf 100644 --- a/lib/classes/Swift/TransportException.php +++ b/lib/classes/Swift/TransportException.php @@ -21,7 +21,7 @@ class Swift_TransportException extends Swift_IoException * @param string $message * @param int $code */ - public function __construct($message, $code = 0, Exception $previous = null) + public function __construct($message, $code = 0, ?Exception $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/lib/preferences.php b/lib/preferences.php index 27b7065db..e755e1952 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -1,10 +1,6 @@ markTestSkipped( 'Smoke tests are skipped if tests/smoke.conf.php is not edited' - ); + ); } } @@ -26,12 +26,12 @@ protected function getMailer() ->setUsername(SWIFT_SMOKE_SMTP_USER) ->setPassword(SWIFT_SMOKE_SMTP_PASS) ->setEncryption(SWIFT_SMOKE_SMTP_ENCRYPTION) - ; + ; break; case 'sendmail': $transport = Swift_DependencyContainer::getInstance()->lookup('transport.sendmail') ->setCommand(SWIFT_SMOKE_SENDMAIL_COMMAND) - ; + ; break; case 'mail': case 'nativemail': diff --git a/tests/SwiftMailerTestCase.php b/tests/SwiftMailerTestCase.php index 4fd96e030..33e09d2f0 100644 --- a/tests/SwiftMailerTestCase.php +++ b/tests/SwiftMailerTestCase.php @@ -7,7 +7,7 @@ * * @author Rouven Weßling */ -class SwiftMailerTestCase extends \PHPUnit\Framework\TestCase +class SwiftMailerTestCase extends PHPUnit\Framework\TestCase { use MockeryPHPUnitIntegration; @@ -17,7 +17,7 @@ public static function regExp($pattern) throw PHPUnit\Util\InvalidArgumentHelper::factory(1, 'string'); } - return new \PHPUnit\Framework\Constraint\RegularExpression($pattern); + return new PHPUnit\Framework\Constraint\RegularExpression($pattern); } public function assertIdenticalBinary($expected, $actual, $message = '') @@ -28,6 +28,6 @@ public function assertIdenticalBinary($expected, $actual, $message = '') protected function getMockery($class) { - return \Mockery::mock($class); + return Mockery::mock($class); } } diff --git a/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php b/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php index a0433153f..f1b2d4f9f 100644 --- a/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php +++ b/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php @@ -1,6 +1,6 @@ createFileStream( $this->testFile, true - ); + ); $is1 = $this->createMockInputStream(); $is2 = $this->createMockInputStream(); diff --git a/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php b/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php index fcc7ad4d0..13b472817 100644 --- a/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php +++ b/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php @@ -1,6 +1,6 @@ cache = new Swift_KeyCache_ArrayKeyCache( new Swift_KeyCache_SimpleKeyCacheInputStream() - ); + ); } public function testStringDataCanBeSetAndFetched() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('test', $this->cache->getString($this->key1, 'foo')); } @@ -25,10 +25,10 @@ public function testStringDataCanBeOverwritten() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('whatever', $this->cache->getString($this->key1, 'foo')); } @@ -36,10 +36,10 @@ public function testStringDataCanBeAppended() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND - ); + ); $this->assertEquals('testing', $this->cache->getString($this->key1, 'foo')); } @@ -48,7 +48,7 @@ public function testHasKeyReturnValue() $this->assertFalse($this->cache->hasKey($this->key1, 'foo')); $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertTrue($this->cache->hasKey($this->key1, 'foo')); } @@ -56,10 +56,10 @@ public function testNsKeyIsWellPartitioned() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('test', $this->cache->getString($this->key1, 'foo')); $this->assertEquals('ing', $this->cache->getString($this->key2, 'foo')); } @@ -68,10 +68,10 @@ public function testItemKeyIsWellPartitioned() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('test', $this->cache->getString($this->key1, 'foo')); $this->assertEquals('ing', $this->cache->getString($this->key1, 'bar')); } @@ -83,7 +83,7 @@ public function testByteStreamCanBeImported() $this->cache->importFromByteStream( $this->key1, 'foo', $os, Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('abcdef', $this->cache->getString($this->key1, 'foo')); } @@ -97,10 +97,10 @@ public function testByteStreamCanBeAppended() $this->cache->importFromByteStream( $this->key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND - ); + ); $this->cache->importFromByteStream( $this->key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND - ); + ); $this->assertEquals('abcdefxyzuvw', $this->cache->getString($this->key1, 'foo')); } @@ -109,14 +109,14 @@ public function testByteStreamAndStringCanBeAppended() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND - ); + ); $os = new Swift_ByteStream_ArrayByteStream(); $os->write('abcdef'); $this->cache->importFromByteStream( $this->key1, 'foo', $os, Swift_KeyCache::MODE_APPEND - ); + ); $this->assertEquals('testabcdef', $this->cache->getString($this->key1, 'foo')); } @@ -124,7 +124,7 @@ public function testDataCanBeExportedToByteStream() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $is = new Swift_ByteStream_ArrayByteStream(); @@ -142,7 +142,7 @@ public function testKeyCanBeCleared() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertTrue($this->cache->hasKey($this->key1, 'foo')); $this->cache->clearKey($this->key1, 'foo'); $this->assertFalse($this->cache->hasKey($this->key1, 'foo')); @@ -152,10 +152,10 @@ public function testNsKeyCanBeCleared() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertTrue($this->cache->hasKey($this->key1, 'foo')); $this->assertTrue($this->cache->hasKey($this->key1, 'bar')); $this->cache->clearAll($this->key1); diff --git a/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php b/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php index 976474235..b7e8b07a0 100644 --- a/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php +++ b/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php @@ -1,6 +1,6 @@ cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('test', $this->cache->getString($this->key1, 'foo')); } @@ -25,10 +25,10 @@ public function testStringDataCanBeOverwritten() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('whatever', $this->cache->getString($this->key1, 'foo')); } @@ -36,10 +36,10 @@ public function testStringDataCanBeAppended() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND - ); + ); $this->assertEquals('testing', $this->cache->getString($this->key1, 'foo')); } @@ -48,7 +48,7 @@ public function testHasKeyReturnValue() $this->assertFalse($this->cache->hasKey($this->key1, 'foo')); $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertTrue($this->cache->hasKey($this->key1, 'foo')); } @@ -56,10 +56,10 @@ public function testNsKeyIsWellPartitioned() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('test', $this->cache->getString($this->key1, 'foo')); $this->assertEquals('ing', $this->cache->getString($this->key2, 'foo')); } @@ -68,10 +68,10 @@ public function testItemKeyIsWellPartitioned() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('test', $this->cache->getString($this->key1, 'foo')); $this->assertEquals('ing', $this->cache->getString($this->key1, 'bar')); } @@ -83,7 +83,7 @@ public function testByteStreamCanBeImported() $this->cache->importFromByteStream( $this->key1, 'foo', $os, Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('abcdef', $this->cache->getString($this->key1, 'foo')); } @@ -97,10 +97,10 @@ public function testByteStreamCanBeAppended() $this->cache->importFromByteStream( $this->key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND - ); + ); $this->cache->importFromByteStream( $this->key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND - ); + ); $this->assertEquals('abcdefxyzuvw', $this->cache->getString($this->key1, 'foo')); } @@ -109,14 +109,14 @@ public function testByteStreamAndStringCanBeAppended() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND - ); + ); $os = new Swift_ByteStream_ArrayByteStream(); $os->write('abcdef'); $this->cache->importFromByteStream( $this->key1, 'foo', $os, Swift_KeyCache::MODE_APPEND - ); + ); $this->assertEquals('testabcdef', $this->cache->getString($this->key1, 'foo')); } @@ -124,7 +124,7 @@ public function testDataCanBeExportedToByteStream() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $is = new Swift_ByteStream_ArrayByteStream(); @@ -142,7 +142,7 @@ public function testKeyCanBeCleared() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertTrue($this->cache->hasKey($this->key1, 'foo')); $this->cache->clearKey($this->key1, 'foo'); $this->assertFalse($this->cache->hasKey($this->key1, 'foo')); @@ -152,10 +152,10 @@ public function testNsKeyCanBeCleared() { $this->cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->cache->setString( $this->key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertTrue($this->cache->hasKey($this->key1, 'foo')); $this->assertTrue($this->cache->hasKey($this->key1, 'bar')); $this->cache->clearAll($this->key1); diff --git a/tests/acceptance/Swift/MessageAcceptanceTest.php b/tests/acceptance/Swift/MessageAcceptanceTest.php index 16adb23b0..ead68d223 100644 --- a/tests/acceptance/Swift/MessageAcceptanceTest.php +++ b/tests/acceptance/Swift/MessageAcceptanceTest.php @@ -42,7 +42,7 @@ public function testAddPartWrapper() "\r\n\r\n". '--'.$boundary.'--'."\r\n", $message->toString() - ); + ); } protected function createMessage() diff --git a/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php b/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php index 11666b5be..c04e2b449 100644 --- a/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php +++ b/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php @@ -2,7 +2,7 @@ use Egulias\EmailValidator\EmailValidator; -class Swift_Mime_AttachmentAcceptanceTest extends \PHPUnit\Framework\TestCase +class Swift_Mime_AttachmentAcceptanceTest extends PHPUnit\Framework\TestCase { private $contentEncoder; private $cache; @@ -14,21 +14,21 @@ protected function setUp() { $this->cache = new Swift_KeyCache_ArrayKeyCache( new Swift_KeyCache_SimpleKeyCacheInputStream() - ); + ); $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); $this->contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') - ); + ); $paramEncoder = new Swift_Encoder_Rfc2231Encoder( new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') - ); + ); $this->emailValidator = new EmailValidator(); $this->idGenerator = new Swift_Mime_IdGenerator('example.com'); $this->headers = new Swift_Mime_SimpleHeaderSet( new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->emailValidator) - ); + ); } public function testDispositionIsSetInHeader() @@ -41,7 +41,7 @@ public function testDispositionIsSetInHeader() 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: inline'."\r\n", $attachment->toString() - ); + ); } public function testDispositionIsAttachmentByDefault() @@ -53,7 +53,7 @@ public function testDispositionIsAttachmentByDefault() 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: attachment'."\r\n", $attachment->toString() - ); + ); } public function testFilenameIsSetInHeader() @@ -66,7 +66,7 @@ public function testFilenameIsSetInHeader() 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: attachment; filename=foo.pdf'."\r\n", $attachment->toString() - ); + ); } public function testSizeIsSetInHeader() @@ -79,7 +79,7 @@ public function testSizeIsSetInHeader() 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: attachment; size=12340'."\r\n", $attachment->toString() - ); + ); } public function testMultipleParametersInHeader() @@ -93,7 +93,7 @@ public function testMultipleParametersInHeader() 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Disposition: attachment; filename=foo.pdf; size=12340'."\r\n", $attachment->toString() - ); + ); } public function testEndToEnd() @@ -110,7 +110,7 @@ public function testEndToEnd() "\r\n". base64_encode('abcd'), $attachment->toString() - ); + ); } protected function createAttachment() @@ -120,7 +120,7 @@ protected function createAttachment() $this->contentEncoder, $this->cache, $this->idGenerator - ); + ); return $entity; } diff --git a/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php b/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php index a87b30ee6..13a76ad7b 100644 --- a/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php +++ b/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php @@ -1,6 +1,6 @@ expectException(\RuntimeException::class); + $this->expectException(RuntimeException::class); $this->encoder->charsetChanged('utf-8'); $this->encoder->charsetChanged('charset'); @@ -82,6 +82,6 @@ private function createEncoderFromContainer() { return Swift_DependencyContainer::getInstance() ->lookup('mime.nativeqpcontentencoder') - ; + ; } } diff --git a/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php b/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php index 544873a92..fde2b2542 100644 --- a/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php +++ b/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php @@ -1,6 +1,6 @@ lookup('mime.qpcontentencoder') - ; + ; } } diff --git a/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php b/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php index 3e614854d..19f81dd74 100644 --- a/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php +++ b/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php @@ -2,7 +2,7 @@ use Egulias\EmailValidator\EmailValidator; -class Swift_Mime_EmbeddedFileAcceptanceTest extends \PHPUnit\Framework\TestCase +class Swift_Mime_EmbeddedFileAcceptanceTest extends PHPUnit\Framework\TestCase { private $contentEncoder; private $cache; @@ -14,21 +14,21 @@ protected function setUp() { $this->cache = new Swift_KeyCache_ArrayKeyCache( new Swift_KeyCache_SimpleKeyCacheInputStream() - ); + ); $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); $this->contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') - ); + ); $paramEncoder = new Swift_Encoder_Rfc2231Encoder( new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') - ); + ); $this->emailValidator = new EmailValidator(); $this->idGenerator = new Swift_Mime_IdGenerator('example.com'); $this->headers = new Swift_Mime_SimpleHeaderSet( new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->emailValidator) - ); + ); } public function testContentIdIsSetInHeader() @@ -42,7 +42,7 @@ public function testContentIdIsSetInHeader() 'Content-ID: '."\r\n". 'Content-Disposition: inline'."\r\n", $file->toString() - ); + ); } public function testDispositionIsSetInHeader() @@ -57,7 +57,7 @@ public function testDispositionIsSetInHeader() 'Content-ID: <'.$id.'>'."\r\n". 'Content-Disposition: attachment'."\r\n", $file->toString() - ); + ); } public function testFilenameIsSetInHeader() @@ -72,7 +72,7 @@ public function testFilenameIsSetInHeader() 'Content-ID: <'.$id.'>'."\r\n". 'Content-Disposition: inline; filename=foo.pdf'."\r\n", $file->toString() - ); + ); } public function testSizeIsSetInHeader() @@ -87,7 +87,7 @@ public function testSizeIsSetInHeader() 'Content-ID: <'.$id.'>'."\r\n". 'Content-Disposition: inline; size=12340'."\r\n", $file->toString() - ); + ); } public function testMultipleParametersInHeader() @@ -104,7 +104,7 @@ public function testMultipleParametersInHeader() 'Content-ID: <'.$id.'>'."\r\n". 'Content-Disposition: inline; filename=foo.pdf; size=12340'."\r\n", $file->toString() - ); + ); } public function testEndToEnd() @@ -123,7 +123,7 @@ public function testEndToEnd() "\r\n". base64_encode('abcd'), $file->toString() - ); + ); } protected function createEmbeddedFile() @@ -133,7 +133,7 @@ protected function createEmbeddedFile() $this->contentEncoder, $this->cache, $this->idGenerator - ); + ); return $entity; } diff --git a/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php b/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php index 1c91df3ab..f5740b77f 100644 --- a/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php +++ b/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php @@ -1,6 +1,6 @@ cache = new Swift_KeyCache_ArrayKeyCache( new Swift_KeyCache_SimpleKeyCacheInputStream() - ); + ); $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); $this->contentEncoder = new Swift_Mime_ContentEncoder_QpContentEncoder( new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'), new Swift_StreamFilters_ByteArrayReplacementFilter( [[0x0D, 0x0A], [0x0D], [0x0A]], [[0x0A], [0x0A], [0x0D, 0x0A]] - ) - ); + ) + ); $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') - ); + ); $paramEncoder = new Swift_Encoder_Rfc2231Encoder( new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') - ); + ); $this->emailValidator = new EmailValidator(); $this->idGenerator = new Swift_Mime_IdGenerator('example.com'); $this->headers = new Swift_Mime_SimpleHeaderSet( new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->emailValidator) - ); + ); } public function testCharsetIsSetInHeader() @@ -49,7 +49,7 @@ public function testCharsetIsSetInHeader() "\r\n". 'foobar', $part->toString() - ); + ); } public function testFormatIsSetInHeaders() @@ -64,7 +64,7 @@ public function testFormatIsSetInHeaders() "\r\n". '> foobar', $part->toString() - ); + ); } public function testDelSpIsSetInHeaders() @@ -79,7 +79,7 @@ public function testDelSpIsSetInHeaders() "\r\n". 'foobar', $part->toString() - ); + ); } public function testAll3ParamsInHeaders() @@ -96,7 +96,7 @@ public function testAll3ParamsInHeaders() "\r\n". 'foobar', $part->toString() - ); + ); } public function testBodyIsCanonicalized() @@ -114,7 +114,7 @@ public function testBodyIsCanonicalized() "test\r\n". "ing\r\n", $part->toString() - ); + ); } protected function createMimePart() diff --git a/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php b/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php index e7f060018..7a8c56a87 100644 --- a/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php +++ b/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php @@ -1,10 +1,10 @@ setCharset(null); //TODO: Test with the charset defined + Swift_Preferences::getInstance()->setCharset(null); // TODO: Test with the charset defined } public function testBasicHeaders() @@ -24,7 +24,7 @@ public function testBasicHeaders() 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString(), '%s: Only required headers, and non-empty headers should be displayed' - ); + ); } public function testSubjectIsDisplayedIfSet() @@ -42,7 +42,7 @@ public function testSubjectIsDisplayedIfSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testDateCanBeSet() @@ -61,7 +61,7 @@ public function testDateCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testMessageIdCanBeSet() @@ -79,7 +79,7 @@ public function testMessageIdCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testContentTypeCanBeChanged() @@ -98,7 +98,7 @@ public function testContentTypeCanBeChanged() 'Content-Type: text/html'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testCharsetCanBeSet() @@ -118,7 +118,7 @@ public function testCharsetCanBeSet() 'Content-Type: text/html; charset=iso-8859-1'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testFormatCanBeSet() @@ -137,7 +137,7 @@ public function testFormatCanBeSet() 'Content-Type: text/plain; format=flowed'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testEncoderCanBeSet() @@ -147,7 +147,7 @@ public function testEncoderCanBeSet() $message->setContentType('text/html'); $message->setEncoder( new Swift_Mime_ContentEncoder_PlainContentEncoder('7bit') - ); + ); $id = $message->getId(); $date = $message->getDate(); $this->assertEquals( @@ -159,7 +159,7 @@ public function testEncoderCanBeSet() 'Content-Type: text/html'."\r\n". 'Content-Transfer-Encoding: 7bit'."\r\n", $message->toString() - ); + ); } public function testFromAddressCanBeSet() @@ -178,7 +178,7 @@ public function testFromAddressCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testFromAddressCanBeSetWithName() @@ -197,7 +197,7 @@ public function testFromAddressCanBeSetWithName() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testMultipleFromAddressesCanBeSet() @@ -219,7 +219,7 @@ public function testMultipleFromAddressesCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testReturnPathAddressCanBeSet() @@ -241,7 +241,7 @@ public function testReturnPathAddressCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testEmptyReturnPathHeaderCanBeUsed() @@ -263,7 +263,7 @@ public function testEmptyReturnPathHeaderCanBeUsed() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testSenderCanBeSet() @@ -283,7 +283,7 @@ public function testSenderCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testSenderCanBeSetWithName() @@ -303,7 +303,7 @@ public function testSenderCanBeSetWithName() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testReplyToCanBeSet() @@ -324,7 +324,7 @@ public function testReplyToCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testMultipleReplyAddressCanBeUsed() @@ -348,7 +348,7 @@ public function testMultipleReplyAddressCanBeUsed() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testToAddressCanBeSet() @@ -374,7 +374,7 @@ public function testToAddressCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testMultipleToAddressesCanBeSet() @@ -402,7 +402,7 @@ public function testMultipleToAddressesCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testCcAddressCanBeSet() @@ -432,7 +432,7 @@ public function testCcAddressCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testMultipleCcAddressesCanBeSet() @@ -465,12 +465,12 @@ public function testMultipleCcAddressesCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testBccAddressCanBeSet() { - //Obviously Transports need to setBcc(array()) and send to each Bcc recipient + // Obviously Transports need to setBcc(array()) and send to each Bcc recipient // separately in accordance with RFC 2822/2821 $message = $this->createMessage(); $message->setSubject('just a test subject'); @@ -502,12 +502,12 @@ public function testBccAddressCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testMultipleBccAddressesCanBeSet() { - //Obviously Transports need to setBcc(array()) and send to each Bcc recipient + // Obviously Transports need to setBcc(array()) and send to each Bcc recipient // separately in accordance with RFC 2822/2821 $message = $this->createMessage(); $message->setSubject('just a test subject'); @@ -539,7 +539,7 @@ public function testMultipleBccAddressesCanBeSet() 'Content-Type: text/plain'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString() - ); + ); } public function testStringBodyIsAppended() @@ -552,7 +552,7 @@ public function testStringBodyIsAppended() $message->setBody( 'just a test body'."\r\n". 'with a new line' - ); + ); $id = $message->getId(); $date = $message->getDate(); $this->assertEquals( @@ -568,7 +568,7 @@ public function testStringBodyIsAppended() 'just a test body'."\r\n". 'with a new line', $message->toString() - ); + ); } public function testStringBodyIsEncoded() @@ -581,7 +581,7 @@ public function testStringBodyIsEncoded() $message->setBody( 'Just s'.pack('C*', 0xC2, 0x01, 0x01).'me multi-'."\r\n". 'line message!' - ); + ); $id = $message->getId(); $date = $message->getDate(); $this->assertEquals( @@ -597,7 +597,7 @@ public function testStringBodyIsEncoded() 'Just s=C2=01=01me multi-'."\r\n". 'line message!', $message->toString() - ); + ); } public function testChildrenCanBeAttached() @@ -650,7 +650,7 @@ public function testChildrenCanBeAttached() "\r\n\r\n". '--'.$boundary.'--'."\r\n", $message->toString() - ); + ); } public function testAttachmentsBeingAttached() @@ -712,7 +712,7 @@ public function testAttachmentsBeingAttached() '--'.$boundary.'--'."\r\n". '$~D', $message->toString() - ); + ); } public function testAttachmentsAndEmbeddedFilesBeingAttached() @@ -798,7 +798,7 @@ public function testAttachmentsAndEmbeddedFilesBeingAttached() '--'.$boundary.'--'."\r\n". '$~D', $message->toString() - ); + ); } public function testComplexEmbeddingOfContent() @@ -853,7 +853,7 @@ public function testComplexEmbeddingOfContent() 'Content-Type: text/html; charset=iso-8859-1'."\r\n". 'Content-Transfer-Encoding: quoted-printable'."\r\n". "\r\n". - 'foo './/=3D is just = in QP + 'foo '.// =3D is just = in QP "\r\n\r\n". '--\\1'."\r\n". 'Content-Type: image/jpeg; name=myimage.jpg'."\r\n". @@ -875,7 +875,7 @@ public function testComplexEmbeddingOfContent() '--'.$boundary.'--'."\r\n". '$~D', $message->toString() - ); + ); } public function testAttachingAndDetachingContent() @@ -950,7 +950,7 @@ public function testAttachingAndDetachingContent() '$~D', $message->toString(), '%s: Attachment should have been detached' - ); + ); } public function testBoundaryDoesNotAppearAfterAllPartsAreDetached() @@ -993,7 +993,7 @@ public function testBoundaryDoesNotAppearAfterAllPartsAreDetached() 'Content-Transfer-Encoding: quoted-printable'."\r\n", $message->toString(), '%s: Message should be restored to orignal state after parts are detached' - ); + ); } public function testCharsetFormatOrDelSpAreNotShownWhenBoundaryIsSet() @@ -1049,7 +1049,7 @@ public function testCharsetFormatOrDelSpAreNotShownWhenBoundaryIsSet() "\r\n\r\n". '--'.$boundary.'--'."\r\n", $message->toString() - ); + ); } public function testBodyCanBeSetWithAttachments() @@ -1099,7 +1099,7 @@ public function testBodyCanBeSetWithAttachments() "\r\n\r\n". '--'.$boundary.'--'."\r\n", $message->toString() - ); + ); } public function testHtmlPartAlwaysAppearsLast() @@ -1149,7 +1149,7 @@ public function testHtmlPartAlwaysAppearsLast() "\r\n\r\n". '--'.$boundary.'--'."\r\n", $message->toString() - ); + ); } public function testBodyBecomesPartIfOtherPartsAttached() @@ -1196,7 +1196,7 @@ public function testBodyBecomesPartIfOtherPartsAttached() "\r\n\r\n". '--'.$boundary.'--'."\r\n", $message->toString() - ); + ); } public function testBodyIsCanonicalized() @@ -1209,7 +1209,7 @@ public function testBodyIsCanonicalized() $message->setBody( 'just a test body'."\n". 'with a new line' - ); + ); $id = $message->getId(); $date = $message->getDate(); $this->assertEquals( @@ -1225,7 +1225,7 @@ public function testBodyIsCanonicalized() 'just a test body'."\r\n". 'with a new line', $message->toString() - ); + ); } protected function createMessage() diff --git a/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php b/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php index a9bd3194f..51fb2e3db 100644 --- a/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php +++ b/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php @@ -1,6 +1,6 @@ markTestSkipped( 'Will fail on travis-ci if not skipped due to travis blocking '. 'socket mailing tcp connections.' - ); + ); } $this->buffer = new Swift_Transport_StreamBuffer( diff --git a/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php b/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php index d1076e21f..5068a442c 100644 --- a/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php +++ b/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php @@ -10,7 +10,7 @@ protected function setUp() $this->markTestSkipped( 'Cannot run test without an SMTP host to connect to (define '. 'SWIFT_SMTP_HOST in tests/acceptance.conf.php if you wish to run this test)' - ); + ); } parent::setUp(); } diff --git a/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php b/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php index 53971a22d..610a386e2 100644 --- a/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php +++ b/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php @@ -1,6 +1,6 @@ markTestSkipped( 'Cannot run test without an SMTP host to connect to (define '. 'SWIFT_SMTP_HOST in tests/acceptance.conf.php if you wish to run this test)' - ); + ); } $serverStarted = false; diff --git a/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php b/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php index 491ac4679..5e3c0e684 100644 --- a/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php +++ b/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php @@ -10,13 +10,13 @@ protected function setUp() if (!\in_array('ssl', $streams)) { $this->markTestSkipped( 'SSL is not configured for your system. It is not possible to run this test' - ); + ); } if (!\defined('SWIFT_SSL_HOST')) { $this->markTestSkipped( 'Cannot run test without an SSL enabled SMTP host to connect to (define '. 'SWIFT_SSL_HOST in tests/acceptance.conf.php if you wish to run this test)' - ); + ); } parent::setUp(); diff --git a/tests/bug/Swift/Bug111Test.php b/tests/bug/Swift/Bug111Test.php index e31ebb393..b98cb96fc 100644 --- a/tests/bug/Swift/Bug111Test.php +++ b/tests/bug/Swift/Bug111Test.php @@ -1,6 +1,6 @@ expectException(\Swift_IoException::class); + $this->expectException(Swift_IoException::class); $this->expectExceptionMessage('The path cannot be empty'); $message = new Swift_Message(); diff --git a/tests/bug/Swift/Bug34Test.php b/tests/bug/Swift/Bug34Test.php index c1e55cb05..b06a13e23 100644 --- a/tests/bug/Swift/Bug34Test.php +++ b/tests/bug/Swift/Bug34Test.php @@ -1,6 +1,6 @@ getId(); $this->assertMatchesRegularExpression( - '~^'. - 'Sender: Other '."\r\n". - 'Message-ID: <'.$id.'>'."\r\n". - 'Date: '.$date."\r\n". - 'Subject: test subject'."\r\n". - 'From: Other '."\r\n". - 'To: User '."\r\n". - 'MIME-Version: 1.0'."\r\n". - 'Content-Type: multipart/alternative;'."\r\n". - ' boundary="'.$boundary.'"'."\r\n". - "\r\n\r\n". - '--'.$boundary."\r\n". - 'Content-Type: text/plain; charset=utf-8'."\r\n". - 'Content-Transfer-Encoding: quoted-printable'."\r\n". - "\r\n". - 'plain part'. - "\r\n\r\n". - '--'.$boundary."\r\n". - 'Content-Type: multipart/related;'."\r\n". - ' boundary="(.*?)"'."\r\n". - "\r\n\r\n". - '--\\1'."\r\n". - 'Content-Type: text/html; charset=utf-8'."\r\n". - 'Content-Transfer-Encoding: quoted-printable'."\r\n". - "\r\n". - ''. - "\r\n\r\n". - '--\\1'."\r\n". - 'Content-Type: image/gif; name=image.gif'."\r\n". - 'Content-Transfer-Encoding: base64'."\r\n". - 'Content-ID: <'.$cidVal.'>'."\r\n". - 'Content-Disposition: inline; filename=image.gif'."\r\n". - "\r\n". - preg_quote(base64_encode(''), '~'). - "\r\n\r\n". - '--\\1--'."\r\n". - "\r\n\r\n". - '--'.$boundary.'--'."\r\n". - '$~D', - $message->toString() + '~^'. + 'Sender: Other '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: test subject'."\r\n". + 'From: Other '."\r\n". + 'To: User '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: text/plain; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'plain part'. + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: multipart/related;'."\r\n". + ' boundary="(.*?)"'."\r\n". + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: text/html; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + ''. + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: image/gif; name=image.gif'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-ID: <'.$cidVal.'>'."\r\n". + 'Content-Disposition: inline; filename=image.gif'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--\\1--'."\r\n". + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D', + $message->toString() ); } } diff --git a/tests/bug/Swift/Bug35Test.php b/tests/bug/Swift/Bug35Test.php index d1a69745d..0f3b3e382 100644 --- a/tests/bug/Swift/Bug35Test.php +++ b/tests/bug/Swift/Bug35Test.php @@ -1,6 +1,6 @@ getBoundary(); $this->assertMatchesRegularExpression( - '~^'. - 'Sender: Other '."\r\n". - 'Message-ID: <'.$id.'>'."\r\n". - 'Date: '.$date."\r\n". - 'Subject: test subject'."\r\n". - 'From: Other '."\r\n". - 'To: User '."\r\n". - 'MIME-Version: 1.0'."\r\n". - 'Content-Type: multipart/mixed;'."\r\n". - ' boundary="'.$boundary.'"'."\r\n". - "\r\n\r\n". - '--'.$boundary."\r\n". - 'Content-Type: multipart/alternative;'."\r\n". - ' boundary="(.*?)"'."\r\n". - "\r\n\r\n". - '--\\1'."\r\n". - 'Content-Type: text/plain; charset=utf-8'."\r\n". - 'Content-Transfer-Encoding: quoted-printable'."\r\n". - "\r\n". - 'plain part'. - "\r\n\r\n". - '--\\1'."\r\n". - 'Content-Type: text/html; charset=utf-8'."\r\n". - 'Content-Transfer-Encoding: quoted-printable'."\r\n". - "\r\n". - 'HTML part'. - "\r\n\r\n". - '--\\1--'."\r\n". - "\r\n\r\n". - '--'.$boundary."\r\n". - 'Content-Type: image/gif; name=image.gif'."\r\n". - 'Content-Transfer-Encoding: base64'."\r\n". - 'Content-Disposition: attachment; filename=image.gif'."\r\n". - "\r\n". - preg_quote(base64_encode(''), '~'). - "\r\n\r\n". - '--'.$boundary.'--'."\r\n". - '$~D', - $message->toString() + '~^'. + 'Sender: Other '."\r\n". + 'Message-ID: <'.$id.'>'."\r\n". + 'Date: '.$date."\r\n". + 'Subject: test subject'."\r\n". + 'From: Other '."\r\n". + 'To: User '."\r\n". + 'MIME-Version: 1.0'."\r\n". + 'Content-Type: multipart/mixed;'."\r\n". + ' boundary="'.$boundary.'"'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: multipart/alternative;'."\r\n". + ' boundary="(.*?)"'."\r\n". + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: text/plain; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'plain part'. + "\r\n\r\n". + '--\\1'."\r\n". + 'Content-Type: text/html; charset=utf-8'."\r\n". + 'Content-Transfer-Encoding: quoted-printable'."\r\n". + "\r\n". + 'HTML part'. + "\r\n\r\n". + '--\\1--'."\r\n". + "\r\n\r\n". + '--'.$boundary."\r\n". + 'Content-Type: image/gif; name=image.gif'."\r\n". + 'Content-Transfer-Encoding: base64'."\r\n". + 'Content-Disposition: attachment; filename=image.gif'."\r\n". + "\r\n". + preg_quote(base64_encode(''), '~'). + "\r\n\r\n". + '--'.$boundary.'--'."\r\n". + '$~D', + $message->toString() ); } } diff --git a/tests/bug/Swift/Bug38Test.php b/tests/bug/Swift/Bug38Test.php index 9a13b481c..e0feeb40b 100644 --- a/tests/bug/Swift/Bug38Test.php +++ b/tests/bug/Swift/Bug38Test.php @@ -1,6 +1,6 @@ toByteStream($streamA); $message->toByteStream($streamB); diff --git a/tests/bug/Swift/Bug518Test.php b/tests/bug/Swift/Bug518Test.php index e4d1d7c04..a0e3625c5 100644 --- a/tests/bug/Swift/Bug518Test.php +++ b/tests/bug/Swift/Bug518Test.php @@ -2,7 +2,7 @@ use Mockery as m; -class Swift_Bug518Test extends \SwiftMailerTestCase +class Swift_Bug518Test extends SwiftMailerTestCase { public function testIfEmailChangesAfterQueued() { @@ -12,7 +12,7 @@ public function testIfEmailChangesAfterQueued() $that = $this; $messageValidation = function ($m) use ($that) { - //the getTo should return the same value as we put in + // the getTo should return the same value as we put in $that->assertEquals('foo@bar.com', key($m->getTo()), 'The message has changed after it was put to the memory queue'); return true; diff --git a/tests/bug/Swift/Bug51Test.php b/tests/bug/Swift/Bug51Test.php index fdeb89b96..5b0141e4a 100644 --- a/tests/bug/Swift/Bug51Test.php +++ b/tests/bug/Swift/Bug51Test.php @@ -1,6 +1,6 @@ createMessageWithRandomAttachment( 10000, $this->attachmentFile @@ -44,7 +44,7 @@ public function testAttachmentsDoNotGetTruncatedUsingToByteStream() public function testAttachmentsDoNotGetTruncatedUsingToString() { - //Run 100 times with 10KB attachments + // Run 100 times with 10KB attachments for ($i = 0; $i < 10; ++$i) { $message = $this->createMessageWithRandomAttachment( 10000, $this->attachmentFile @@ -103,7 +103,7 @@ private function createMessageWithRandomAttachment($size, $attachmentPath) ->setFrom('a@b.c') ->setTo('d@e.f') ->attach(Swift_Attachment::fromPath($attachmentPath)) - ; + ; return $message; } diff --git a/tests/bug/Swift/Bug534Test.php b/tests/bug/Swift/Bug534Test.php index 6b224f1d9..3f3f22096 100644 --- a/tests/bug/Swift/Bug534Test.php +++ b/tests/bug/Swift/Bug534Test.php @@ -2,7 +2,7 @@ use Mockery as m; -class Swift_Bug534Test extends \SwiftMailerTestCase +class Swift_Bug534Test extends SwiftMailerTestCase { public function testEmbeddedImagesAreEmbedded() { diff --git a/tests/bug/Swift/Bug650Test.php b/tests/bug/Swift/Bug650Test.php index 31036c6ba..a9009b636 100644 --- a/tests/bug/Swift/Bug650Test.php +++ b/tests/bug/Swift/Bug650Test.php @@ -2,7 +2,7 @@ use Egulias\EmailValidator\EmailValidator; -class Swift_Bug650Test extends \PHPUnit\Framework\TestCase +class Swift_Bug650Test extends PHPUnit\Framework\TestCase { /** * @dataProvider encodingDataProvider diff --git a/tests/bug/Swift/Bug71Test.php b/tests/bug/Swift/Bug71Test.php index 90cee3f5c..73a17e580 100644 --- a/tests/bug/Swift/Bug71Test.php +++ b/tests/bug/Swift/Bug71Test.php @@ -1,6 +1,6 @@ createStream($this->inputFile); $is = $this->createStream($this->outputFile); - $this->encoder->encodeByteStream($os, $is, 0, 80); //Exceeds 76 + $this->encoder->encodeByteStream($os, $is, 0, 80); // Exceeds 76 $this->assertMaxLineLength(76, $this->outputFile, '%s: Line length should not exceed 76 characters' @@ -41,7 +41,7 @@ public function assertMaxLineLength($length, $filePath, $message = '%s') { $lines = file($filePath); foreach ($lines as $line) { - $this->assertTrue((\strlen(trim($line)) <= 76), $message); + $this->assertTrue(\strlen(trim($line)) <= 76, $message); } } diff --git a/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php b/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php index bffc6a54b..14abc8a16 100644 --- a/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php +++ b/tests/bug/Swift/BugFileByteStreamConsecutiveReadCallsTest.php @@ -1,15 +1,15 @@ expectException(\Swift_IoException::class); + $this->expectException(Swift_IoException::class); - $fbs = new \Swift_ByteStream_FileByteStream('does not exist'); + $fbs = new Swift_ByteStream_FileByteStream('does not exist'); try { $fbs->read(100); - } catch (\Swift_IoException $exc) { + } catch (Swift_IoException $exc) { $fbs->read(100); } } diff --git a/tests/smoke/Swift/Smoke/AttachmentSmokeTest.php b/tests/smoke/Swift/Smoke/AttachmentSmokeTest.php index 510d43ea7..c1e71116f 100644 --- a/tests/smoke/Swift/Smoke/AttachmentSmokeTest.php +++ b/tests/smoke/Swift/Smoke/AttachmentSmokeTest.php @@ -23,11 +23,11 @@ public function testAttachmentSending() ->setBody('This message should contain an attached ZIP file (named "textfile.zip").'.PHP_EOL. 'When unzipped, the archive should produce a text file which reads:'.PHP_EOL. '"This is part of a Swift Mailer smoke test."' - ) + ) ->attach(Swift_Attachment::fromPath($this->attFile)) - ; + ; $this->assertEquals(1, $mailer->send($message), '%s: The smoke test should send a single message' - ); + ); } } diff --git a/tests/smoke/Swift/Smoke/BasicSmokeTest.php b/tests/smoke/Swift/Smoke/BasicSmokeTest.php index 79915b342..fd0e17d5d 100644 --- a/tests/smoke/Swift/Smoke/BasicSmokeTest.php +++ b/tests/smoke/Swift/Smoke/BasicSmokeTest.php @@ -14,10 +14,10 @@ public function testBasicSending() ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS) ->setBody('One, two, three, four, five...'.PHP_EOL. 'six, seven, eight...' - ) - ; + ) + ; $this->assertEquals(1, $mailer->send($message), '%s: The smoke test should send a single message' - ); + ); } } diff --git a/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php b/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php index 5ed6c33b0..ed0271b9a 100644 --- a/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php +++ b/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php @@ -25,9 +25,9 @@ public function testAttachmentSending() 'When unzipped, the archive should produce a text file which reads:

'.PHP_EOL. '

This is part of a Swift Mailer smoke test.

', 'text/html' ) - ; + ; $this->assertEquals(1, $mailer->send($message), '%s: The smoke test should send a single message' - ); + ); } } diff --git a/tests/smoke/Swift/Smoke/InternationalSmokeTest.php b/tests/smoke/Swift/Smoke/InternationalSmokeTest.php index b1093f3d8..495c91d2b 100644 --- a/tests/smoke/Swift/Smoke/InternationalSmokeTest.php +++ b/tests/smoke/Swift/Smoke/InternationalSmokeTest.php @@ -27,14 +27,14 @@ public function testAttachmentSending() PHP_EOL. 'Following is some arbitrary Greek text:'.PHP_EOL. 'Δεν βρέθηκαν λέξεις.' - ) + ) ->attach(Swift_Attachment::fromPath($this->attFile) - ->setContentType('application/zip') - ->setFilename('κείμενο, εδάφιο, θέμα.zip') - ) - ; + ->setContentType('application/zip') + ->setFilename('κείμενο, εδάφιο, θέμα.zip') + ) + ; $this->assertEquals(1, $mailer->send($message), '%s: The smoke test should send a single message' - ); + ); } } diff --git a/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php b/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php index 3cb67e79f..7c8ad9c16 100644 --- a/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php +++ b/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php @@ -1,6 +1,6 @@ assertEquals($input, $output, '%s: Bytes read from stream should be the same as bytes in constructor' - ); + ); } public function testReadingMultipleBytesFromBaseInput() @@ -25,7 +25,7 @@ public function testReadingMultipleBytesFromBaseInput() } $this->assertEquals(['ab', 'cd'], $output, '%s: Bytes read from stream should be in pairs' - ); + ); } public function testReadingOddOffsetOnLastByte() @@ -38,7 +38,7 @@ public function testReadingOddOffsetOnLastByte() } $this->assertEquals(['ab', 'cd', 'e'], $output, '%s: Bytes read from stream should be in pairs except final read' - ); + ); } public function testSettingPointerPartway() @@ -48,7 +48,7 @@ public function testSettingPointerPartway() $bs->setReadPointer(1); $this->assertEquals('b', $bs->read(1), '%s: Byte should be second byte since pointer as at offset 1' - ); + ); } public function testResettingPointerAfterExhaustion() @@ -56,12 +56,13 @@ public function testResettingPointerAfterExhaustion() $input = ['a', 'b', 'c']; $bs = $this->createArrayStream($input); - while (false !== $bs->read(1)); + while (false !== $bs->read(1)) { + } $bs->setReadPointer(0); $this->assertEquals('a', $bs->read(1), '%s: Byte should be first byte since pointer as at offset 0' - ); + ); } public function testPointerNeverSetsBelowZero() @@ -72,7 +73,7 @@ public function testPointerNeverSetsBelowZero() $bs->setReadPointer(-1); $this->assertEquals('a', $bs->read(1), '%s: Byte should be first byte since pointer should be at offset 0' - ); + ); } public function testPointerNeverSetsAboveStackSize() @@ -83,7 +84,7 @@ public function testPointerNeverSetsAboveStackSize() $bs->setReadPointer(3); $this->assertFalse($bs->read(1), '%s: Stream should be at end and thus return false' - ); + ); } public function testBytesCanBeWrittenToStream() @@ -99,7 +100,7 @@ public function testBytesCanBeWrittenToStream() } $this->assertEquals(['a', 'b', 'c', 'd', 'e'], $output, '%s: Bytes read from stream should be from initial stack + written' - ); + ); } public function testContentsCanBeFlushed() @@ -111,7 +112,7 @@ public function testContentsCanBeFlushed() $this->assertFalse($bs->read(1), '%s: Contents have been flushed so read() should return false' - ); + ); } public function testConstructorCanTakeStringArgument() @@ -123,7 +124,7 @@ public function testConstructorCanTakeStringArgument() } $this->assertEquals(['a', 'b', 'c'], $output, '%s: Bytes read from stream should be the same as bytes in constructor' - ); + ); } public function testBindingOtherStreamsMirrorsWriteOperations() diff --git a/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php b/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php index 1ba5e784c..bb6a3a691 100644 --- a/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php +++ b/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php @@ -1,6 +1,6 @@ assertSame( 1, $reader->validateByteSequence([0x01, 0x02, 0x03], 3) - ); //3 octets + ); // 3 octets $this->assertSame( 2, $reader->validateByteSequence([0x01, 0x0A], 2) - ); //2 octets + ); // 2 octets $this->assertSame( 3, $reader->validateByteSequence([0xFE], 1) - ); //1 octet + ); // 1 octet $this->assertSame( 0, $reader->validateByteSequence([0xFE, 0x03, 0x67, 0x9A], 4) - ); //All 4 octets + ); // All 4 octets } public function testValidationFailsIfTooManyOctets() @@ -38,6 +38,6 @@ public function testValidationFailsIfTooManyOctets() $this->assertSame(-1, $reader->validateByteSequence( [0xFE, 0x03, 0x67, 0x9A, 0x10, 0x09, 0x85], 7 - )); //7 octets + )); // 7 octets } } diff --git a/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php b/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php index b85b0ab1b..05b128183 100644 --- a/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php +++ b/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php @@ -1,6 +1,6 @@ assertSame( 0, $this->reader->validateByteSequence([$ordinal], 1) - ); + ); } } @@ -37,7 +37,7 @@ public function testMultipleBytesAreInvalid() for ($ordinal = 0x00; $ordinal <= 0x7F; $ordinal += 2) { $this->assertSame( -1, $this->reader->validateByteSequence([$ordinal, $ordinal + 1], 2) - ); + ); } } @@ -46,7 +46,7 @@ public function testBytesAboveAsciiRangeAreInvalid() for ($ordinal = 0x80; $ordinal <= 0xFF; ++$ordinal) { $this->assertSame( -1, $this->reader->validateByteSequence([$ordinal], 1) - ); + ); } } } diff --git a/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php b/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php index 06379118c..0e5f1e6e5 100644 --- a/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php +++ b/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php @@ -1,6 +1,6 @@ assertSame( 0, $this->reader->validateByteSequence([$ordinal], 1) - ); + ); } } @@ -23,7 +23,7 @@ public function testLeadingByteOf2OctetCharCausesReturn1() for ($octet = 0xC0; $octet <= 0xDF; ++$octet) { $this->assertSame( 1, $this->reader->validateByteSequence([$octet], 1) - ); + ); } } @@ -32,7 +32,7 @@ public function testLeadingByteOf3OctetCharCausesReturn2() for ($octet = 0xE0; $octet <= 0xEF; ++$octet) { $this->assertSame( 2, $this->reader->validateByteSequence([$octet], 1) - ); + ); } } @@ -41,7 +41,7 @@ public function testLeadingByteOf4OctetCharCausesReturn3() for ($octet = 0xF0; $octet <= 0xF7; ++$octet) { $this->assertSame( 3, $this->reader->validateByteSequence([$octet], 1) - ); + ); } } @@ -50,7 +50,7 @@ public function testLeadingByteOf5OctetCharCausesReturn4() for ($octet = 0xF8; $octet <= 0xFB; ++$octet) { $this->assertSame( 4, $this->reader->validateByteSequence([$octet], 1) - ); + ); } } @@ -59,7 +59,7 @@ public function testLeadingByteOf6OctetCharCausesReturn5() for ($octet = 0xFC; $octet <= 0xFD; ++$octet) { $this->assertSame( 5, $this->reader->validateByteSequence([$octet], 1) - ); + ); } } } diff --git a/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php b/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php index b166245d7..987074f78 100644 --- a/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php +++ b/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php @@ -1,6 +1,6 @@ shouldReceive('getInitialByteSize') ->zeroOrMoreTimes() ->andReturn(1); - //String + // String $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); - //Stream + // Stream $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); $reader->shouldReceive('validateByteSequence')->once()->with([0xD1], 1)->andReturn(1); $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); @@ -90,17 +90,17 @@ public function testReadCharactersAreInTact() 0xD0, 0xB1, 0xD1, 0x8B, 0xD1, 0x85 - ) + ) ); $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94), $stream->read(1)); $this->assertIdenticalBinary( pack('C*', 0xD0, 0xB6, 0xD0, 0xBE), $stream->read(2) - ); + ); $this->assertIdenticalBinary(pack('C*', 0xD0, 0xBB), $stream->read(1)); $this->assertIdenticalBinary( pack('C*', 0xD1, 0x8E, 0xD0, 0xB1, 0xD1, 0x8B), $stream->read(3) - ); + ); $this->assertIdenticalBinary(pack('C*', 0xD1, 0x85), $stream->read(1)); $this->assertFalse($stream->read(1)); @@ -116,11 +116,11 @@ public function testCharactersCanBeReadAsByteArrays() $reader->shouldReceive('getInitialByteSize') ->zeroOrMoreTimes() ->andReturn(1); - //String + // String $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); - //Stream + // Stream $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); $reader->shouldReceive('validateByteSequence')->once()->with([0xD1], 1)->andReturn(1); $reader->shouldReceive('validateByteSequence')->once()->with([0xD0], 1)->andReturn(1); @@ -135,7 +135,7 @@ public function testCharactersCanBeReadAsByteArrays() 0xD0, 0xB1, 0xD1, 0x8B, 0xD1, 0x85 - ) + ) ); $this->assertEquals([0xD0, 0x94], $stream->readBytes(1)); @@ -143,7 +143,7 @@ public function testCharactersCanBeReadAsByteArrays() $this->assertEquals([0xD0, 0xBB], $stream->readBytes(1)); $this->assertEquals( [0xD1, 0x8E, 0xD0, 0xB1, 0xD1, 0x8B], $stream->readBytes(3) - ); + ); $this->assertEquals([0xD1, 0x85], $stream->readBytes(1)); $this->assertFalse($stream->readBytes(1)); @@ -167,7 +167,7 @@ public function testRequestingLargeCharCountPastEndOfStream() $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE), $stream->read(100) - ); + ); $this->assertFalse($stream->read(1)); } @@ -190,7 +190,7 @@ public function testRequestingByteArrayCountPastEndOfStream() $this->assertEquals([0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE], $stream->readBytes(100) - ); + ); $this->assertFalse($stream->readBytes(1)); } diff --git a/tests/unit/Swift/DependencyContainerTest.php b/tests/unit/Swift/DependencyContainerTest.php index 286f83281..4f7b86711 100644 --- a/tests/unit/Swift/DependencyContainerTest.php +++ b/tests/unit/Swift/DependencyContainerTest.php @@ -12,7 +12,7 @@ public function __construct($arg1 = null, $arg2 = null) } } -class Swift_DependencyContainerTest extends \PHPUnit\Framework\TestCase +class Swift_DependencyContainerTest extends PHPUnit\Framework\TestCase { private $container; @@ -147,7 +147,7 @@ public function testResolvedDependenciesCanBeLookedUp() $deps = $this->container->createDependenciesFor('two'); $this->assertEquals( [$this->container->lookup('one'), 'FOO'], $deps - ); + ); } public function testArrayOfDependenciesCanBeSpecified() diff --git a/tests/unit/Swift/Encoder/Base64EncoderTest.php b/tests/unit/Swift/Encoder/Base64EncoderTest.php index eefb0c6fc..009c84721 100644 --- a/tests/unit/Swift/Encoder/Base64EncoderTest.php +++ b/tests/unit/Swift/Encoder/Base64EncoderTest.php @@ -1,6 +1,6 @@ assertEquals( 'MTIz', $this->encoder->encodeString('123'), '%s: 3 bytes of input should yield 4 bytes of output' - ); + ); $this->assertEquals( 'MTIzNDU2', $this->encoder->encodeString('123456'), '%s: 6 bytes in input should yield 8 bytes of output' - ); + ); $this->assertEquals( 'MTIzNDU2Nzg5', $this->encoder->encodeString('123456789'), '%s: 9 bytes in input should yield 12 bytes of output' - ); + ); } public function testPadLength() @@ -68,7 +68,7 @@ public function testPadLength() $this->assertMatchesRegularExpression( '~^[a-zA-Z0-9/\+]{2}==$~', $this->encoder->encodeString($input), '%s: A single byte should have 2 bytes of padding' - ); + ); } for ($i = 0; $i < 30; ++$i) { @@ -76,7 +76,7 @@ public function testPadLength() $this->assertMatchesRegularExpression( '~^[a-zA-Z0-9/\+]{3}=$~', $this->encoder->encodeString($input), '%s: Two bytes should have 1 byte of padding' - ); + ); } for ($i = 0; $i < 30; ++$i) { @@ -84,7 +84,7 @@ public function testPadLength() $this->assertMatchesRegularExpression( '~^[a-zA-Z0-9/\+]{4}$~', $this->encoder->encodeString($input), '%s: Three bytes should have no padding' - ); + ); } } @@ -106,17 +106,17 @@ public function testMaximumLineLengthIs76Characters() 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $output = - 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.//38 - 'NERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1'."\r\n".//76 * - 'Njc4OTBhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3'.//38 - 'h5ekFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFla'."\r\n".//76 * - 'MTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BRUl'.//38 - 'NUVVZXWFla'; //48 + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.// 38 + 'NERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1'."\r\n".// 76 * + 'Njc4OTBhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3'.// 38 + 'h5ekFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFla'."\r\n".// 76 * + 'MTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BRUl'.// 38 + 'NUVVZXWFla'; // 48 $this->assertEquals( $output, $this->encoder->encodeString($input), '%s: Lines should be no more than 76 characters' - ); + ); } public function testMaximumLineLengthCanBeSpecified() @@ -131,19 +131,19 @@ public function testMaximumLineLengthCanBeSpecified() 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $output = - 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.//38 - 'NERUZHSElKS0'."\r\n".//50 * - 'xNTk9QUVJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNk'.//38 - 'ZWZnaGlqa2xt'."\r\n".//50 * - 'bm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLTE1OT1'.//38 - 'BRUlNUVVZXWF'."\r\n".//50 * - 'laMTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BR'.//38 - 'UlNUVVZXWFla'; //50 * + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.// 38 + 'NERUZHSElKS0'."\r\n".// 50 * + 'xNTk9QUVJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNk'.// 38 + 'ZWZnaGlqa2xt'."\r\n".// 50 * + 'bm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLTE1OT1'.// 38 + 'BRUlNUVVZXWF'."\r\n".// 50 * + 'laMTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BR'.// 38 + 'UlNUVVZXWFla'; // 50 * $this->assertEquals( $output, $this->encoder->encodeString($input, 0, 50), '%s: Lines should be no more than 100 characters' - ); + ); } public function testFirstLineLengthCanBeDifferent() @@ -158,16 +158,16 @@ public function testFirstLineLengthCanBeDifferent() 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $output = - 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.//38 - 'NERUZHSElKS0xNTk9QU'."\r\n".//57 * - 'VJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNkZWZnaGl'.//38 - 'qa2xtbm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLT'."\r\n".//76 * - 'E1OT1BRUlNUVVZXWFlaMTIzNDU2Nzg5MEFCQ0R'.//38 - 'FRkdISUpLTE1OT1BRUlNUVVZXWFla'; //67 + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk'.// 38 + 'NERUZHSElKS0xNTk9QU'."\r\n".// 57 * + 'VJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNkZWZnaGl'.// 38 + 'qa2xtbm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLT'."\r\n".// 76 * + 'E1OT1BRUlNUVVZXWFlaMTIzNDU2Nzg5MEFCQ0R'.// 38 + 'FRkdISUpLTE1OT1BRUlNUVVZXWFla'; // 67 $this->assertEquals( $output, $this->encoder->encodeString($input, 19), '%s: First line offset is 19 so first line should be 57 chars long' - ); + ); } } diff --git a/tests/unit/Swift/Encoder/QpEncoderTest.php b/tests/unit/Swift/Encoder/QpEncoderTest.php index 51dc9d17e..22d647f50 100644 --- a/tests/unit/Swift/Encoder/QpEncoderTest.php +++ b/tests/unit/Swift/Encoder/QpEncoderTest.php @@ -1,6 +1,6 @@ createCharStream(); @@ -101,9 +101,9 @@ public function testWhiteSpaceAtLineEndingIsEncoded() $this->assertEquals( 'a'.$HT.'=09'."\r\n".'b', $encoder->encodeString($string) - ); + ); - //SPACE + // SPACE $string = 'a'.$SPACE.$SPACE."\r\n".'b'; $charStream = $this->createCharStream(); @@ -125,7 +125,7 @@ public function testWhiteSpaceAtLineEndingIsEncoded() $this->assertEquals( 'a'.$SPACE.'=20'."\r\n".'b', $encoder->encodeString($string) - ); + ); } public function testCRLFIsLeftAlone() @@ -278,7 +278,7 @@ public function testBytesBelowPermittedRangeAreEncoded() $this->assertEquals( sprintf('=%02X', $ordinal), $encoder->encodeString($char) - ); + ); } } @@ -334,7 +334,7 @@ public function testBytesAbovePermittedRangeAreEncoded() $this->assertEquals( sprintf('=%02X', $ordinal), $encoder->encodeString($char) - ); + ); } } @@ -369,7 +369,7 @@ public function testFirstLineLengthCanBeDifferent() $this->assertEquals( $output, $encoder->encodeString($input, 22), '%s: First line should start at offset 22 so can only have max length 54' - ); + ); } public function testTextIsPreWrapped() @@ -382,7 +382,7 @@ public function testTextIsPreWrapped() $this->assertEquals( $input, $encoder->encodeString($input) - ); + ); } private function createCharStream() diff --git a/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php b/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php index 3f25687fd..04ec2f56f 100644 --- a/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php +++ b/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php @@ -1,6 +1,6 @@ createEvent($this->createTransport(), "250 Ok\r\n", true); $this->assertEquals("250 Ok\r\n", $evt->getResponse(), '%s: Response should be available via getResponse()' - ); + ); } public function testResultCanBeFetchedViaGetter() @@ -15,7 +15,7 @@ public function testResultCanBeFetchedViaGetter() $evt = $this->createEvent($this->createTransport(), "250 Ok\r\n", false); $this->assertFalse($evt->isValid(), '%s: Result should be checkable via isValid()' - ); + ); } public function testSourceIsBuffer() diff --git a/tests/unit/Swift/Events/SendEventTest.php b/tests/unit/Swift/Events/SendEventTest.php index 9f55589a6..b564f95b5 100644 --- a/tests/unit/Swift/Events/SendEventTest.php +++ b/tests/unit/Swift/Events/SendEventTest.php @@ -1,6 +1,6 @@ getMessage(); $this->assertEquals($message, $ref, '%s: Message should be returned from getMessage()' - ); + ); } public function testTransportCanBeFetchViaGetter() @@ -25,7 +25,7 @@ public function testTransportCanBeFetchViaGetter() $ref = $evt->getTransport(); $this->assertEquals($transport, $ref, '%s: Transport should be returned from getTransport()' - ); + ); } public function testTransportCanBeFetchViaGetSource() @@ -38,7 +38,7 @@ public function testTransportCanBeFetchViaGetSource() $ref = $evt->getSource(); $this->assertEquals($transport, $ref, '%s: Transport should be returned from getSource()' - ); + ); } public function testResultCanBeSetAndGet() @@ -50,7 +50,7 @@ public function testResultCanBeSetAndGet() $evt->setResult( Swift_Events_SendEvent::RESULT_SUCCESS | Swift_Events_SendEvent::RESULT_TENTATIVE - ); + ); $this->assertTrue((bool) ($evt->getResult() & Swift_Events_SendEvent::RESULT_SUCCESS)); $this->assertTrue((bool) ($evt->getResult() & Swift_Events_SendEvent::RESULT_TENTATIVE)); @@ -67,7 +67,7 @@ public function testFailedRecipientsCanBeSetAndGet() $this->assertEquals(['foo@bar', 'zip@button'], $evt->getFailedRecipients(), '%s: FailedRecipients should be returned from getter' - ); + ); } public function testFailedRecipientsGetsPickedUpCorrectly() diff --git a/tests/unit/Swift/Events/SimpleEventDispatcherTest.php b/tests/unit/Swift/Events/SimpleEventDispatcherTest.php index 92eafe905..7d9e47f9e 100644 --- a/tests/unit/Swift/Events/SimpleEventDispatcherTest.php +++ b/tests/unit/Swift/Events/SimpleEventDispatcherTest.php @@ -1,6 +1,6 @@ getException(); $this->assertEquals($ex, $ref, '%s: Exception should be available via getException()' - ); + ); } public function testSourceIsTransport() @@ -21,7 +21,7 @@ public function testSourceIsTransport() $ref = $evt->getSource(); $this->assertEquals($transport, $ref, '%s: Transport should be available via getSource()' - ); + ); } private function createEvent(Swift_Transport $transport, Swift_TransportException $ex) diff --git a/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php b/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php index 9edb95bb2..dfd0ad4fc 100644 --- a/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php +++ b/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php @@ -1,6 +1,6 @@ createCache($is); $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('test', $cache->getString($this->key1, 'foo')); } @@ -21,10 +21,10 @@ public function testStringDataCanBeOverwritten() $cache = $this->createCache($is); $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $cache->setString( $this->key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('whatever', $cache->getString($this->key1, 'foo')); } @@ -35,10 +35,10 @@ public function testStringDataCanBeAppended() $cache = $this->createCache($is); $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $cache->setString( $this->key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND - ); + ); $this->assertEquals('testing', $cache->getString($this->key1, 'foo')); } @@ -49,7 +49,7 @@ public function testHasKeyReturnValue() $cache = $this->createCache($is); $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertTrue($cache->hasKey($this->key1, 'foo')); } @@ -60,10 +60,10 @@ public function testNsKeyIsWellPartitioned() $cache = $this->createCache($is); $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $cache->setString( $this->key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('test', $cache->getString($this->key1, 'foo')); $this->assertEquals('ing', $cache->getString($this->key2, 'foo')); @@ -75,10 +75,10 @@ public function testItemKeyIsWellPartitioned() $cache = $this->createCache($is); $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $cache->setString( $this->key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('test', $cache->getString($this->key1, 'foo')); $this->assertEquals('ing', $cache->getString($this->key1, 'bar')); @@ -95,7 +95,7 @@ public function testByteStreamCanBeImported() $cache = $this->createCache($is); $cache->importFromByteStream( $this->key1, 'foo', $os, Swift_KeyCache::MODE_WRITE - ); + ); $this->assertEquals('abcdef', $cache->getString($this->key1, 'foo')); } @@ -117,10 +117,10 @@ public function testByteStreamCanBeAppended() $cache->importFromByteStream( $this->key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND - ); + ); $cache->importFromByteStream( $this->key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND - ); + ); $this->assertEquals('abcdefxyzuvw', $cache->getString($this->key1, 'foo')); } @@ -138,16 +138,16 @@ public function testByteStreamAndStringCanBeAppended() $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND - ); + ); $cache->importFromByteStream( $this->key1, 'foo', $os, Swift_KeyCache::MODE_APPEND - ); + ); $this->assertEquals('testabcdef', $cache->getString($this->key1, 'foo')); } public function testDataCanBeExportedToByteStream() { - //See acceptance test for more detail + // See acceptance test for more detail $is = $this->createInputStream(); $is->expects($this->atLeastOnce()) ->method('write'); @@ -158,7 +158,7 @@ public function testDataCanBeExportedToByteStream() $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $cache->exportToByteStream($this->key1, 'foo', $is); } @@ -170,7 +170,7 @@ public function testKeyCanBeCleared() $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertTrue($cache->hasKey($this->key1, 'foo')); $cache->clearKey($this->key1, 'foo'); $this->assertFalse($cache->hasKey($this->key1, 'foo')); @@ -183,10 +183,10 @@ public function testNsKeyCanBeCleared() $cache->setString( $this->key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE - ); + ); $cache->setString( $this->key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE - ); + ); $this->assertTrue($cache->hasKey($this->key1, 'foo')); $this->assertTrue($cache->hasKey($this->key1, 'bar')); $cache->clearAll($this->key1); diff --git a/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php b/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php index 5bf06b9ab..27da00020 100644 --- a/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php +++ b/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php @@ -1,6 +1,6 @@ createMessage(); $transport->shouldReceive('send') ->once() - ->with($message, \Mockery::any()); + ->with($message, Mockery::any()); $mailer = $this->createMailer($transport); $mailer->send($message); @@ -68,7 +68,7 @@ public function testSendReturnsCountFromTransport() $message = $this->createMessage(); $transport->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturn(57); $mailer = $this->createMailer($transport); diff --git a/tests/unit/Swift/MessageTest.php b/tests/unit/Swift/MessageTest.php index 1c3f894ed..ff572c341 100644 --- a/tests/unit/Swift/MessageTest.php +++ b/tests/unit/Swift/MessageTest.php @@ -1,6 +1,6 @@ createHeaderSet(); $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $this->assertSame($headers, $entity->getHeaders()); } @@ -19,7 +19,7 @@ public function testContentTypeIsReturnedFromHeader() $headers = $this->createHeaderSet(['Content-Type' => $ctype]); $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('image/jpeg-test', $entity->getContentType()); } @@ -33,11 +33,11 @@ public function testContentTypeIsSetInHeader() ->with('image/jpeg'); $ctype->shouldReceive('setFieldBodyModel') ->zeroOrMoreTimes() - ->with(\Mockery::not('image/jpeg')); + ->with(Mockery::not('image/jpeg')); $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setContentType('image/jpeg'); } @@ -52,7 +52,7 @@ public function testContentTypeHeaderIsAddedIfNoneSet() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setContentType('image/jpeg'); } @@ -67,7 +67,7 @@ public function testContentTypeCanBeSetViaSetBody() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setBody('foo', 'text/html'); } @@ -76,7 +76,7 @@ public function testGetEncoderFromConstructor() $encoder = $this->createEncoder('base64'); $entity = $this->createEntity($this->createHeaderSet(), $encoder, $this->createCache() - ); + ); $this->assertSame($encoder, $entity->getEncoder()); } @@ -86,7 +86,7 @@ public function testSetAndGetEncoder() $headers = $this->createHeaderSet(); $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setEncoder($encoder); $this->assertSame($encoder, $entity->getEncoder()); } @@ -96,7 +96,7 @@ public function testSettingEncoderUpdatesTransferEncoding() $encoder = $this->createEncoder('base64'); $encoding = $this->createHeader( 'Content-Transfer-Encoding', '8bit', [], false - ); + ); $headers = $this->createHeaderSet([ 'Content-Transfer-Encoding' => $encoding, ]); @@ -108,7 +108,7 @@ public function testSettingEncoderUpdatesTransferEncoding() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setEncoder($encoder); } @@ -123,7 +123,7 @@ public function testSettingEncoderAddsEncodingHeaderIfNonePresent() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setEncoder($this->createEncoder('something')); } @@ -140,7 +140,7 @@ public function testIdIsReturnedFromHeader() $headers = $this->createHeaderSet(['Content-ID' => $cid]); $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('zip@button', $entity->getId()); } @@ -157,7 +157,7 @@ public function testIdIsSetInHeader() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setId('foo@bar'); } @@ -165,7 +165,7 @@ public function testIdIsAutoGenerated() { $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertMatchesRegularExpression('/^.*?@.*?$/D', $entity->getId()); } @@ -174,7 +174,7 @@ public function testGenerateIdCreatesNewId() $headers = $this->createHeaderSet(); $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $id1 = $entity->generateId(); $id2 = $entity->generateId(); $this->assertNotEquals($id1, $id2); @@ -185,7 +185,7 @@ public function testGenerateIdSetsNewId() $headers = $this->createHeaderSet(); $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $id = $entity->generateId(); $this->assertEquals($id, $entity->getId()); } @@ -204,7 +204,7 @@ public function testDescriptionIsReadFromHeader() $headers = $this->createHeaderSet(['Content-Description' => $desc]); $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('something', $entity->getDescription()); } @@ -217,7 +217,7 @@ public function testDescriptionIsSetInHeader() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setDescription('whatever'); } @@ -232,7 +232,7 @@ public function testDescriptionHeaderIsAddedIfNotPresent() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setDescription('whatever'); } @@ -240,7 +240,7 @@ public function testSetAndGetMaxLineLength() { $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $entity->setMaxLineLength(60); $this->assertEquals(60, $entity->getMaxLineLength()); } @@ -254,7 +254,7 @@ public function testEncoderIsUsedForStringGeneration() $entity = $this->createEntity($this->createHeaderSet(), $encoder, $this->createCache() - ); + ); $entity->setBody('blah'); $entity->toString(); } @@ -268,7 +268,7 @@ public function testMaxLineLengthIsProvidedWhenEncoding() $entity = $this->createEntity($this->createHeaderSet(), $encoder, $this->createCache() - ); + ); $entity->setBody('blah'); $entity->setMaxLineLength(65); $entity->toString(); @@ -286,19 +286,19 @@ public function testHeadersAppearInString() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals( "Content-Type: text/plain; charset=utf-8\r\n". "X-MyHeader: foobar\r\n", $entity->toString() - ); + ); } public function testSetAndGetBody() { $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $entity->setBody("blah\r\nblah!"); $this->assertEquals("blah\r\nblah!", $entity->getBody()); } @@ -312,14 +312,14 @@ public function testBodyIsAppended() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setBody("blah\r\nblah!"); $this->assertEquals( "Content-Type: text/plain; charset=utf-8\r\n". "\r\n". "blah\r\nblah!", $entity->toString() - ); + ); } public function testGetBodyReturnsStringFromByteStream() @@ -327,7 +327,7 @@ public function testGetBodyReturnsStringFromByteStream() $os = $this->createOutputStream('byte stream string'); $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $entity->setBody($os); $this->assertEquals('byte stream string', $entity->getBody()); } @@ -342,14 +342,14 @@ public function testByteStreamBodyIsAppended() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setBody($os); $this->assertEquals( "Content-Type: text/plain; charset=utf-8\r\n". "\r\n". 'streamed', $entity->toString() - ); + ); } public function testBoundaryCanBeRetrieved() @@ -366,18 +366,18 @@ public function testBoundaryCanBeRetrieved() $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertMatchesRegularExpression( '/^[a-zA-Z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-zA-Z0-9\'\(\)\+_\-,\.\/:=\?]$/D', $entity->getBoundary() - ); + ); } public function testBoundaryNeverChanges() { $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $firstBoundary = $entity->getBoundary(); for ($i = 0; $i < 10; ++$i) { $this->assertEquals($firstBoundary, $entity->getBoundary()); @@ -388,7 +388,7 @@ public function testBoundaryCanBeSet() { $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $entity->setBoundary('foobar'); $this->assertEquals('foobar', $entity->getBoundary()); } @@ -399,7 +399,7 @@ public function testAddingChildrenGeneratesBoundaryInHeaders() $cType = $this->createHeader('Content-Type', 'text/plain', [], false); $cType->shouldReceive('setParameter') ->once() - ->with('boundary', \Mockery::any()); + ->with('boundary', Mockery::any()); $cType->shouldReceive('setParameter') ->zeroOrMoreTimes(); @@ -407,7 +407,7 @@ public function testAddingChildrenGeneratesBoundaryInHeaders() 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $entity->setChildren([$child]); } @@ -418,7 +418,7 @@ public function testChildrenOfLevelAttachmentAndLessCauseMultipartMixed() $child = $this->createChild($level); $cType = $this->createHeader( 'Content-Type', 'text/plain', [], false - ); + ); $cType->shouldReceive('setFieldBodyModel') ->once() ->with('multipart/mixed'); @@ -428,7 +428,7 @@ public function testChildrenOfLevelAttachmentAndLessCauseMultipartMixed() $entity = $this->createEntity($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $entity->setChildren([$child]); } } @@ -440,7 +440,7 @@ public function testChildrenOfLevelAlternativeAndLessCauseMultipartAlternative() $child = $this->createChild($level); $cType = $this->createHeader( 'Content-Type', 'text/plain', [], false - ); + ); $cType->shouldReceive('setFieldBodyModel') ->once() ->with('multipart/alternative'); @@ -450,7 +450,7 @@ public function testChildrenOfLevelAlternativeAndLessCauseMultipartAlternative() $entity = $this->createEntity($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $entity->setChildren([$child]); } } @@ -462,7 +462,7 @@ public function testChildrenOfLevelRelatedAndLessCauseMultipartRelated() $child = $this->createChild($level); $cType = $this->createHeader( 'Content-Type', 'text/plain', [], false - ); + ); $cType->shouldReceive('setFieldBodyModel') ->once() ->with('multipart/related'); @@ -472,7 +472,7 @@ public function testChildrenOfLevelRelatedAndLessCauseMultipartRelated() $entity = $this->createEntity($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $entity->setChildren([$child]); } } @@ -511,7 +511,7 @@ public function testHighestLevelChildDeterminesContentType() $cType = $this->createHeader( 'Content-Type', 'text/plain', [], false - ); + ); $cType->shouldReceive('setFieldBodyModel') ->once() ->with($combination['type']); @@ -524,7 +524,7 @@ public function testHighestLevelChildDeterminesContentType() }); $entity = $this->createEntity($headerSet, $this->createEncoder(), $this->createCache() - ); + ); $entity->setChildren($children); } } @@ -541,13 +541,13 @@ public function testChildrenAppearNestedInString() "Content-Type: text/plain\r\n". "\r\n". 'foobar', 'text/plain' - ); + ); $child2 = new MimeEntityFixture(Swift_Mime_SimpleMimeEntity::LEVEL_ALTERNATIVE, "Content-Type: text/html\r\n". "\r\n". 'foobar', 'text/html' - ); + ); $headers->shouldReceive('toString') ->zeroOrMoreTimes() @@ -555,7 +555,7 @@ public function testChildrenAppearNestedInString() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setBoundary('xxx'); $entity->setChildren([$child1, $child2]); @@ -572,7 +572,7 @@ public function testChildrenAppearNestedInString() "foobar\r\n". "\r\n--xxx--\r\n", $entity->toString() - ); + ); } public function testMixingLevelsIsHierarchical() @@ -584,13 +584,13 @@ public function testMixingLevelsIsHierarchical() "Content-Type: text/plain\r\n". "\r\n". 'foobar' - ); + ); $attachment = $this->createChild(Swift_Mime_SimpleMimeEntity::LEVEL_MIXED, "Content-Type: application/octet-stream\r\n". "\r\n". 'data' - ); + ); $headers->shouldReceive('toString') ->zeroOrMoreTimes() @@ -604,7 +604,7 @@ public function testMixingLevelsIsHierarchical() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setBoundary('xxx'); $entity->setChildren([$part, $attachment]); @@ -625,7 +625,7 @@ public function testMixingLevelsIsHierarchical() "\r\n\r\n--xxx--\r\n". '$~', $entity->toString() - ); + ); } public function testSettingEncoderNotifiesChildren() @@ -639,7 +639,7 @@ public function testSettingEncoderNotifiesChildren() $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $entity->setChildren([$child]); $entity->setEncoder($encoder); } @@ -655,7 +655,7 @@ public function testReceiptOfEncoderChangeNotifiesChildren() $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $entity->setChildren([$child]); $entity->encoderChanged($encoder); } @@ -669,7 +669,7 @@ public function testReceiptOfCharsetChangeNotifiesChildren() $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $entity->setChildren([$child]); $entity->charsetChanged('windows-874'); } @@ -678,7 +678,7 @@ public function testEntityIsWrittenToByteStream() { $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $is = $this->createInputStream(false); $is->expects($this->atLeastOnce()) ->method('write'); @@ -690,7 +690,7 @@ public function testEntityHeadersAreComittedToByteStream() { $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $is = $this->createInputStream(false); $is->expects($this->atLeastOnce()) ->method('write'); @@ -707,13 +707,13 @@ public function testOrderingTextBeforeHtml() "\r\n". 'HTML PART', 'text/html' - ); + ); $textChild = new MimeEntityFixture(Swift_Mime_SimpleMimeEntity::LEVEL_ALTERNATIVE, "Content-Type: text/plain\r\n". "\r\n". 'TEXT PART', 'text/plain' - ); + ); $headers = $this->createHeaderSet([], false); $headers->shouldReceive('toString') ->zeroOrMoreTimes() @@ -721,7 +721,7 @@ public function testOrderingTextBeforeHtml() $entity = $this->createEntity($headers, $this->createEncoder(), $this->createCache() - ); + ); $entity->setBoundary('xxx'); $entity->setChildren([$htmlChild, $textChild]); @@ -737,7 +737,7 @@ public function testOrderingTextBeforeHtml() 'HTML PART'. "\r\n\r\n--xxx--\r\n", $entity->toString() - ); + ); } public function testOrderingEqualContentTypesMaintainsOriginalOrdering() @@ -793,13 +793,13 @@ public function testUnsettingChildrenRestoresContentType() ->with('multipart/alternative'); $cType->shouldReceive('setFieldBodyModel') ->zeroOrMoreTimes() - ->with(\Mockery::not('multipart/alternative', 'image/jpeg')); + ->with(Mockery::not('multipart/alternative', 'image/jpeg')); $entity = $this->createEntity($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $entity->setContentType('image/jpeg'); $entity->setChildren([$child]); @@ -816,16 +816,16 @@ public function testBodyIsReadFromCacheWhenUsingToStringIfPresent() $cache = $this->createCache(false); $cache->shouldReceive('hasKey') ->once() - ->with(\Mockery::any(), 'body') + ->with(Mockery::any(), 'body') ->andReturn(true); $cache->shouldReceive('getString') ->once() - ->with(\Mockery::any(), 'body') + ->with(Mockery::any(), 'body') ->andReturn("\r\ncache\r\ncache!"); $entity = $this->createEntity($headers, $this->createEncoder(), $cache - ); + ); $entity->setBody("blah\r\nblah!"); $this->assertEquals( @@ -833,7 +833,7 @@ public function testBodyIsReadFromCacheWhenUsingToStringIfPresent() "\r\n". "cache\r\ncache!", $entity->toString() - ); + ); } public function testBodyIsAddedToCacheWhenUsingToString() @@ -846,15 +846,15 @@ public function testBodyIsAddedToCacheWhenUsingToString() $cache = $this->createCache(false); $cache->shouldReceive('hasKey') ->once() - ->with(\Mockery::any(), 'body') + ->with(Mockery::any(), 'body') ->andReturn(false); $cache->shouldReceive('setString') ->once() - ->with(\Mockery::any(), 'body', "\r\nblah\r\nblah!", Swift_KeyCache::MODE_WRITE); + ->with(Mockery::any(), 'body', "\r\nblah\r\nblah!", Swift_KeyCache::MODE_WRITE); $entity = $this->createEntity($headers, $this->createEncoder(), $cache - ); + ); $entity->setBody("blah\r\nblah!"); $entity->toString(); @@ -870,7 +870,7 @@ public function testBodyIsClearedFromCacheIfNewBodySet() $cache = $this->createCache(false); $entity = $this->createEntity($headers, $this->createEncoder(), $cache - ); + ); $entity->setBody("blah\r\nblah!"); $entity->toString(); @@ -878,7 +878,7 @@ public function testBodyIsClearedFromCacheIfNewBodySet() // We set the expectation at this point because we only care what happens when calling setBody() $cache->shouldReceive('clearKey') ->once() - ->with(\Mockery::any(), 'body'); + ->with(Mockery::any(), 'body'); $entity->setBody("new\r\nnew!"); } @@ -893,7 +893,7 @@ public function testBodyIsNotClearedFromCacheIfSameBodySet() $cache = $this->createCache(false); $entity = $this->createEntity($headers, $this->createEncoder(), $cache - ); + ); $entity->setBody("blah\r\nblah!"); $entity->toString(); @@ -916,7 +916,7 @@ public function testBodyIsClearedFromCacheIfNewEncoderSet() $otherEncoder = $this->createEncoder(); $entity = $this->createEntity($headers, $this->createEncoder(), $cache - ); + ); $entity->setBody("blah\r\nblah!"); $entity->toString(); @@ -924,7 +924,7 @@ public function testBodyIsClearedFromCacheIfNewEncoderSet() // We set the expectation at this point because we only care what happens when calling setEncoder() $cache->shouldReceive('clearKey') ->once() - ->with(\Mockery::any(), 'body'); + ->with(Mockery::any(), 'body'); $entity->setEncoder($otherEncoder); } @@ -935,15 +935,15 @@ public function testBodyIsReadFromCacheWhenUsingToByteStreamIfPresent() $cache = $this->createCache(false); $cache->shouldReceive('hasKey') ->once() - ->with(\Mockery::any(), 'body') + ->with(Mockery::any(), 'body') ->andReturn(true); $cache->shouldReceive('exportToByteStream') ->once() - ->with(\Mockery::any(), 'body', $is); + ->with(Mockery::any(), 'body', $is); $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $cache - ); + ); $entity->setBody('foo'); $entity->toByteStream($is); @@ -955,15 +955,15 @@ public function testBodyIsAddedToCacheWhenUsingToByteStream() $cache = $this->createCache(false); $cache->shouldReceive('hasKey') ->once() - ->with(\Mockery::any(), 'body') + ->with(Mockery::any(), 'body') ->andReturn(false); $cache->shouldReceive('getInputByteStream') ->once() - ->with(\Mockery::any(), 'body'); + ->with(Mockery::any(), 'body'); $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $cache - ); + ); $entity->setBody('foo'); $entity->toByteStream($is); @@ -973,7 +973,7 @@ public function testFluidInterface() { $entity = $this->createEntity($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertSame($entity, $entity @@ -985,7 +985,7 @@ public function testFluidInterface() ->setBody('xx') ->setBoundary('xyz') ->setChildren([]) - ); + ); } abstract protected function createEntity($headers, $encoder, $cache); diff --git a/tests/unit/Swift/Mime/AttachmentTest.php b/tests/unit/Swift/Mime/AttachmentTest.php index da7f82474..75416ae93 100644 --- a/tests/unit/Swift/Mime/AttachmentTest.php +++ b/tests/unit/Swift/Mime/AttachmentTest.php @@ -6,10 +6,10 @@ public function testNestingLevelIsAttachment() { $attachment = $this->createAttachment($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals( Swift_Mime_SimpleMimeEntity::LEVEL_MIXED, $attachment->getNestingLevel() - ); + ); } public function testDispositionIsReturnedFromHeader() @@ -21,7 +21,7 @@ public function testDispositionIsReturnedFromHeader() $attachment = $this->createAttachment($this->createHeaderSet([ 'Content-Disposition' => $disposition, ]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('attachment', $attachment->getDisposition()); } @@ -29,7 +29,7 @@ public function testDispositionIsSetInHeader() { $disposition = $this->createHeader('Content-Disposition', 'attachment', [], false - ); + ); $disposition->shouldReceive('setFieldBodyModel') ->once() ->with('inline'); @@ -39,7 +39,7 @@ public function testDispositionIsSetInHeader() $attachment = $this->createAttachment($this->createHeaderSet([ 'Content-Disposition' => $disposition, ]), $this->createEncoder(), $this->createCache() - ); + ); $attachment->setDisposition('inline'); } @@ -54,7 +54,7 @@ public function testDispositionIsAddedIfNonePresent() $attachment = $this->createAttachment($headers, $this->createEncoder(), $this->createCache() - ); + ); $attachment->setDisposition('inline'); } @@ -69,14 +69,14 @@ public function testDispositionIsAutoDefaultedToAttachment() $attachment = $this->createAttachment($headers, $this->createEncoder(), $this->createCache() - ); + ); } public function testDefaultContentTypeInitializedToOctetStream() { $cType = $this->createHeader('Content-Type', '', [], false - ); + ); $cType->shouldReceive('setFieldBodyModel') ->once() ->with('application/octet-stream'); @@ -86,7 +86,7 @@ public function testDefaultContentTypeInitializedToOctetStream() $attachment = $this->createAttachment($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); } public function testFilenameIsReturnedFromHeader() @@ -96,11 +96,11 @@ public function testFilenameIsReturnedFromHeader() $disposition = $this->createHeader('Content-Disposition', 'attachment', ['filename' => 'foo.txt'] - ); + ); $attachment = $this->createAttachment($this->createHeaderSet([ 'Content-Disposition' => $disposition, ]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('foo.txt', $attachment->getFilename()); } @@ -108,7 +108,7 @@ public function testFilenameIsSetInHeader() { $disposition = $this->createHeader('Content-Disposition', 'attachment', ['filename' => 'foo.txt'], false - ); + ); $disposition->shouldReceive('setParameter') ->once() ->with('filename', 'bar.txt'); @@ -118,7 +118,7 @@ public function testFilenameIsSetInHeader() $attachment = $this->createAttachment($this->createHeaderSet([ 'Content-Disposition' => $disposition, ]), $this->createEncoder(), $this->createCache() - ); + ); $attachment->setFilename('bar.txt'); } @@ -130,7 +130,7 @@ public function testSettingFilenameSetsNameInContentType() $cType = $this->createHeader('Content-Type', 'text/plain', [], false - ); + ); $cType->shouldReceive('setParameter') ->once() ->with('name', 'bar.txt'); @@ -140,7 +140,7 @@ public function testSettingFilenameSetsNameInContentType() $attachment = $this->createAttachment($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $attachment->setFilename('bar.txt'); } @@ -151,11 +151,11 @@ public function testSizeIsReturnedFromHeader() $disposition = $this->createHeader('Content-Disposition', 'attachment', ['size' => 1234] - ); + ); $attachment = $this->createAttachment($this->createHeaderSet([ 'Content-Disposition' => $disposition, ]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals(1234, $attachment->getSize()); } @@ -163,7 +163,7 @@ public function testSizeIsSetInHeader() { $disposition = $this->createHeader('Content-Disposition', 'attachment', [], false - ); + ); $disposition->shouldReceive('setParameter') ->once() ->with('size', 12345); @@ -173,7 +173,7 @@ public function testSizeIsSetInHeader() $attachment = $this->createAttachment($this->createHeaderSet([ 'Content-Disposition' => $disposition, ]), $this->createEncoder(), $this->createCache() - ); + ); $attachment->setSize(12345); } @@ -182,7 +182,7 @@ public function testFilnameCanBeReadFromFileStream() $file = $this->createFileStream('/bar/file.ext', ''); $disposition = $this->createHeader('Content-Disposition', 'attachment', ['filename' => 'foo.txt'], false - ); + ); $disposition->shouldReceive('setParameter') ->once() ->with('filename', 'file.ext'); @@ -190,7 +190,7 @@ public function testFilnameCanBeReadFromFileStream() $attachment = $this->createAttachment($this->createHeaderSet([ 'Content-Disposition' => $disposition, ]), $this->createEncoder(), $this->createCache() - ); + ); $attachment->setFile($file); } @@ -199,7 +199,7 @@ public function testContentTypeCanBeSetViaSetFile() $file = $this->createFileStream('/bar/file.ext', ''); $disposition = $this->createHeader('Content-Disposition', 'attachment', ['filename' => 'foo.txt'], false - ); + ); $disposition->shouldReceive('setParameter') ->once() ->with('filename', 'file.ext'); @@ -218,7 +218,7 @@ public function testContentTypeCanBeSetViaSetFile() $attachment = $this->createAttachment($headers, $this->createEncoder(), $this->createCache() - ); + ); $attachment->setFile($file, 'text/html'); } @@ -227,7 +227,7 @@ public function XtestContentTypeCanBeLookedUpFromCommonListIfNotProvided() $file = $this->createFileStream('/bar/file.zip', ''); $disposition = $this->createHeader('Content-Disposition', 'attachment', ['filename' => 'foo.zip'], false - ); + ); $disposition->shouldReceive('setParameter') ->once() ->with('filename', 'file.zip'); @@ -246,7 +246,7 @@ public function XtestContentTypeCanBeLookedUpFromCommonListIfNotProvided() $attachment = $this->createAttachment($headers, $this->createEncoder(), $this->createCache(), ['zip' => 'application/zip', 'txt' => 'text/plain'] - ); + ); $attachment->setFile($file); } @@ -255,7 +255,7 @@ public function testDataCanBeReadFromFile() $file = $this->createFileStream('/foo/file.ext', ''); $attachment = $this->createAttachment($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $attachment->setFile($file); $this->assertEquals('', $attachment->getBody()); } @@ -264,7 +264,7 @@ public function testFluidInterface() { $attachment = $this->createAttachment($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertSame($attachment, $attachment ->setContentType('application/pdf') @@ -279,7 +279,7 @@ public function testFluidInterface() ->setFilename('afile.txt') ->setSize(123) ->setFile($this->createFileStream('foo.txt', '')) - ); + ); } protected function createEntity($headers, $encoder, $cache) diff --git a/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php b/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php index 3da7b4f04..7048289cf 100644 --- a/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php +++ b/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php @@ -1,6 +1,6 @@ encoder->encodeByteStream($os, $is); $this->assertMatchesRegularExpression('~^[a-zA-Z0-9/\+]{2}==$~', $collection->content, '%s: A single byte should have 2 bytes of padding' - ); + ); } for ($i = 0; $i < 30; ++$i) { @@ -111,7 +111,7 @@ public function testPadLength() $this->encoder->encodeByteStream($os, $is); $this->assertMatchesRegularExpression('~^[a-zA-Z0-9/\+]{3}=$~', $collection->content, '%s: Two bytes should have 1 byte of padding' - ); + ); } for ($i = 0; $i < 30; ++$i) { @@ -132,7 +132,7 @@ public function testPadLength() $this->encoder->encodeByteStream($os, $is); $this->assertMatchesRegularExpression('~^[a-zA-Z0-9/\+]{4}$~', $collection->content, '%s: Three bytes should have no padding' - ); + ); } } @@ -153,25 +153,25 @@ public function testMaximumLineLengthIs76Characters() ->andReturnUsing($collection); $os->shouldReceive('read') ->once() - ->andReturn('abcdefghijkl'); //12 + ->andReturn('abcdefghijkl'); // 12 $os->shouldReceive('read') ->once() - ->andReturn('mnopqrstuvwx'); //24 + ->andReturn('mnopqrstuvwx'); // 24 $os->shouldReceive('read') ->once() - ->andReturn('yzabc1234567'); //36 + ->andReturn('yzabc1234567'); // 36 $os->shouldReceive('read') ->once() - ->andReturn('890ABCDEFGHI'); //48 + ->andReturn('890ABCDEFGHI'); // 48 $os->shouldReceive('read') ->once() - ->andReturn('JKLMNOPQRSTU'); //60 + ->andReturn('JKLMNOPQRSTU'); // 60 $os->shouldReceive('read') ->once() - ->andReturn('VWXYZ1234567'); //72 + ->andReturn('VWXYZ1234567'); // 72 $os->shouldReceive('read') ->once() - ->andReturn('abcdefghijkl'); //84 + ->andReturn('abcdefghijkl'); // 84 $os->shouldReceive('read') ->zeroOrMoreTimes() ->andReturn(false); @@ -181,7 +181,7 @@ public function testMaximumLineLengthIs76Characters() "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFS\r\n". 'U1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts', $collection->content - ); + ); } public function testMaximumLineLengthCanBeDifferent() @@ -195,25 +195,25 @@ public function testMaximumLineLengthCanBeDifferent() ->andReturnUsing($collection); $os->shouldReceive('read') ->once() - ->andReturn('abcdefghijkl'); //12 + ->andReturn('abcdefghijkl'); // 12 $os->shouldReceive('read') ->once() - ->andReturn('mnopqrstuvwx'); //24 + ->andReturn('mnopqrstuvwx'); // 24 $os->shouldReceive('read') ->once() - ->andReturn('yzabc1234567'); //36 + ->andReturn('yzabc1234567'); // 36 $os->shouldReceive('read') ->once() - ->andReturn('890ABCDEFGHI'); //48 + ->andReturn('890ABCDEFGHI'); // 48 $os->shouldReceive('read') ->once() - ->andReturn('JKLMNOPQRSTU'); //60 + ->andReturn('JKLMNOPQRSTU'); // 60 $os->shouldReceive('read') ->once() - ->andReturn('VWXYZ1234567'); //72 + ->andReturn('VWXYZ1234567'); // 72 $os->shouldReceive('read') ->once() - ->andReturn('abcdefghijkl'); //84 + ->andReturn('abcdefghijkl'); // 84 $os->shouldReceive('read') ->zeroOrMoreTimes() ->andReturn(false); @@ -224,7 +224,7 @@ public function testMaximumLineLengthCanBeDifferent() "kwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3YWJj\r\n". 'ZGVmZ2hpamts', $collection->content - ); + ); } public function testMaximumLineLengthIsNeverMoreThan76Chars() @@ -238,25 +238,25 @@ public function testMaximumLineLengthIsNeverMoreThan76Chars() ->andReturnUsing($collection); $os->shouldReceive('read') ->once() - ->andReturn('abcdefghijkl'); //12 + ->andReturn('abcdefghijkl'); // 12 $os->shouldReceive('read') ->once() - ->andReturn('mnopqrstuvwx'); //24 + ->andReturn('mnopqrstuvwx'); // 24 $os->shouldReceive('read') ->once() - ->andReturn('yzabc1234567'); //36 + ->andReturn('yzabc1234567'); // 36 $os->shouldReceive('read') ->once() - ->andReturn('890ABCDEFGHI'); //48 + ->andReturn('890ABCDEFGHI'); // 48 $os->shouldReceive('read') ->once() - ->andReturn('JKLMNOPQRSTU'); //60 + ->andReturn('JKLMNOPQRSTU'); // 60 $os->shouldReceive('read') ->once() - ->andReturn('VWXYZ1234567'); //72 + ->andReturn('VWXYZ1234567'); // 72 $os->shouldReceive('read') ->once() - ->andReturn('abcdefghijkl'); //84 + ->andReturn('abcdefghijkl'); // 84 $os->shouldReceive('read') ->zeroOrMoreTimes() ->andReturn(false); @@ -266,7 +266,7 @@ public function testMaximumLineLengthIsNeverMoreThan76Chars() "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFS\r\n". 'U1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts', $collection->content - ); + ); } public function testFirstLineLengthCanBeDifferent() @@ -280,25 +280,25 @@ public function testFirstLineLengthCanBeDifferent() ->andReturnUsing($collection); $os->shouldReceive('read') ->once() - ->andReturn('abcdefghijkl'); //12 + ->andReturn('abcdefghijkl'); // 12 $os->shouldReceive('read') ->once() - ->andReturn('mnopqrstuvwx'); //24 + ->andReturn('mnopqrstuvwx'); // 24 $os->shouldReceive('read') ->once() - ->andReturn('yzabc1234567'); //36 + ->andReturn('yzabc1234567'); // 36 $os->shouldReceive('read') ->once() - ->andReturn('890ABCDEFGHI'); //48 + ->andReturn('890ABCDEFGHI'); // 48 $os->shouldReceive('read') ->once() - ->andReturn('JKLMNOPQRSTU'); //60 + ->andReturn('JKLMNOPQRSTU'); // 60 $os->shouldReceive('read') ->once() - ->andReturn('VWXYZ1234567'); //72 + ->andReturn('VWXYZ1234567'); // 72 $os->shouldReceive('read') ->once() - ->andReturn('abcdefghijkl'); //84 + ->andReturn('abcdefghijkl'); // 84 $os->shouldReceive('read') ->zeroOrMoreTimes() ->andReturn(false); @@ -308,7 +308,7 @@ public function testFirstLineLengthCanBeDifferent() "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDR\r\n". 'EVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts', $collection->content - ); + ); } private function createOutputByteStream($stub = false) diff --git a/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php b/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php index 270d02c3c..ced94c801 100644 --- a/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php +++ b/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php @@ -1,6 +1,6 @@ assertEquals( - 'a a a a a a a a a a a a a a a a a a a a a a a a a '."\r\n".//50 * - 'a a a a a a a a a a a a a a a a a a a a a a a a a', //99 + 'a a a a a a a a a a a a a a a a a a a a a a a a a '."\r\n".// 50 * + 'a a a a a a a a a a a a a a a a a a a a a a a a a', // 99 $encoder->encodeString($input, 0, 50), '%s: Lines should be wrapped at 50 chars' - ); + ); } public function testLineLengthCanBeSpecifiedInByteStream() @@ -89,7 +89,7 @@ public function testLineLengthCanBeSpecifiedInByteStream() $this->assertEquals( str_repeat('a ', 25)."\r\n".str_repeat('a ', 25), $collection->content - ); + ); } public function testencodeStringGeneratesCorrectCrlf() @@ -97,19 +97,19 @@ public function testencodeStringGeneratesCorrectCrlf() $encoder = $this->getEncoder('7bit', true); $this->assertEquals("a\r\nb", $encoder->encodeString("a\rb"), '%s: Line endings should be standardized' - ); + ); $this->assertEquals("a\r\nb", $encoder->encodeString("a\nb"), '%s: Line endings should be standardized' - ); + ); $this->assertEquals("a\r\n\r\nb", $encoder->encodeString("a\n\rb"), '%s: Line endings should be standardized' - ); + ); $this->assertEquals("a\r\n\r\nb", $encoder->encodeString("a\r\rb"), '%s: Line endings should be standardized' - ); + ); $this->assertEquals("a\r\n\r\nb", $encoder->encodeString("a\n\nb"), '%s: Line endings should be standardized' - ); + ); } public function crlfProvider() diff --git a/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php b/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php index f5019b7ae..31afbfddb 100644 --- a/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php +++ b/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php @@ -1,12 +1,12 @@ createCharacterStream(true) - ); + ); $this->assertEquals('quoted-printable', $encoder->getName()); } @@ -91,10 +91,10 @@ public function testLinearWhiteSpaceAtLineEndingIsEncoded() intermediate transport agents. */ - $HT = \chr(0x09); //9 - $SPACE = \chr(0x20); //32 + $HT = \chr(0x09); // 9 + $SPACE = \chr(0x20); // 32 - //HT + // HT $os = $this->createOutputByteStream(true); $charStream = $this->createCharacterStream(); $is = $this->createInputByteStream(); @@ -135,7 +135,7 @@ public function testLinearWhiteSpaceAtLineEndingIsEncoded() $this->assertEquals("a\t=09\r\nb", $collection->content); - //SPACE + // SPACE $os = $this->createOutputByteStream(true); $charStream = $this->createCharacterStream(); $is = $this->createInputByteStream(); @@ -458,7 +458,7 @@ public function testFirstLineLengthCanBeDifferent() $this->assertEquals( str_repeat('a', 53)."=\r\n".str_repeat('a', 75)."=\r\n".str_repeat('a', 13), $collection->content - ); + ); } public function testObserverInterfaceCanChangeCharset() @@ -488,7 +488,7 @@ public function testTextIsPreWrapped() $this->assertEquals( $input, $os->read(PHP_INT_MAX) - ); + ); } private function createCharacterStream($stub = false) diff --git a/tests/unit/Swift/Mime/EmbeddedFileTest.php b/tests/unit/Swift/Mime/EmbeddedFileTest.php index 5476fad86..35928951d 100644 --- a/tests/unit/Swift/Mime/EmbeddedFileTest.php +++ b/tests/unit/Swift/Mime/EmbeddedFileTest.php @@ -12,10 +12,10 @@ public function testNestingLevelIsEmbedded() { $file = $this->createEmbeddedFile($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals( Swift_Mime_SimpleMimeEntity::LEVEL_RELATED, $file->getNestingLevel() - ); + ); } public function testIdIsAutoGenerated() @@ -23,11 +23,11 @@ public function testIdIsAutoGenerated() $headers = $this->createHeaderSet([], false); $headers->shouldReceive('addIdHeader') ->once() - ->with('Content-ID', \Mockery::pattern('/^.*?@.*?$/D')); + ->with('Content-ID', Mockery::pattern('/^.*?@.*?$/D')); $file = $this->createEmbeddedFile($headers, $this->createEncoder(), $this->createCache() - ); + ); } public function testDefaultDispositionIsInline() @@ -41,7 +41,7 @@ public function testDefaultDispositionIsInline() $file = $this->createEmbeddedFile($headers, $this->createEncoder(), $this->createCache() - ); + ); } protected function createAttachment($headers, $encoder, $cache, $mimeTypes = []) diff --git a/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php b/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php index 0db540732..f0a3a0c15 100644 --- a/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php +++ b/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php @@ -1,8 +1,8 @@ createEncoder( $this->createCharacterStream(true) - ); + ); $this->assertEquals('Q', $encoder->getName()); } @@ -29,7 +29,7 @@ public function testSpaceAndTabNeverAppear() $encoder = $this->createEncoder($charStream); $this->assertDoesNotMatchRegularExpression('~[ \t]~', $encoder->encodeString("a \t b"), '%s: encoded-words in headers cannot contain LWSP as per RFC 2047.' - ); + ); } public function testSpaceIsRepresentedByUnderscore() @@ -60,7 +60,7 @@ public function testSpaceIsRepresentedByUnderscore() $encoder = $this->createEncoder($charStream); $this->assertEquals('a_b', $encoder->encodeString('a b'), '%s: Spaces can be represented by more readable underscores as per RFC 2047.' - ); + ); } public function testEqualsAndQuestionAndUnderscoreAreEncoded() @@ -89,7 +89,7 @@ public function testEqualsAndQuestionAndUnderscoreAreEncoded() $encoder = $this->createEncoder($charStream); $this->assertEquals('=3D=3F=5F', $encoder->encodeString('=?_'), '%s: Chars =, ? and _ (underscore) may not appear as per RFC 2047.' - ); + ); } public function testParensAndQuotesAreEncoded() @@ -116,7 +116,7 @@ public function testParensAndQuotesAreEncoded() $encoder = $this->createEncoder($charStream); $this->assertEquals('=28=22=29', $encoder->encodeString('(")'), '%s: Chars (, " (DQUOTE) and ) may not appear as per RFC 2047.' - ); + ); } public function testOnlyCharactersAllowedInPhrasesAreUsed() @@ -140,7 +140,7 @@ public function testOnlyCharactersAllowedInPhrasesAreUsed() range(\ord('a'), \ord('z')), range(\ord('A'), \ord('Z')), range(\ord('0'), \ord('9')), [\ord('!'), \ord('*'), \ord('+'), \ord('-'), \ord('/')] - ); + ); foreach (range(0x00, 0xFF) as $byte) { $char = pack('C', $byte); @@ -159,16 +159,16 @@ public function testOnlyCharactersAllowedInPhrasesAreUsed() if (\in_array($byte, $allowedBytes)) { $this->assertEquals($char, $encodedChar, '%s: Character '.$char.' should not be encoded.' - ); + ); } elseif (0x20 == $byte) { - //Special case + // Special case $this->assertEquals('_', $encodedChar, '%s: Space character should be replaced.' - ); + ); } else { $this->assertEquals(sprintf('=%02X', $byte), $encodedChar, '%s: Byte '.$byte.' should be encoded.' - ); + ); } } } diff --git a/tests/unit/Swift/Mime/Headers/DateHeaderTest.php b/tests/unit/Swift/Mime/Headers/DateHeaderTest.php index e41930618..99311436e 100644 --- a/tests/unit/Swift/Mime/Headers/DateHeaderTest.php +++ b/tests/unit/Swift/Mime/Headers/DateHeaderTest.php @@ -1,6 +1,6 @@ setDateTime($dateTime); $this->assertEquals("Date: Sat, 01 Jan 2000 12:00:00 +0100\r\n", $header->toString() - ); + ); } private function getHeader($name) diff --git a/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php b/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php index 00157f65c..cf325447e 100644 --- a/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php +++ b/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php @@ -2,7 +2,7 @@ use Egulias\EmailValidator\EmailValidator; -class Swift_Mime_Headers_IdentificationHeaderTest extends \PHPUnit\Framework\TestCase +class Swift_Mime_Headers_IdentificationHeaderTest extends PHPUnit\Framework\TestCase { public function testTypeIsIdHeader() { @@ -101,7 +101,7 @@ public function testIdLeftCanBeDotAtom() public function testInvalidIdLeftThrowsException() { - $this->expectException(\Swift_RfcComplianceException::class); + $this->expectException(Swift_RfcComplianceException::class); $this->expectExceptionMessage('Invalid ID given '); $header = $this->getHeader('References'); @@ -142,7 +142,7 @@ public function testIdRigthIsIdnEncoded() public function testInvalidIdRightThrowsException() { - $this->expectException(\Swift_RfcComplianceException::class); + $this->expectException(Swift_RfcComplianceException::class); $this->expectExceptionMessage('Invalid ID given '); $header = $this->getHeader('References'); @@ -151,7 +151,7 @@ public function testInvalidIdRightThrowsException() public function testMissingAtSignThrowsException() { - $this->expectException(\Swift_RfcComplianceException::class); + $this->expectException(Swift_RfcComplianceException::class); $this->expectExceptionMessage('Invalid ID given '); /* -- RFC 2822, 3.6.4. diff --git a/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php b/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php index 815818854..d087eb1e7 100644 --- a/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php +++ b/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php @@ -2,7 +2,7 @@ use Egulias\EmailValidator\EmailValidator; -class Swift_Mime_Headers_MailboxHeaderTest extends \SwiftMailerTestCase +class Swift_Mime_Headers_MailboxHeaderTest extends SwiftMailerTestCase { /* -- RFC 2822, 3.6.2 for all tests. */ @@ -21,7 +21,7 @@ public function testMailboxIsSetForAddress() $header->setAddresses('chris@swiftmailer.org'); $this->assertEquals(['chris@swiftmailer.org'], $header->getNameAddressStrings() - ); + ); } public function testMailboxIsRenderedForNameAddress() @@ -30,7 +30,7 @@ public function testMailboxIsRenderedForNameAddress() $header->setNameAddresses(['chris@swiftmailer.org' => 'Chris Corbyn']); $this->assertEquals( ['Chris Corbyn '], $header->getNameAddressStrings() - ); + ); } public function testAddressCanBeReturnedForAddress() @@ -56,7 +56,7 @@ public function testQuotesInNameAreQuoted() $this->assertEquals( ['"Chris Corbyn, \"DHE\"" '], $header->getNameAddressStrings() - ); + ); } public function testEscapeCharsInNameAreQuoted() @@ -68,7 +68,7 @@ public function testEscapeCharsInNameAreQuoted() $this->assertEquals( ['"Chris Corbyn, \\\\escaped\\\\" '], $header->getNameAddressStrings() - ); + ); } public function testUtf8CharsInDomainAreIdnEncoded() @@ -80,12 +80,12 @@ public function testUtf8CharsInDomainAreIdnEncoded() $this->assertEquals( ['Chris Corbyn '], $header->getNameAddressStrings() - ); + ); } public function testUtf8CharsInLocalPartThrows() { - $this->expectException(\Swift_AddressEncoderException::class); + $this->expectException(Swift_AddressEncoderException::class); $header = $this->getHeader('From'); $header->setNameAddresses([ @@ -103,7 +103,7 @@ public function testUtf8CharsInEmail() $this->assertEquals( ['Chris Corbyn '], $header->getNameAddressStrings() - ); + ); } public function testGetMailboxesReturnsNameValuePairs() @@ -114,7 +114,7 @@ public function testGetMailboxesReturnsNameValuePairs() ]); $this->assertEquals( ['chris@swiftmailer.org' => 'Chris Corbyn, DHE'], $header->getNameAddresses() - ); + ); } public function testMultipleAddressesCanBeSetAndFetched() @@ -126,7 +126,7 @@ public function testMultipleAddressesCanBeSetAndFetched() $this->assertEquals( ['chris@swiftmailer.org', 'mark@swiftmailer.org'], $header->getAddresses() - ); + ); } public function testMultipleAddressesAsMailboxes() @@ -138,7 +138,7 @@ public function testMultipleAddressesAsMailboxes() $this->assertEquals( ['chris@swiftmailer.org' => null, 'mark@swiftmailer.org' => null], $header->getNameAddresses() - ); + ); } public function testMultipleAddressesAsMailboxStrings() @@ -150,7 +150,7 @@ public function testMultipleAddressesAsMailboxStrings() $this->assertEquals( ['chris@swiftmailer.org', 'mark@swiftmailer.org'], $header->getNameAddressStrings() - ); + ); } public function testMultipleNamedMailboxesReturnsMultipleAddresses() @@ -163,7 +163,7 @@ public function testMultipleNamedMailboxesReturnsMultipleAddresses() $this->assertEquals( ['chris@swiftmailer.org', 'mark@swiftmailer.org'], $header->getAddresses() - ); + ); } public function testMultipleNamedMailboxesReturnsMultipleMailboxes() @@ -178,7 +178,7 @@ public function testMultipleNamedMailboxesReturnsMultipleMailboxes() 'mark@swiftmailer.org' => 'Mark Corbyn', ], $header->getNameAddresses() - ); + ); } public function testMultipleMailboxesProducesMultipleMailboxStrings() @@ -193,7 +193,7 @@ public function testMultipleMailboxesProducesMultipleMailboxStrings() 'Mark Corbyn ', ], $header->getNameAddressStrings() - ); + ); } public function testSetAddressesOverwritesAnyMailboxes() @@ -207,22 +207,22 @@ public function testSetAddressesOverwritesAnyMailboxes() ['chris@swiftmailer.org' => 'Chris Corbyn', 'mark@swiftmailer.org' => 'Mark Corbyn', ], $header->getNameAddresses() - ); + ); $this->assertEquals( ['chris@swiftmailer.org', 'mark@swiftmailer.org'], $header->getAddresses() - ); + ); $header->setAddresses(['chris@swiftmailer.org', 'mark@swiftmailer.org']); $this->assertEquals( ['chris@swiftmailer.org' => null, 'mark@swiftmailer.org' => null], $header->getNameAddresses() - ); + ); $this->assertEquals( ['chris@swiftmailer.org', 'mark@swiftmailer.org'], $header->getAddresses() - ); + ); } public function testNameIsEncodedIfNonAscii() @@ -232,7 +232,7 @@ public function testNameIsEncodedIfNonAscii() $encoder = $this->getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($name, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($name, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('C=8Frbyn'); $header = $this->getHeader('From', $encoder); @@ -242,7 +242,7 @@ public function testNameIsEncodedIfNonAscii() $this->assertEquals( 'Chris =?'.$this->charset.'?Q?C=8Frbyn?= ', array_shift($addresses) - ); + ); } public function testEncodingLineLengthCalculations() @@ -257,7 +257,7 @@ public function testEncodingLineLengthCalculations() $encoder = $this->getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($name, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($name, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('C=8Frbyn'); $header = $this->getHeader('From', $encoder); @@ -274,7 +274,7 @@ public function testGetValueReturnsMailboxStringValue() ]); $this->assertEquals( 'Chris Corbyn ', $header->getFieldBody() - ); + ); } public function testGetValueReturnsMailboxStringValueForMultipleMailboxes() @@ -287,7 +287,7 @@ public function testGetValueReturnsMailboxStringValueForMultipleMailboxes() $this->assertEquals( 'Chris Corbyn , Mark Corbyn ', $header->getFieldBody() - ); + ); } public function testRemoveAddressesWithSingleValue() @@ -300,7 +300,7 @@ public function testRemoveAddressesWithSingleValue() $header->removeAddresses('chris@swiftmailer.org'); $this->assertEquals(['mark@swiftmailer.org'], $header->getAddresses() - ); + ); } public function testRemoveAddressesWithList() @@ -312,7 +312,7 @@ public function testRemoveAddressesWithList() ]); $header->removeAddresses( ['chris@swiftmailer.org', 'mark@swiftmailer.org'] - ); + ); $this->assertEquals([], $header->getAddresses()); } @@ -341,7 +341,7 @@ public function testToString() 'From: Chris Corbyn , '. 'Mark Corbyn '."\r\n", $header->toString() - ); + ); } private function getHeader($name, $encoder = null, $addressEncoder = null) diff --git a/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php b/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php index c90b05b42..023e7f5f9 100644 --- a/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php +++ b/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php @@ -1,6 +1,6 @@ getHeader('Content-Type', $this->getHeaderEncoder('Q', true), $this->getParameterEncoder(true) - ); + ); $this->assertEquals(Swift_Mime_Header::TYPE_PARAMETERIZED, $header->getFieldType()); } @@ -17,7 +17,7 @@ public function testValueIsReturnedVerbatim() { $header = $this->getHeader('Content-Type', $this->getHeaderEncoder('Q', true), $this->getParameterEncoder(true) - ); + ); $header->setValue('text/plain'); $this->assertEquals('text/plain', $header->getValue()); } @@ -45,7 +45,7 @@ public function testParametersAreAppended() $header = $this->getHeader('Content-Type', $this->getHeaderEncoder('Q', true), $this->getParameterEncoder(true) - ); + ); $header->setValue('text/plain'); $header->setParameters(['charset' => 'utf-8']); $this->assertEquals('text/plain; charset=utf-8', $header->getFieldBody()); @@ -55,12 +55,12 @@ public function testSpaceInParamResultsInQuotedString() { $header = $this->getHeader('Content-Disposition', $this->getHeaderEncoder('Q', true), $this->getParameterEncoder(true) - ); + ); $header->setValue('attachment'); $header->setParameters(['filename' => 'my file.txt']); $this->assertEquals('attachment; filename="my file.txt"', $header->getFieldBody() - ); + ); } public function testLongParamsAreBrokenIntoMultipleAttributeStrings() @@ -97,13 +97,13 @@ public function testLongParamsAreBrokenIntoMultipleAttributeStrings() $encoder = $this->getParameterEncoder(); $encoder->shouldReceive('encodeString') ->once() - ->with($value, \Mockery::any(), 63, \Mockery::any()) + ->with($value, Mockery::any(), 63, Mockery::any()) ->andReturn(str_repeat('a', 63)."\r\n". str_repeat('a', 63)."\r\n".str_repeat('a', 54)); $header = $this->getHeader('Content-Disposition', $this->getHeaderEncoder('Q', true), $encoder - ); + ); $header->setValue('attachment'); $header->setParameters(['filename' => $value]); $header->setMaxLineLength(78); @@ -113,7 +113,7 @@ public function testLongParamsAreBrokenIntoMultipleAttributeStrings() 'filename*1*='.str_repeat('a', 63).";\r\n ". 'filename*2*='.str_repeat('a', 54), $header->getFieldBody() - ); + ); } public function testEncodedParamDataIncludesCharsetAndLanguage() @@ -146,12 +146,12 @@ public function testEncodedParamDataIncludesCharsetAndLanguage() $encoder = $this->getParameterEncoder(); $encoder->shouldReceive('encodeString') ->once() - ->with($value, 12, 62, \Mockery::any()) + ->with($value, 12, 62, Mockery::any()) ->andReturn(str_repeat('a', 20).'%8F'.str_repeat('a', 10)); $header = $this->getHeader('Content-Disposition', $this->getHeaderEncoder('Q', true), $encoder - ); + ); $header->setValue('attachment'); $header->setParameters(['filename' => $value]); $header->setMaxLineLength(78); @@ -160,7 +160,7 @@ public function testEncodedParamDataIncludesCharsetAndLanguage() 'attachment; filename*='.$this->charset."'".$this->lang."'". str_repeat('a', 20).'%8F'.str_repeat('a', 10), $header->getFieldBody() - ); + ); } public function testMultipleEncodedParamLinesAreFormattedCorrectly() @@ -199,13 +199,13 @@ public function testMultipleEncodedParamLinesAreFormattedCorrectly() $encoder = $this->getParameterEncoder(); $encoder->shouldReceive('encodeString') ->once() - ->with($value, 12, 62, \Mockery::any()) + ->with($value, 12, 62, Mockery::any()) ->andReturn(str_repeat('a', 20).'%8F'.str_repeat('a', 28)."\r\n". str_repeat('a', 32)); $header = $this->getHeader('Content-Disposition', $this->getHeaderEncoder('Q', true), $encoder - ); + ); $header->setValue('attachment'); $header->setParameters(['filename' => $value]); $header->setMaxLineLength(78); @@ -215,19 +215,19 @@ public function testMultipleEncodedParamLinesAreFormattedCorrectly() str_repeat('a', 20).'%8F'.str_repeat('a', 28).";\r\n ". 'filename*1*='.str_repeat('a', 32), $header->getFieldBody() - ); + ); } public function testToString() { $header = $this->getHeader('Content-Type', $this->getHeaderEncoder('Q', true), $this->getParameterEncoder(true) - ); + ); $header->setValue('text/html'); $header->setParameters(['charset' => 'utf-8']); $this->assertEquals('Content-Type: text/html; charset=utf-8'."\r\n", $header->toString() - ); + ); } public function testValueCanBeEncodedIfNonAscii() @@ -237,7 +237,7 @@ public function testValueCanBeEncodedIfNonAscii() $encoder = $this->getHeaderEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($value, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('fo=8Fbar'); $header = $this->getHeader('X-Foo', $encoder, $this->getParameterEncoder(true)); @@ -245,7 +245,7 @@ public function testValueCanBeEncodedIfNonAscii() $header->setParameters(['lookslike' => 'foobar']); $this->assertEquals('X-Foo: =?utf-8?Q?fo=8Fbar?=; lookslike=foobar'."\r\n", $header->toString() - ); + ); } public function testValueAndParamCanBeEncodedIfNonAscii() @@ -255,13 +255,13 @@ public function testValueAndParamCanBeEncodedIfNonAscii() $encoder = $this->getHeaderEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($value, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('fo=8Fbar'); $paramEncoder = $this->getParameterEncoder(); $paramEncoder->shouldReceive('encodeString') ->once() - ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($value, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('fo%8Fbar'); $header = $this->getHeader('X-Foo', $encoder, $paramEncoder); @@ -269,7 +269,7 @@ public function testValueAndParamCanBeEncodedIfNonAscii() $header->setParameters(['says' => $value]); $this->assertEquals("X-Foo: =?utf-8?Q?fo=8Fbar?=; says*=utf-8''fo%8Fbar\r\n", $header->toString() - ); + ); } public function testParamsAreEncodedWithEncodedWordsIfNoParamEncoderSet() @@ -279,7 +279,7 @@ public function testParamsAreEncodedWithEncodedWordsIfNoParamEncoderSet() $encoder = $this->getHeaderEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($value, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('fo=8Fbar'); $header = $this->getHeader('X-Foo', $encoder, null); @@ -287,7 +287,7 @@ public function testParamsAreEncodedWithEncodedWordsIfNoParamEncoderSet() $header->setParameters(['says' => $value]); $this->assertEquals("X-Foo: bar; says=\"=?utf-8?Q?fo=8Fbar?=\"\r\n", $header->toString() - ); + ); } public function testLanguageInformationAppearsInEncodedWords() @@ -314,13 +314,13 @@ public function testLanguageInformationAppearsInEncodedWords() $encoder = $this->getHeaderEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($value, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('fo=8Fbar'); $paramEncoder = $this->getParameterEncoder(); $paramEncoder->shouldReceive('encodeString') ->once() - ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($value, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('fo%8Fbar'); $header = $this->getHeader('X-Foo', $encoder, $paramEncoder); @@ -329,14 +329,14 @@ public function testLanguageInformationAppearsInEncodedWords() $header->setParameters(['says' => $value]); $this->assertEquals("X-Foo: =?utf-8*en?Q?fo=8Fbar?=; says*=utf-8'en'fo%8Fbar\r\n", $header->toString() - ); + ); } public function testSetBodyModel() { $header = $this->getHeader('Content-Type', $this->getHeaderEncoder('Q', true), $this->getParameterEncoder(true) - ); + ); $header->setFieldBodyModel('text/html'); $this->assertEquals('text/html', $header->getValue()); } @@ -345,7 +345,7 @@ public function testGetBodyModel() { $header = $this->getHeader('Content-Type', $this->getHeaderEncoder('Q', true), $this->getParameterEncoder(true) - ); + ); $header->setValue('text/plain'); $this->assertEquals('text/plain', $header->getFieldBodyModel()); } @@ -354,19 +354,19 @@ public function testSetParameter() { $header = $this->getHeader('Content-Type', $this->getHeaderEncoder('Q', true), $this->getParameterEncoder(true) - ); + ); $header->setParameters(['charset' => 'utf-8', 'delsp' => 'yes']); $header->setParameter('delsp', 'no'); $this->assertEquals(['charset' => 'utf-8', 'delsp' => 'no'], $header->getParameters() - ); + ); } public function testGetParameter() { $header = $this->getHeader('Content-Type', $this->getHeaderEncoder('Q', true), $this->getParameterEncoder(true) - ); + ); $header->setParameters(['charset' => 'utf-8', 'delsp' => 'yes']); $this->assertEquals('utf-8', $header->getParameter('charset')); } diff --git a/tests/unit/Swift/Mime/Headers/PathHeaderTest.php b/tests/unit/Swift/Mime/Headers/PathHeaderTest.php index bc435c9a1..67727b251 100644 --- a/tests/unit/Swift/Mime/Headers/PathHeaderTest.php +++ b/tests/unit/Swift/Mime/Headers/PathHeaderTest.php @@ -2,7 +2,7 @@ use Egulias\EmailValidator\EmailValidator; -class Swift_Mime_Headers_PathHeaderTest extends \PHPUnit\Framework\TestCase +class Swift_Mime_Headers_PathHeaderTest extends PHPUnit\Framework\TestCase { public function testTypeIsPathHeader() { @@ -19,7 +19,7 @@ public function testSingleAddressCanBeSetAndFetched() public function testAddressMustComplyWithRfc2822() { - $this->expectException(\Exception::class); + $this->expectException(Exception::class); $header = $this->getHeader('Return-Path'); $header->setAddress('chr is@swiftmailer.org'); @@ -49,7 +49,7 @@ public function testAddressIsIdnEncoded() public function testAddressMustBeEncodable() { - $this->expectException(\Swift_AddressEncoderException::class); + $this->expectException(Swift_AddressEncoderException::class); $header = $this->getHeader('Return-Path'); $header->setAddress('chrïs@swiftmailer.org'); @@ -83,7 +83,7 @@ public function testToString() $header->setAddress('chris@swiftmailer.org'); $this->assertEquals('Return-Path: '."\r\n", $header->toString() - ); + ); } private function getHeader($name) diff --git a/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php b/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php index 7e757e5b0..0d3fa4473 100644 --- a/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php +++ b/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php @@ -1,6 +1,6 @@ getHeader('X-Custom-Header', $this->getEncoder('Q', true) - ); + ); $header->setValue($value); - $header->setMaxLineLength(78); //A safe [RFC 2822, 2.2.3] default + $header->setMaxLineLength(78); // A safe [RFC 2822, 2.2.3] default /* X-Custom-Header: The quick brown fox jumped over the fence, he was a very very scary brown fox with a bushy tail */ $this->assertEquals( 'X-Custom-Header: The quick brown fox jumped over the fence, he was a'. - ' very very'."\r\n".//Folding + ' very very'."\r\n".// Folding ' scary brown fox with a bushy tail'."\r\n", $header->toString(), '%s: The header should have been folded at 78th char' - ); + ); } public function testPrintableAsciiOnlyAppearsInHeaders() @@ -80,7 +80,7 @@ public function testPrintableAsciiOnlyAppearsInHeaders() $this->assertMatchesRegularExpression( '~^[^:\x00-\x20\x80-\xFF]+: [^\x80-\xFF\r\n]+\r\n$~s', $header->toString() - ); + ); } public function testEncodedWordsFollowGeneralStructure() @@ -97,7 +97,7 @@ public function testEncodedWordsFollowGeneralStructure() $this->assertMatchesRegularExpression( '~^X-Test: \=?.*?\?.*?\?.*?\?=\r\n$~s', $header->toString() - ); + ); } public function testEncodedWordIncludesCharsetAndEncodingMethodAndText() @@ -115,7 +115,7 @@ public function testEncodedWordIncludesCharsetAndEncodingMethodAndText() $encoder = $this->getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($nonAsciiChar, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($nonAsciiChar, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('=8F'); $header = $this->getHeader('X-Test', $encoder); @@ -123,15 +123,15 @@ public function testEncodedWordIncludesCharsetAndEncodingMethodAndText() $this->assertEquals( 'X-Test: =?'.$this->charset.'?Q?=8F?='."\r\n", $header->toString() - ); + ); } public function testEncodedWordsAreUsedToEncodedNonPrintableAscii() { - //SPACE and TAB permitted + // SPACE and TAB permitted $nonPrintableBytes = array_merge( range(0x00, 0x08), range(0x10, 0x19), [0x7F] - ); + ); foreach ($nonPrintableBytes as $byte) { $char = pack('C', $byte); @@ -140,7 +140,7 @@ public function testEncodedWordsAreUsedToEncodedNonPrintableAscii() $encoder = $this->getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($char, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($char, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($encodedChar); $header = $this->getHeader('X-A', $encoder); @@ -149,7 +149,7 @@ public function testEncodedWordsAreUsedToEncodedNonPrintableAscii() $this->assertEquals( 'X-A: =?'.$this->charset.'?Q?'.$encodedChar.'?='."\r\n", $header->toString(), '%s: Non-printable ascii should be encoded' - ); + ); } } @@ -162,7 +162,7 @@ public function testEncodedWordsAreUsedToEncode8BitOctets() $encoder = $this->getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($char, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($char, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($encodedChar); $header = $this->getHeader('X-A', $encoder); @@ -171,7 +171,7 @@ public function testEncodedWordsAreUsedToEncode8BitOctets() $this->assertEquals( 'X-A: =?'.$this->charset.'?Q?'.$encodedChar.'?='."\r\n", $header->toString(), '%s: 8-bit octets should be encoded' - ); + ); } } @@ -193,19 +193,19 @@ public function testEncodedWordsAreNoMoreThan75CharsPerLine() $encoder = $this->getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($nonAsciiChar, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($nonAsciiChar, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('=8F'); - //Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 - //Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 + // Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 + // Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 - //* X-Test: is 8 chars + // * X-Test: is 8 chars $header = $this->getHeader('X-Test', $encoder); $header->setValue($nonAsciiChar); $this->assertEquals( 'X-Test: =?'.$this->charset.'?Q?=8F?='."\r\n", $header->toString() - ); + ); } public function testFWSPIsUsedWhenEncoderReturnsMultipleLines() @@ -216,20 +216,20 @@ public function testFWSPIsUsedWhenEncoderReturnsMultipleLines() be used. */ - //Note the Mock does NOT return 8F encoded, the 8F merely triggers + // Note the Mock does NOT return 8F encoded, the 8F merely triggers // encoding for the sake of testing $nonAsciiChar = pack('C', 0x8F); $encoder = $this->getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($nonAsciiChar, 8, 63, \Mockery::any()) + ->with($nonAsciiChar, 8, 63, Mockery::any()) ->andReturn('line_one_here'."\r\n".'line_two_here'); - //Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 - //Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 + // Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 + // Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 - //* X-Test: is 8 chars + // * X-Test: is 8 chars $header = $this->getHeader('X-Test', $encoder); $header->setValue($nonAsciiChar); @@ -237,7 +237,7 @@ public function testFWSPIsUsedWhenEncoderReturnsMultipleLines() 'X-Test: =?'.$this->charset.'?Q?line_one_here?='."\r\n". ' =?'.$this->charset.'?Q?line_two_here?='."\r\n", $header->toString() - ); + ); } public function testAdjacentWordsAreEncodedTogether() @@ -255,7 +255,7 @@ public function testAdjacentWordsAreEncodedTogether() 'encoded-word'. */ - //It would be valid to encode all words needed, however it's probably + // It would be valid to encode all words needed, however it's probably // easiest to encode the longest amount required at a time $word = 'w'.pack('C', 0x8F).'rd'; @@ -265,11 +265,11 @@ public function testAdjacentWordsAreEncodedTogether() $encoder = $this->getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($word.' '.$word, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($word.' '.$word, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('w=8Frd_w=8Frd'); $encoder->shouldReceive('encodeString') ->once() - ->with($word, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($word, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('w=8Frd'); $header = $this->getHeader('X-Test', $encoder); @@ -281,7 +281,7 @@ public function testAdjacentWordsAreEncodedTogether() 'w=8Frd_w=8Frd?= then end =?'.$this->charset.'?Q?'. 'w=8Frd?='."\r\n", $headerString, '%s: Adjacent encoded words should appear grouped with WSP encoded' - ); + ); } public function testLanguageInformationAppearsInEncodedWords() @@ -308,7 +308,7 @@ public function testLanguageInformationAppearsInEncodedWords() $encoder = $this->getEncoder('Q'); $encoder->shouldReceive('encodeString') ->once() - ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->with($value, Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn('fo=8Fbar'); $header = $this->getHeader('Subject', $encoder); @@ -316,7 +316,7 @@ public function testLanguageInformationAppearsInEncodedWords() $header->setValue($value); $this->assertEquals("Subject: =?utf-8*en?Q?fo=8Fbar?=\r\n", $header->toString() - ); + ); } public function testSetBodyModel() diff --git a/tests/unit/Swift/Mime/IdGeneratorTest.php b/tests/unit/Swift/Mime/IdGeneratorTest.php index 2c672e2d1..c744d4fca 100644 --- a/tests/unit/Swift/Mime/IdGeneratorTest.php +++ b/tests/unit/Swift/Mime/IdGeneratorTest.php @@ -3,7 +3,7 @@ use Egulias\EmailValidator\EmailValidator; use Egulias\EmailValidator\Validation\RFCValidation; -class Swift_Mime_IdGeneratorTest extends \PHPUnit\Framework\TestCase +class Swift_Mime_IdGeneratorTest extends PHPUnit\Framework\TestCase { protected $emailValidator; protected $originalServerName; diff --git a/tests/unit/Swift/Mime/MimePartTest.php b/tests/unit/Swift/Mime/MimePartTest.php index 028e5f453..1b53eb541 100644 --- a/tests/unit/Swift/Mime/MimePartTest.php +++ b/tests/unit/Swift/Mime/MimePartTest.php @@ -6,10 +6,10 @@ public function testNestingLevelIsSubpart() { $part = $this->createMimePart($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals( Swift_Mime_SimpleMimeEntity::LEVEL_ALTERNATIVE, $part->getNestingLevel() - ); + ); } public function testCharsetIsReturnedFromHeader() @@ -28,11 +28,11 @@ public function testCharsetIsReturnedFromHeader() $cType = $this->createHeader('Content-Type', 'text/plain', ['charset' => 'iso-8859-1'] - ); + ); $part = $this->createMimePart($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('iso-8859-1', $part->getCharset()); } @@ -40,13 +40,13 @@ public function testCharsetIsSetInHeader() { $cType = $this->createHeader('Content-Type', 'text/plain', ['charset' => 'iso-8859-1'], false - ); + ); $cType->shouldReceive('setParameter')->once()->with('charset', 'utf-8'); $part = $this->createMimePart($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $part->setCharset('utf-8'); } @@ -54,13 +54,13 @@ public function testCharsetIsSetInHeaderIfPassedToSetBody() { $cType = $this->createHeader('Content-Type', 'text/plain', ['charset' => 'iso-8859-1'], false - ); + ); $cType->shouldReceive('setParameter')->once()->with('charset', 'utf-8'); $part = $this->createMimePart($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $part->setBody('', 'text/plian', 'utf-8'); } @@ -73,7 +73,7 @@ public function testSettingCharsetNotifiesEncoder() $part = $this->createMimePart($this->createHeaderSet(), $encoder, $this->createCache() - ); + ); $part->setCharset('utf-8'); } @@ -86,7 +86,7 @@ public function testSettingCharsetNotifiesHeaders() $part = $this->createMimePart($headers, $this->createEncoder(), $this->createCache() - ); + ); $part->setCharset('utf-8'); } @@ -99,7 +99,7 @@ public function testSettingCharsetNotifiesChildren() $part = $this->createMimePart($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $part->setChildren([$child]); $part->setCharset('windows-874'); } @@ -108,13 +108,13 @@ public function testCharsetChangeUpdatesCharset() { $cType = $this->createHeader('Content-Type', 'text/plain', ['charset' => 'iso-8859-1'], false - ); + ); $cType->shouldReceive('setParameter')->once()->with('charset', 'utf-8'); $part = $this->createMimePart($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $part->charsetChanged('utf-8'); } @@ -129,7 +129,7 @@ public function testSettingCharsetClearsCache() $entity = $this->createEntity($headers, $this->createEncoder(), $cache - ); + ); $entity->setBody("blah\r\nblah!"); $entity->toString(); @@ -137,7 +137,7 @@ public function testSettingCharsetClearsCache() // Initialize the expectation here because we only care about what happens in setCharset() $cache->shouldReceive('clearKey') ->once() - ->with(\Mockery::any(), 'body'); + ->with(Mockery::any(), 'body'); $entity->setCharset('iso-2022'); } @@ -149,11 +149,11 @@ public function testFormatIsReturnedFromHeader() $cType = $this->createHeader('Content-Type', 'text/plain', ['format' => 'flowed'] - ); + ); $part = $this->createMimePart($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('flowed', $part->getFormat()); } @@ -165,7 +165,7 @@ public function testFormatIsSetInHeader() $part = $this->createMimePart($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $part->setFormat('fixed'); } @@ -176,11 +176,11 @@ public function testDelSpIsReturnedFromHeader() $cType = $this->createHeader('Content-Type', 'text/plain', ['delsp' => 'no'] - ); + ); $part = $this->createMimePart($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertFalse($part->getDelSp()); } @@ -192,7 +192,7 @@ public function testDelSpIsSetInHeader() $part = $this->createMimePart($this->createHeaderSet([ 'Content-Type' => $cType, ]), $this->createEncoder(), $this->createCache() - ); + ); $part->setDelSp(true); } @@ -200,7 +200,7 @@ public function testFluidInterface() { $part = $this->createMimePart($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertSame($part, $part @@ -215,10 +215,10 @@ public function testFluidInterface() ->setCharset('utf-8') ->setFormat('flowed') ->setDelSp(true) - ); + ); } - //abstract + // abstract protected function createEntity($headers, $encoder, $cache) { return $this->createMimePart($headers, $encoder, $cache); diff --git a/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php b/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php index d15d81ed3..521ea95e0 100644 --- a/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php +++ b/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php @@ -2,7 +2,7 @@ use Egulias\EmailValidator\EmailValidator; -class Swift_Mime_SimpleHeaderFactoryTest extends \PHPUnit\Framework\TestCase +class Swift_Mime_SimpleHeaderFactoryTest extends PHPUnit\Framework\TestCase { private $factory; @@ -27,7 +27,7 @@ public function testMailboxHeaderHasCorrectModel() { $header = $this->factory->createMailboxHeader('X-Foo', ['foo@bar' => 'FooBar'] - ); + ); $this->assertEquals(['foo@bar' => 'FooBar'], $header->getFieldBodyModel()); } @@ -45,7 +45,7 @@ public function testDateHeaderHasCorrectName() public function testDateHeaderHasCorrectModel() { - $dateTime = new \DateTimeImmutable(); + $dateTime = new DateTimeImmutable(); $header = $this->factory->createDateHeader('X-Date', $dateTime); $this->assertEquals($dateTime, $header->getFieldBodyModel()); } @@ -90,7 +90,7 @@ public function testParameterizedHeaderHasCorrectParams() { $header = $this->factory->createParameterizedHeader('X-Foo', 'bar', ['zip' => 'button'] - ); + ); $this->assertEquals(['zip' => 'button'], $header->getParameters()); } @@ -154,7 +154,7 @@ private function createFactory($encoder = null, $paramEncoder = null) $paramEncoder ?: $this->createParamEncoder(), new EmailValidator() - ); + ); } private function createHeaderEncoder() diff --git a/tests/unit/Swift/Mime/SimpleHeaderSetTest.php b/tests/unit/Swift/Mime/SimpleHeaderSetTest.php index 16ec1cc03..abaf46125 100644 --- a/tests/unit/Swift/Mime/SimpleHeaderSetTest.php +++ b/tests/unit/Swift/Mime/SimpleHeaderSetTest.php @@ -1,6 +1,6 @@ createSet($factory); $set->addParameterizedHeader('Content-Type', 'text/plain', ['charset' => 'utf-8'] - ); + ); } public function testAddIdHeaderDelegatesToFactory() @@ -136,7 +136,7 @@ public function testAddedParameterizedHeaderIsSeenByHas() $set = $this->createSet($factory); $set->addParameterizedHeader('Content-Type', 'text/plain', ['charset' => 'utf-8'] - ); + ); $this->assertTrue($set->has('Content-Type')); } @@ -293,7 +293,7 @@ public function testGetAllReturnsAllHeadersMatchingName() $this->assertEquals([$header0, $header1, $header2], $set->getAll('Message-ID') - ); + ); } public function testGetAllReturnsAllHeadersIfNoArguments() @@ -322,7 +322,7 @@ public function testGetAllReturnsAllHeadersIfNoArguments() $this->assertEquals([$header0, $header1, $header2], $set->getAll() - ); + ); } public function testGetAllReturnsEmptyArrayIfNoneSet() @@ -529,7 +529,7 @@ public function testToStringJoinsHeadersTogether() "Foo: bar\r\n". "Zip: buttons\r\n", $set->toString() - ); + ); } public function testHeadersWithoutBodiesAreNotDisplayed() @@ -552,7 +552,7 @@ public function testHeadersWithoutBodiesAreNotDisplayed() $this->assertEquals( "Foo: bar\r\n", $set->toString() - ); + ); } public function testHeadersWithoutBodiesCanBeForcedToDisplay() @@ -577,7 +577,7 @@ public function testHeadersWithoutBodiesCanBeForcedToDisplay() "Foo: \r\n". "Zip: \r\n", $set->toString() - ); + ); } public function testHeaderSequencesCanBeSpecified() @@ -608,7 +608,7 @@ public function testHeaderSequencesCanBeSpecified() "Second: two\r\n". "Third: three\r\n", $set->toString() - ); + ); } public function testUnsortedHeadersAppearAtEnd() @@ -647,7 +647,7 @@ public function testUnsortedHeadersAppearAtEnd() "Fourth: four\r\n". "Fifth: five\r\n", $set->toString() - ); + ); } public function testSettingCharsetNotifiesAlreadyExistingHeaders() diff --git a/tests/unit/Swift/Mime/SimpleMessageTest.php b/tests/unit/Swift/Mime/SimpleMessageTest.php index 1b6687a89..0650f8e10 100644 --- a/tests/unit/Swift/Mime/SimpleMessageTest.php +++ b/tests/unit/Swift/Mime/SimpleMessageTest.php @@ -12,10 +12,10 @@ public function testNestingLevelIsTop() { $message = $this->createMessage($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals( Swift_Mime_SimpleMimeEntity::LEVEL_TOP, $message->getNestingLevel() - ); + ); } public function testDateIsReturnedFromHeader() @@ -26,7 +26,7 @@ public function testDateIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['Date' => $date]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals($dateTime, $message->getDate()); } @@ -44,7 +44,7 @@ public function testDateIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['Date' => $date]), $this->createEncoder(), $this->createCache() - ); + ); $message->setDate($dateTime); } @@ -61,7 +61,7 @@ public function testDateHeaderIsCreatedIfNonePresent() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setDate($dateTime); } @@ -74,7 +74,7 @@ public function testDateHeaderIsAddedDuringConstruction() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); } public function testIdIsReturnedFromHeader() @@ -90,7 +90,7 @@ public function testIdIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['Message-ID' => $messageId]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('a@b', $message->getId()); } @@ -106,7 +106,7 @@ public function testIdIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['Message-ID' => $messageId]), $this->createEncoder(), $this->createCache() - ); + ); $message->setId('x@y'); } @@ -115,11 +115,11 @@ public function testIdIsAutoGenerated() $headers = $this->createHeaderSet([], false); $headers->shouldReceive('addIdHeader') ->once() - ->with('Message-ID', \Mockery::pattern('/^.*?@.*?$/D')); + ->with('Message-ID', Mockery::pattern('/^.*?@.*?$/D')); $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); } public function testSubjectIsReturnedFromHeader() @@ -131,7 +131,7 @@ public function testSubjectIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['Subject' => $subject]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('example subject', $message->getSubject()); } @@ -145,7 +145,7 @@ public function testSubjectIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['Subject' => $subject]), $this->createEncoder(), $this->createCache() - ); + ); $message->setSubject('foo'); } @@ -160,7 +160,7 @@ public function testSubjectHeaderIsCreatedIfNotPresent() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setSubject('example subject'); } @@ -173,7 +173,7 @@ public function testReturnPathIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['Return-Path' => $path]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('bounces@domain', $message->getReturnPath()); } @@ -187,7 +187,7 @@ public function testReturnPathIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['Return-Path' => $path]), $this->createEncoder(), $this->createCache() - ); + ); $message->setReturnPath('bounces@domain'); } @@ -200,7 +200,7 @@ public function testReturnPathHeaderIsAddedIfNoneSet() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setReturnPath('bounces@domain'); } @@ -213,7 +213,7 @@ public function testSenderIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['Sender' => $sender]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals(['sender@domain' => 'Name'], $message->getSender()); } @@ -221,7 +221,7 @@ public function testSenderIsSetInHeader() { $sender = $this->createHeader('Sender', ['sender@domain' => 'Name'], [], false - ); + ); $sender->shouldReceive('setFieldBodyModel') ->once() ->with(['other@domain' => 'Other']); @@ -229,7 +229,7 @@ public function testSenderIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['Sender' => $sender]), $this->createEncoder(), $this->createCache() - ); + ); $message->setSender(['other@domain' => 'Other']); } @@ -244,7 +244,7 @@ public function testSenderHeaderIsAddedIfNoneSet() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setSender('sender@domain'); } @@ -259,7 +259,7 @@ public function testNameCanBeUsedInSenderHeader() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setSender('sender@domain', 'Name'); } @@ -272,7 +272,7 @@ public function testFromIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['From' => $from]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals(['from@domain' => 'Name'], $message->getFrom()); } @@ -280,7 +280,7 @@ public function testFromIsSetInHeader() { $from = $this->createHeader('From', ['from@domain' => 'Name'], [], false - ); + ); $from->shouldReceive('setFieldBodyModel') ->once() ->with(['other@domain' => 'Other']); @@ -288,7 +288,7 @@ public function testFromIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['From' => $from]), $this->createEncoder(), $this->createCache() - ); + ); $message->setFrom(['other@domain' => 'Other']); } @@ -296,7 +296,7 @@ public function testFromIsAddedToHeadersDuringAddFrom() { $from = $this->createHeader('From', ['from@domain' => 'Name'], [], false - ); + ); $from->shouldReceive('setFieldBodyModel') ->once() ->with(['from@domain' => 'Name', 'other@domain' => 'Other']); @@ -304,7 +304,7 @@ public function testFromIsAddedToHeadersDuringAddFrom() $message = $this->createMessage( $this->createHeaderSet(['From' => $from]), $this->createEncoder(), $this->createCache() - ); + ); $message->addFrom('other@domain', 'Other'); } @@ -319,7 +319,7 @@ public function testFromHeaderIsAddedIfNoneSet() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setFrom('from@domain'); } @@ -334,7 +334,7 @@ public function testPersonalNameCanBeUsedInFromAddress() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setFrom('from@domain', 'Name'); } @@ -347,7 +347,7 @@ public function testReplyToIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['Reply-To' => $reply]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals(['reply@domain' => 'Name'], $message->getReplyTo()); } @@ -355,7 +355,7 @@ public function testReplyToIsSetInHeader() { $reply = $this->createHeader('Reply-To', ['reply@domain' => 'Name'], [], false - ); + ); $reply->shouldReceive('setFieldBodyModel') ->once() ->with(['other@domain' => 'Other']); @@ -363,7 +363,7 @@ public function testReplyToIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['Reply-To' => $reply]), $this->createEncoder(), $this->createCache() - ); + ); $message->setReplyTo(['other@domain' => 'Other']); } @@ -371,7 +371,7 @@ public function testReplyToIsAddedToHeadersDuringAddReplyTo() { $replyTo = $this->createHeader('Reply-To', ['from@domain' => 'Name'], [], false - ); + ); $replyTo->shouldReceive('setFieldBodyModel') ->once() ->with(['from@domain' => 'Name', 'other@domain' => 'Other']); @@ -379,7 +379,7 @@ public function testReplyToIsAddedToHeadersDuringAddReplyTo() $message = $this->createMessage( $this->createHeaderSet(['Reply-To' => $replyTo]), $this->createEncoder(), $this->createCache() - ); + ); $message->addReplyTo('other@domain', 'Other'); } @@ -394,7 +394,7 @@ public function testReplyToHeaderIsAddedIfNoneSet() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setReplyTo('reply@domain'); } @@ -409,7 +409,7 @@ public function testNameCanBeUsedInReplyTo() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setReplyTo('reply@domain', 'Name'); } @@ -422,7 +422,7 @@ public function testToIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['To' => $to]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals(['to@domain' => 'Name'], $message->getTo()); } @@ -430,7 +430,7 @@ public function testToIsSetInHeader() { $to = $this->createHeader('To', ['to@domain' => 'Name'], [], false - ); + ); $to->shouldReceive('setFieldBodyModel') ->once() ->with(['other@domain' => 'Other']); @@ -438,7 +438,7 @@ public function testToIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['To' => $to]), $this->createEncoder(), $this->createCache() - ); + ); $message->setTo(['other@domain' => 'Other']); } @@ -446,7 +446,7 @@ public function testToIsAddedToHeadersDuringAddTo() { $to = $this->createHeader('To', ['from@domain' => 'Name'], [], false - ); + ); $to->shouldReceive('setFieldBodyModel') ->once() ->with(['from@domain' => 'Name', 'other@domain' => 'Other']); @@ -454,7 +454,7 @@ public function testToIsAddedToHeadersDuringAddTo() $message = $this->createMessage( $this->createHeaderSet(['To' => $to]), $this->createEncoder(), $this->createCache() - ); + ); $message->addTo('other@domain', 'Other'); } @@ -469,7 +469,7 @@ public function testToHeaderIsAddedIfNoneSet() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setTo('to@domain'); } @@ -484,7 +484,7 @@ public function testNameCanBeUsedInToHeader() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setTo('to@domain', 'Name'); } @@ -497,7 +497,7 @@ public function testCcIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['Cc' => $cc]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals(['cc@domain' => 'Name'], $message->getCc()); } @@ -505,7 +505,7 @@ public function testCcIsSetInHeader() { $cc = $this->createHeader('Cc', ['cc@domain' => 'Name'], [], false - ); + ); $cc->shouldReceive('setFieldBodyModel') ->once() ->with(['other@domain' => 'Other']); @@ -513,7 +513,7 @@ public function testCcIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['Cc' => $cc]), $this->createEncoder(), $this->createCache() - ); + ); $message->setCc(['other@domain' => 'Other']); } @@ -521,7 +521,7 @@ public function testCcIsAddedToHeadersDuringAddCc() { $cc = $this->createHeader('Cc', ['from@domain' => 'Name'], [], false - ); + ); $cc->shouldReceive('setFieldBodyModel') ->once() ->with(['from@domain' => 'Name', 'other@domain' => 'Other']); @@ -529,7 +529,7 @@ public function testCcIsAddedToHeadersDuringAddCc() $message = $this->createMessage( $this->createHeaderSet(['Cc' => $cc]), $this->createEncoder(), $this->createCache() - ); + ); $message->addCc('other@domain', 'Other'); } @@ -544,7 +544,7 @@ public function testCcHeaderIsAddedIfNoneSet() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setCc('cc@domain'); } @@ -559,7 +559,7 @@ public function testNameCanBeUsedInCcHeader() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setCc('cc@domain', 'Name'); } @@ -572,7 +572,7 @@ public function testBccIsReturnedFromHeader() $message = $this->createMessage( $this->createHeaderSet(['Bcc' => $bcc]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals(['bcc@domain' => 'Name'], $message->getBcc()); } @@ -580,7 +580,7 @@ public function testBccIsSetInHeader() { $bcc = $this->createHeader('Bcc', ['bcc@domain' => 'Name'], [], false - ); + ); $bcc->shouldReceive('setFieldBodyModel') ->once() ->with(['other@domain' => 'Other']); @@ -588,7 +588,7 @@ public function testBccIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['Bcc' => $bcc]), $this->createEncoder(), $this->createCache() - ); + ); $message->setBcc(['other@domain' => 'Other']); } @@ -596,7 +596,7 @@ public function testBccIsAddedToHeadersDuringAddBcc() { $bcc = $this->createHeader('Bcc', ['from@domain' => 'Name'], [], false - ); + ); $bcc->shouldReceive('setFieldBodyModel') ->once() ->with(['from@domain' => 'Name', 'other@domain' => 'Other']); @@ -604,7 +604,7 @@ public function testBccIsAddedToHeadersDuringAddBcc() $message = $this->createMessage( $this->createHeaderSet(['Bcc' => $bcc]), $this->createEncoder(), $this->createCache() - ); + ); $message->addBcc('other@domain', 'Other'); } @@ -619,7 +619,7 @@ public function testBccHeaderIsAddedIfNoneSet() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setBcc('bcc@domain'); } @@ -634,7 +634,7 @@ public function testNameCanBeUsedInBcc() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setBcc('bcc@domain', 'Name'); } @@ -644,7 +644,7 @@ public function testPriorityIsReadFromHeader() $message = $this->createMessage( $this->createHeaderSet(['X-Priority' => $prio]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals(2, $message->getPriority()); } @@ -658,7 +658,7 @@ public function testPriorityIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['X-Priority' => $prio]), $this->createEncoder(), $this->createCache() - ); + ); $message->setPriority($message::PRIORITY_LOWEST); } @@ -673,7 +673,7 @@ public function testPriorityHeaderIsAddedIfNoneSet() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setPriority($message::PRIORITY_LOW); } @@ -681,14 +681,14 @@ public function testReadReceiptAddressReadFromHeader() { $rcpt = $this->createHeader('Disposition-Notification-To', ['chris@swiftmailer.org' => 'Chris'] - ); + ); $message = $this->createMessage( $this->createHeaderSet(['Disposition-Notification-To' => $rcpt]), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals(['chris@swiftmailer.org' => 'Chris'], $message->getReadReceiptTo() - ); + ); } public function testReadReceiptIsSetInHeader() @@ -701,7 +701,7 @@ public function testReadReceiptIsSetInHeader() $message = $this->createMessage( $this->createHeaderSet(['Disposition-Notification-To' => $rcpt]), $this->createEncoder(), $this->createCache() - ); + ); $message->setReadReceiptTo('mark@swiftmailer.org'); } @@ -716,7 +716,7 @@ public function testReadReceiptHeaderIsAddedIfNoneSet() $message = $this->createMessage($headers, $this->createEncoder(), $this->createCache() - ); + ); $message->setReadReceiptTo('mark@swiftmailer.org'); } @@ -727,7 +727,7 @@ public function testChildrenCanBeAttached() $message = $this->createMessage($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $message->attach($child1); $message->attach($child2); @@ -742,7 +742,7 @@ public function testChildrenCanBeDetached() $message = $this->createMessage($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $message->attach($child1); $message->attach($child2); @@ -758,7 +758,7 @@ public function testEmbedAttachesChild() $message = $this->createMessage($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $message->embed($child); @@ -769,14 +769,14 @@ public function testEmbedReturnsValidCid() { $child = $this->createChild(Swift_Mime_SimpleMimeEntity::LEVEL_RELATED, '', false - ); + ); $child->shouldReceive('getId') ->zeroOrMoreTimes() ->andReturn('foo@bar'); $message = $this->createMessage($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertEquals('cid:foo@bar', $message->embed($child)); } @@ -786,7 +786,7 @@ public function testFluidInterface() $child = $this->createChild(); $message = $this->createMessage($this->createHeaderSet(), $this->createEncoder(), $this->createCache() - ); + ); $this->assertSame($message, $message ->setContentType('text/plain') @@ -813,10 +813,10 @@ public function testFluidInterface() ->setReadReceiptTo('a@b') ->attach($child) ->detach($child) - ); + ); } - //abstract + // abstract protected function createEntity($headers, $encoder, $cache) { return $this->createMessage($headers, $encoder, $cache); diff --git a/tests/unit/Swift/Plugins/AntiFloodPluginTest.php b/tests/unit/Swift/Plugins/AntiFloodPluginTest.php index 2c1e33a1d..fef0730b9 100644 --- a/tests/unit/Swift/Plugins/AntiFloodPluginTest.php +++ b/tests/unit/Swift/Plugins/AntiFloodPluginTest.php @@ -1,6 +1,6 @@ 'Chris'], 'Subject', 'Hello {name}, you are customer #{id}' - ); + ); $message->shouldReceive('setBody') ->once() ->with('Hello Zip, you are customer #456'); @@ -19,7 +19,7 @@ public function testMessageBodyReceivesReplacements() $plugin = $this->createPlugin( ['zip@button.tld' => ['{name}' => 'Zip', '{id}' => '456']] - ); + ); $evt = $this->createSendEvent($message); @@ -35,7 +35,7 @@ public function testReplacementsCanBeAppliedToSameMessageMultipleTimes() ['chris.corbyn@swiftmailer.org' => 'Chris'], 'Subject', 'Hello {name}, you are customer #{id}' - ); + ); $message->shouldReceive('setBody') ->once() ->with('Hello Zip, you are customer #456'); @@ -53,7 +53,7 @@ public function testReplacementsCanBeAppliedToSameMessageMultipleTimes() 'foo@bar.tld' => ['{name}' => 'Foo', '{id}' => '123'], 'zip@button.tld' => ['{name}' => 'Zip', '{id}' => '456'], ] - ); + ); $evt = $this->createSendEvent($message); @@ -76,7 +76,7 @@ public function testReplacementsCanBeMadeInHeaders() ['chris.corbyn@swiftmailer.org' => 'Chris'], 'A message for {name}!', 'Hello {name}, you are customer #{id}' - ); + ); $message->shouldReceive('setBody') ->once() @@ -96,7 +96,7 @@ public function testReplacementsCanBeMadeInHeaders() $plugin = $this->createPlugin( ['zip@button.tld' => ['{name}' => 'Zip', '{id}' => '456']] - ); + ); $evt = $this->createSendEvent($message); $plugin->beforeSendPerformed($evt); @@ -113,7 +113,7 @@ public function testReplacementsAreMadeOnSubparts() ['chris.corbyn@swiftmailer.org' => 'Chris'], 'A message for {name}!', 'Subject' - ); + ); $message->shouldReceive('getChildren') ->zeroOrMoreTimes() ->andReturn([$part1, $part2]); @@ -130,7 +130,7 @@ public function testReplacementsAreMadeOnSubparts() $plugin = $this->createPlugin( ['zip@button.tld' => ['{name}' => 'Zip', '{id}' => '456']] - ); + ); $evt = $this->createSendEvent($message); @@ -146,7 +146,7 @@ public function testReplacementsCanBeTakenFromCustomReplacementsObject() ['chris.corbyn@swiftmailer.org' => 'Chris'], 'Subject', 'Something {a}' - ); + ); $replacements = $this->createReplacements(); diff --git a/tests/unit/Swift/Plugins/LoggerPluginTest.php b/tests/unit/Swift/Plugins/LoggerPluginTest.php index 0bedb6549..01bec5047 100644 --- a/tests/unit/Swift/Plugins/LoggerPluginTest.php +++ b/tests/unit/Swift/Plugins/LoggerPluginTest.php @@ -1,6 +1,6 @@ > RSET\r\n".PHP_EOL. "<< 250 OK\r\n", $logger->dump() - ); + ); } public function testLogCanBeCleared() @@ -40,7 +40,7 @@ public function testLogCanBeCleared() ">> RSET\r\n".PHP_EOL. "<< 250 OK\r\n", $logger->dump() - ); + ); $logger->clear(); @@ -60,6 +60,6 @@ public function testLengthCanBeTruncated() "<< 250 OK\r\n", $logger->dump(), '%s: Log should be truncated to last 2 entries' - ); + ); } } diff --git a/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php b/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php index c43660da1..f7b44075c 100644 --- a/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php +++ b/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php @@ -1,6 +1,6 @@ hitReporter->notify($this->message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_FAIL - ); + ); $this->assertEquals(['foo@bar.tld'], $this->hitReporter->getFailedRecipients() - ); + ); } public function testMultipleReports() { $this->hitReporter->notify($this->message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_FAIL - ); + ); $this->hitReporter->notify($this->message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL - ); + ); $this->assertEquals(['foo@bar.tld', 'zip@button'], $this->hitReporter->getFailedRecipients() - ); + ); } public function testReportingPassIsIgnored() { $this->hitReporter->notify($this->message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_FAIL - ); + ); $this->hitReporter->notify($this->message, 'zip@button', Swift_Plugins_Reporter::RESULT_PASS - ); + ); $this->assertEquals(['foo@bar.tld'], $this->hitReporter->getFailedRecipients() - ); + ); } public function testBufferCanBeCleared() { $this->hitReporter->notify($this->message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_FAIL - ); + ); $this->hitReporter->notify($this->message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL - ); + ); $this->assertEquals(['foo@bar.tld', 'zip@button'], $this->hitReporter->getFailedRecipients() - ); + ); $this->hitReporter->clear(); $this->assertEquals([], $this->hitReporter->getFailedRecipients()); } diff --git a/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php b/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php index 72ffaaebc..00de279d1 100644 --- a/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php +++ b/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php @@ -1,6 +1,6 @@ html->notify($this->message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS - ); + ); $html = ob_get_clean(); $this->assertMatchesRegularExpression('~ok|pass~i', $html, '%s: Reporter should indicate pass'); @@ -28,7 +28,7 @@ public function testReportingFail() ob_start(); $this->html->notify($this->message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL - ); + ); $html = ob_get_clean(); $this->assertMatchesRegularExpression('~fail~i', $html, '%s: Reporter should indicate fail'); @@ -40,10 +40,10 @@ public function testMultipleReports() ob_start(); $this->html->notify($this->message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS - ); + ); $this->html->notify($this->message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL - ); + ); $html = ob_get_clean(); $this->assertMatchesRegularExpression('~ok|pass~i', $html, '%s: Reporter should indicate pass'); diff --git a/tests/unit/Swift/Plugins/ThrottlerPluginTest.php b/tests/unit/Swift/Plugins/ThrottlerPluginTest.php index e35dcc8dc..0baee323d 100644 --- a/tests/unit/Swift/Plugins/ThrottlerPluginTest.php +++ b/tests/unit/Swift/Plugins/ThrottlerPluginTest.php @@ -1,31 +1,31 @@ createSleeper(); $timer = $this->createTimer(); - //10MB/min + // 10MB/min $plugin = new Swift_Plugins_ThrottlerPlugin( 10000000, Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE, $sleeper, $timer - ); + ); $timer->shouldReceive('getTimestamp')->once()->andReturn(0); - $timer->shouldReceive('getTimestamp')->once()->andReturn(1); //expected 0.6 - $timer->shouldReceive('getTimestamp')->once()->andReturn(1); //expected 1.2 (sleep 1) - $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 1.8 - $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 2.4 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(1); // expected 0.6 + $timer->shouldReceive('getTimestamp')->once()->andReturn(1); // expected 1.2 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); // expected 1.8 + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); // expected 2.4 (sleep 1) $sleeper->shouldReceive('sleep')->twice()->with(1); - //10,000,000 bytes per minute - //100,000 bytes per email + // 10,000,000 bytes per minute + // 100,000 bytes per email // .: (10,000,000/100,000)/60 emails per second = 1.667 emais/sec - $message = $this->createMessageWithByteCount(100000); //100KB + $message = $this->createMessageWithByteCount(100000); // 100KB $evt = $this->createSendEvent($message); @@ -40,21 +40,21 @@ public function testMessagesPerMinuteThrottling() $sleeper = $this->createSleeper(); $timer = $this->createTimer(); - //60/min + // 60/min $plugin = new Swift_Plugins_ThrottlerPlugin( 60, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE, $sleeper, $timer - ); + ); $timer->shouldReceive('getTimestamp')->once()->andReturn(0); - $timer->shouldReceive('getTimestamp')->once()->andReturn(0); //expected 1 (sleep 1) - $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 2 - $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 3 (sleep 1) - $timer->shouldReceive('getTimestamp')->once()->andReturn(4); //expected 4 + $timer->shouldReceive('getTimestamp')->once()->andReturn(0); // expected 1 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); // expected 2 + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); // expected 3 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(4); // expected 4 $sleeper->shouldReceive('sleep')->twice()->with(1); - //60 messages per minute - //1 message per second + // 60 messages per minute + // 1 message per second $message = $this->createMessageWithByteCount(10); diff --git a/tests/unit/Swift/Signers/DKIMSignerTest.php b/tests/unit/Swift/Signers/DKIMSignerTest.php index 0db317c35..865cfe132 100644 --- a/tests/unit/Swift/Signers/DKIMSignerTest.php +++ b/tests/unit/Swift/Signers/DKIMSignerTest.php @@ -2,7 +2,7 @@ use Egulias\EmailValidator\EmailValidator; -class Swift_Signers_DKIMSignerTest extends \SwiftMailerTestCase +class Swift_Signers_DKIMSignerTest extends SwiftMailerTestCase { public function testBasicSigningHeaderManipulation() { @@ -208,7 +208,7 @@ private function createHeaders() ->andReturn([$headerFactory->createTextHeader('Subject', 'Foo Bar Text Message')]); $headers->shouldReceive('addTextHeader') ->zeroOrMoreTimes() - ->with('DKIM-Signature', \Mockery::any()) + ->with('DKIM-Signature', Mockery::any()) ->andReturn(true); $headers->shouldReceive('getAll') ->zeroOrMoreTimes() diff --git a/tests/unit/Swift/Signers/OpenDKIMSignerTest.php b/tests/unit/Swift/Signers/OpenDKIMSignerTest.php index bf347aa75..2bcb364ad 100644 --- a/tests/unit/Swift/Signers/OpenDKIMSignerTest.php +++ b/tests/unit/Swift/Signers/OpenDKIMSignerTest.php @@ -3,14 +3,14 @@ /** * @todo */ -class Swift_Signers_OpenDKIMSignerTest extends \SwiftMailerTestCase +class Swift_Signers_OpenDKIMSignerTest extends SwiftMailerTestCase { protected function setUp() { if (!\extension_loaded('opendkim')) { $this->markTestSkipped( 'Need OpenDKIM extension run these tests.' - ); + ); } } diff --git a/tests/unit/Swift/Signers/SMimeSignerTest.php b/tests/unit/Swift/Signers/SMimeSignerTest.php index 62b0d5f35..84300bb52 100644 --- a/tests/unit/Swift/Signers/SMimeSignerTest.php +++ b/tests/unit/Swift/Signers/SMimeSignerTest.php @@ -1,6 +1,6 @@ assertEquals( [0x59, 0x60, 0x63, 0x64, 0x65], $filter->filter([0x59, 0x60, 0x61, 0x62, 0x65]) - ); + ); } public function testShouldBufferReturnsTrueIfPartialMatchAtEndOfBuffer() @@ -17,7 +17,7 @@ public function testShouldBufferReturnsTrueIfPartialMatchAtEndOfBuffer() $this->assertTrue($filter->shouldBuffer([0x59, 0x60, 0x61]), '%s: Filter should buffer since 0x61 0x62 is the needle and the ending '. '0x61 could be from 0x61 0x62' - ); + ); } public function testFilterCanMakeMultipleReplacements() @@ -26,7 +26,7 @@ public function testFilterCanMakeMultipleReplacements() $this->assertEquals( [0x60, 0x63, 0x60, 0x63, 0x60], $filter->filter([0x60, 0x61, 0x60, 0x62, 0x60]) - ); + ); } public function testMultipleReplacementsCanBeDifferent() @@ -35,7 +35,7 @@ public function testMultipleReplacementsCanBeDifferent() $this->assertEquals( [0x60, 0x63, 0x60, 0x64, 0x60], $filter->filter([0x60, 0x61, 0x60, 0x62, 0x60]) - ); + ); } public function testShouldBufferReturnsFalseIfPartialMatchNotAtEndOfString() @@ -43,7 +43,7 @@ public function testShouldBufferReturnsFalseIfPartialMatchNotAtEndOfString() $filter = $this->createFilter([0x0D, 0x0A], [0x0A]); $this->assertFalse($filter->shouldBuffer([0x61, 0x62, 0x0D, 0x0A, 0x63]), '%s: Filter should not buffer since x0Dx0A is the needle and is not at EOF' - ); + ); } public function testShouldBufferReturnsTrueIfAnyOfMultipleMatchesAtEndOfString() @@ -52,7 +52,7 @@ public function testShouldBufferReturnsTrueIfAnyOfMultipleMatchesAtEndOfString() $this->assertTrue($filter->shouldBuffer([0x59, 0x60, 0x61]), '%s: Filter should buffer since 0x61 0x62 is a needle and the ending '. '0x61 could be from 0x61 0x62' - ); + ); } public function testConvertingAllLineEndingsToCRLFWhenInputIsLF() @@ -60,12 +60,12 @@ public function testConvertingAllLineEndingsToCRLFWhenInputIsLF() $filter = $this->createFilter( [[0x0D, 0x0A], [0x0D], [0x0A]], [[0x0A], [0x0A], [0x0D, 0x0A]] - ); + ); $this->assertEquals( [0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63], $filter->filter([0x60, 0x0A, 0x61, 0x0A, 0x62, 0x0A, 0x63]) - ); + ); } public function testConvertingAllLineEndingsToCRLFWhenInputIsCR() @@ -73,12 +73,12 @@ public function testConvertingAllLineEndingsToCRLFWhenInputIsCR() $filter = $this->createFilter( [[0x0D, 0x0A], [0x0D], [0x0A]], [[0x0A], [0x0A], [0x0D, 0x0A]] - ); + ); $this->assertEquals( [0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63], $filter->filter([0x60, 0x0D, 0x61, 0x0D, 0x62, 0x0D, 0x63]) - ); + ); } public function testConvertingAllLineEndingsToCRLFWhenInputIsCRLF() @@ -86,12 +86,12 @@ public function testConvertingAllLineEndingsToCRLFWhenInputIsCRLF() $filter = $this->createFilter( [[0x0D, 0x0A], [0x0D], [0x0A]], [[0x0A], [0x0A], [0x0D, 0x0A]] - ); + ); $this->assertEquals( [0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63], $filter->filter([0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63]) - ); + ); } public function testConvertingAllLineEndingsToCRLFWhenInputIsLFCR() @@ -99,27 +99,27 @@ public function testConvertingAllLineEndingsToCRLFWhenInputIsLFCR() $filter = $this->createFilter( [[0x0D, 0x0A], [0x0D], [0x0A]], [[0x0A], [0x0A], [0x0D, 0x0A]] - ); + ); $this->assertEquals( [0x60, 0x0D, 0x0A, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x0D, 0x0A, 0x63], $filter->filter([0x60, 0x0A, 0x0D, 0x61, 0x0A, 0x0D, 0x62, 0x0A, 0x0D, 0x63]) - ); + ); } public function testConvertingAllLineEndingsToCRLFWhenInputContainsLFLF() { - //Lighthouse Bug #23 + // Lighthouse Bug #23 $filter = $this->createFilter( [[0x0D, 0x0A], [0x0D], [0x0A]], [[0x0A], [0x0A], [0x0D, 0x0A]] - ); + ); $this->assertEquals( [0x60, 0x0D, 0x0A, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x0D, 0x0A, 0x63], $filter->filter([0x60, 0x0A, 0x0A, 0x61, 0x0A, 0x0A, 0x62, 0x0A, 0x0A, 0x63]) - ); + ); } private function createFilter($search, $replace) diff --git a/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php b/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php index 514829f62..6fae946ef 100644 --- a/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php +++ b/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php @@ -1,6 +1,6 @@ createFilter('a', 'c'); $this->assertNotEquals($filter1, $filter2, '%s: Differing instances should not be cached' - ); + ); } private function createFactory() diff --git a/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php b/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php index 1a5f4dca7..8dcf5a701 100644 --- a/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php +++ b/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php @@ -1,6 +1,6 @@ assertTrue($filter->shouldBuffer('XfooYf'), '%s: Filter should buffer since "foo" is the needle and the ending '. '"f" could be from "foo"' - ); + ); } public function testFilterCanMakeMultipleReplacements() @@ -34,7 +34,7 @@ public function testShouldBufferReturnsFalseIfPartialMatchNotAtEndOfString() $filter = $this->createFilter("\r\n", "\n"); $this->assertFalse($filter->shouldBuffer("foo\r\nbar"), '%s: Filter should not buffer since x0Dx0A is the needle and is not at EOF' - ); + ); } public function testShouldBufferReturnsTrueIfAnyOfMultipleMatchesAtEndOfString() @@ -43,7 +43,7 @@ public function testShouldBufferReturnsTrueIfAnyOfMultipleMatchesAtEndOfString() $this->assertTrue($filter->shouldBuffer('XfooYzi'), '%s: Filter should buffer since "zip" is a needle and the ending '. '"zi" could be from "zip"' - ); + ); } public function testShouldBufferReturnsFalseOnEmptyBuffer() diff --git a/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php b/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php index 896171dcd..4e7541d91 100644 --- a/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php +++ b/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php @@ -111,7 +111,7 @@ public function testSendEventCapturesFailures() ->andReturn("500 Not now\r\n"); $dispatcher->shouldReceive('createSendEvent') ->zeroOrMoreTimes() - ->with($smtp, \Mockery::any()) + ->with($smtp, Mockery::any()) ->andReturn($evt); $dispatcher->shouldReceive('dispatchEvent') ->once() @@ -162,7 +162,7 @@ public function testSendEventHasResultFailedIfAllFailures() ->andReturn("500 Not now\r\n"); $dispatcher->shouldReceive('createSendEvent') ->zeroOrMoreTimes() - ->with($smtp, \Mockery::any()) + ->with($smtp, Mockery::any()) ->andReturn($evt); $dispatcher->shouldReceive('dispatchEvent') ->once() @@ -216,7 +216,7 @@ public function testSendEventHasResultTentativeIfSomeFailures() ->andReturn("500 Not now\r\n"); $dispatcher->shouldReceive('createSendEvent') ->zeroOrMoreTimes() - ->with($smtp, \Mockery::any()) + ->with($smtp, Mockery::any()) ->andReturn($evt); $dispatcher->shouldReceive('dispatchEvent') ->once() @@ -254,7 +254,7 @@ public function testSendEventHasResultSuccessIfNoFailures() ]); $dispatcher->shouldReceive('createSendEvent') ->zeroOrMoreTimes() - ->with($smtp, \Mockery::any()) + ->with($smtp, Mockery::any()) ->andReturn($evt); $dispatcher->shouldReceive('dispatchEvent') ->once() @@ -289,7 +289,7 @@ public function testCancellingEventBubbleBeforeSendStopsEvent() ->andReturn(['mark@swiftmailer.org' => 'Mark']); $dispatcher->shouldReceive('createSendEvent') ->zeroOrMoreTimes() - ->with($smtp, \Mockery::any()) + ->with($smtp, Mockery::any()) ->andReturn($evt); $dispatcher->shouldReceive('dispatchEvent') ->once() @@ -469,7 +469,7 @@ public function testResponseEventsAreGenerated() $dispatcher->shouldReceive('createResponseEvent') ->atLeast()->once() - ->with($smtp, \Mockery::any(), \Mockery::any()) + ->with($smtp, Mockery::any(), Mockery::any()) ->andReturn($evt); $dispatcher->shouldReceive('dispatchEvent') ->atLeast()->once() @@ -488,7 +488,7 @@ public function testCommandEventsAreGenerated() $dispatcher->shouldReceive('createCommandEvent') ->once() - ->with($smtp, \Mockery::any(), \Mockery::any()) + ->with($smtp, Mockery::any(), Mockery::any()) ->andReturn($evt); $dispatcher->shouldReceive('dispatchEvent') ->once() @@ -510,7 +510,7 @@ public function testExceptionsCauseExceptionEvents() ->andReturn("503 I'm sleepy, go away!\r\n"); $dispatcher->shouldReceive('createTransportExceptionEvent') ->zeroOrMoreTimes() - ->with($smtp, \Mockery::any()) + ->with($smtp, Mockery::any()) ->andReturn($evt); $dispatcher->shouldReceive('dispatchEvent') ->once() @@ -538,7 +538,7 @@ public function testExceptionBubblesCanBeCancelled() ->andReturn("503 I'm sleepy, go away!\r\n"); $dispatcher->shouldReceive('createTransportExceptionEvent') ->twice() - ->with($smtp, \Mockery::any()) + ->with($smtp, Mockery::any()) ->andReturn($evt); $dispatcher->shouldReceive('dispatchEvent') ->twice() diff --git a/tests/unit/Swift/Transport/AbstractSmtpTest.php b/tests/unit/Swift/Transport/AbstractSmtpTest.php index dc9f05ea5..e9968e01e 100644 --- a/tests/unit/Swift/Transport/AbstractSmtpTest.php +++ b/tests/unit/Swift/Transport/AbstractSmtpTest.php @@ -1,6 +1,6 @@ getBuffer(); $smtp = $this->getTransport($buf); @@ -689,7 +689,7 @@ public function testSendReturnsNumberOfSuccessfulRecipients() $smtp->start(); $this->assertEquals(2, $smtp->send($message), '%s: 1 of 3 recipients failed so 2 should be returned' - ); + ); } public function testRsetIsSentIfNoSuccessfulRecipients() @@ -739,7 +739,7 @@ public function testRsetIsSentIfNoSuccessfulRecipients() $smtp->start(); $this->assertEquals(0, $smtp->send($message), '%s: 1 of 1 recipients failed so 0 should be returned' - ); + ); } public function testSuccessfulDataCommand() diff --git a/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php b/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php index 3fae9f9b7..c4dafcb85 100644 --- a/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php +++ b/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php @@ -1,6 +1,6 @@ andReturn('334 '.base64_encode('')."\r\n"); $this->agent->shouldReceive('executeCommand') ->once() - ->with(\Mockery::any(), [235]); + ->with(Mockery::any(), [235]); $this->assertTrue($cram->authenticate($this->agent, 'jack', 'pass'), '%s: The buffer accepted all commands authentication should succeed' - ); + ); } public function testAuthenticationFailureSendRset() { - $this->expectException(\Swift_TransportException::class); + $this->expectException(Swift_TransportException::class); $cram = $this->getAuthenticator(); @@ -48,7 +48,7 @@ public function testAuthenticationFailureSendRset() ->andReturn('334 '.base64_encode('')."\r\n"); $this->agent->shouldReceive('executeCommand') ->once() - ->with(\Mockery::any(), [235]) + ->with(Mockery::any(), [235]) ->andThrow(new Swift_TransportException('')); $this->agent->shouldReceive('executeCommand') ->once() diff --git a/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php b/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php index 46f58bfd4..1c26d5459 100644 --- a/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php +++ b/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php @@ -1,6 +1,6 @@ assertTrue($login->authenticate($this->agent, 'jack', 'pass'), '%s: The buffer accepted all commands authentication should succeed' - ); + ); } public function testAuthenticationFailureSendRset() { - $this->expectException(\Swift_TransportException::class); + $this->expectException(Swift_TransportException::class); $login = $this->getAuthenticator(); diff --git a/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php b/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php index e6a385714..149c93cbe 100644 --- a/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php +++ b/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php @@ -1,6 +1,6 @@ shouldReceive('executeCommand') ->once() ->with('AUTH NTLM '.base64_encode( - $this->invokePrivateMethod('createMessage1', $ntlm) - )."\r\n", [334]) + $this->invokePrivateMethod('createMessage1', $ntlm) + )."\r\n", [334]) ->andReturn('334 '.base64_encode(hex2bin('4e544c4d53535000020000000c000c003000000035828980514246973ea892c10000000000000000460046003c00000054004500530054004e00540002000c0054004500530054004e00540001000c004d0045004d0042004500520003001e006d0065006d006200650072002e0074006500730074002e0063006f006d0000000000'))); $agent->shouldReceive('executeCommand') ->once() ->with(base64_encode( - $this->invokePrivateMethod('createMessage3', $ntlm, [$domain, $username, hex2bin('4d0045004d00420045005200'), hex2bin('bf2e015119f6bdb3f6fdb768aa12d478f5ce3d2401c8f6e9'), hex2bin('caa4da8f25d5e840974ed8976d3ada46010100000000000030fa7e3c677bc301f5ce3d2401c8f6e90000000002000c0054004500530054004e00540001000c004d0045004d0042004500520003001e006d0065006d006200650072002e0074006500730074002e0063006f006d000000000000000000')] - ))."\r\n", [235]); + $this->invokePrivateMethod('createMessage3', $ntlm, [$domain, $username, hex2bin('4d0045004d00420045005200'), hex2bin('bf2e015119f6bdb3f6fdb768aa12d478f5ce3d2401c8f6e9'), hex2bin('caa4da8f25d5e840974ed8976d3ada46010100000000000030fa7e3c677bc301f5ce3d2401c8f6e90000000002000c0054004500530054004e00540001000c004d0045004d0042004500520003001e006d0065006d006200650072002e0074006500730074002e0063006f006d000000000000000000')] + ))."\r\n", [235]); $this->assertTrue($ntlm->authenticate($agent, $username.'@'.$domain, $secret, hex2bin('30fa7e3c677bc301'), hex2bin('f5ce3d2401c8f6e9')), '%s: The buffer accepted all commands authentication should succeed'); } public function testAuthenticationFailureSendRset() { - $this->expectException(\Swift_TransportException::class); + $this->expectException(Swift_TransportException::class); $domain = 'TESTNT'; $username = 'test'; @@ -173,8 +173,8 @@ public function testAuthenticationFailureSendRset() $agent->shouldReceive('executeCommand') ->once() ->with('AUTH NTLM '.base64_encode( - $this->invokePrivateMethod('createMessage1', $ntlm) - )."\r\n", [334]) + $this->invokePrivateMethod('createMessage1', $ntlm) + )."\r\n", [334]) ->andThrow(new Swift_TransportException('')); $agent->shouldReceive('executeCommand') ->once() diff --git a/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php b/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php index 4c29d60d2..87faf12d6 100644 --- a/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php +++ b/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php @@ -1,6 +1,6 @@ agent->shouldReceive('executeCommand') ->once() ->with('AUTH PLAIN '.base64_encode( - 'jack'.\chr(0).'jack'.\chr(0).'pass' - )."\r\n", [235]); + 'jack'.\chr(0).'jack'.\chr(0).'pass' + )."\r\n", [235]); $this->assertTrue($plain->authenticate($this->agent, 'jack', 'pass'), '%s: The buffer accepted all commands authentication should succeed' - ); + ); } public function testAuthenticationFailureSendRset() { - $this->expectException(\Swift_TransportException::class); + $this->expectException(Swift_TransportException::class); $plain = $this->getAuthenticator(); $this->agent->shouldReceive('executeCommand') ->once() ->with('AUTH PLAIN '.base64_encode( - 'jack'.\chr(0).'jack'.\chr(0).'pass' - )."\r\n", [235]) + 'jack'.\chr(0).'jack'.\chr(0).'pass' + )."\r\n", [235]) ->andThrow(new Swift_TransportException('')); $this->agent->shouldReceive('executeCommand') ->once() diff --git a/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php b/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php index 81d2d629e..1416487b7 100644 --- a/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php +++ b/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php @@ -1,6 +1,6 @@ exposeMixinMethods(); $this->assertTrue(\in_array('getUsername', $mixins), '%s: getUsername() should be accessible via mixin' - ); + ); $this->assertTrue(\in_array('setUsername', $mixins), '%s: setUsername() should be accessible via mixin' - ); + ); $this->assertTrue(\in_array('getPassword', $mixins), '%s: getPassword() should be accessible via mixin' - ); + ); $this->assertTrue(\in_array('setPassword', $mixins), '%s: setPassword() should be accessible via mixin' - ); + ); $this->assertTrue(\in_array('setAuthMode', $mixins), '%s: setAuthMode() should be accessible via mixin' - ); + ); $this->assertTrue(\in_array('getAuthMode', $mixins), '%s: getAuthMode() should be accessible via mixin' - ); + ); } public function testAuthenticatorsAreCalledAccordingToParamsAfterEhlo() diff --git a/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php b/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php index 63d6079a1..fc18ee554 100644 --- a/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php +++ b/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php @@ -384,19 +384,19 @@ public function testExtensionsAreNotifiedOnCommand() ->andReturn('AUTH'); $ext1->shouldReceive('onCommand') ->once() - ->with($smtp, "FOO\r\n", [250, 251], \Mockery::any(), \Mockery::any()); + ->with($smtp, "FOO\r\n", [250, 251], Mockery::any(), Mockery::any()); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('SIZE'); $ext2->shouldReceive('onCommand') ->once() - ->with($smtp, "FOO\r\n", [250, 251], \Mockery::any(), \Mockery::any()); + ->with($smtp, "FOO\r\n", [250, 251], Mockery::any(), Mockery::any()); $ext3->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $ext3->shouldReceive('onCommand') ->never() - ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + ->with(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()); $smtp->setExtensionHandlers([$ext1, $ext2, $ext3]); $smtp->start(); @@ -441,7 +441,7 @@ public function testChainOfCommandAlgorithmWhenNotifyingExtensions() ->andReturn('AUTH'); $ext1->shouldReceive('onCommand') ->once() - ->with($smtp, "FOO\r\n", [250, 251], \Mockery::any(), \Mockery::any()) + ->with($smtp, "FOO\r\n", [250, 251], Mockery::any(), Mockery::any()) ->andReturnUsing(function ($a, $b, $c, $d, &$e) { $e = true; @@ -452,14 +452,14 @@ public function testChainOfCommandAlgorithmWhenNotifyingExtensions() ->andReturn('SIZE'); $ext2->shouldReceive('onCommand') ->never() - ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + ->with(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()); $ext3->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $ext3->shouldReceive('onCommand') ->never() - ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + ->with(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()); $smtp->setExtensionHandlers([$ext1, $ext2, $ext3]); $smtp->start(); diff --git a/tests/unit/Swift/Transport/EsmtpTransportTest.php b/tests/unit/Swift/Transport/EsmtpTransportTest.php index a27381590..ae55decbb 100644 --- a/tests/unit/Swift/Transport/EsmtpTransportTest.php +++ b/tests/unit/Swift/Transport/EsmtpTransportTest.php @@ -156,13 +156,13 @@ public function testHeloIsUsedAsFallback() } catch (Exception $e) { $this->fail( 'Starting Esmtp should fallback to HELO if needed and accept 250 response' - ); + ); } } public function testInvalidHeloResponseCausesException() { - //Overridden to first try EHLO + // Overridden to first try EHLO $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); @@ -236,7 +236,7 @@ public function testDomainNameIsPlacedInEhlo() public function testDomainNameIsPlacedInHelo() { - //Overridden to include ESMTP + // Overridden to include ESMTP /* -- RFC 2821, 4.1.4. The SMTP client MUST, if possible, ensure that the domain parameter @@ -645,7 +645,7 @@ public function testFluidInterface() ->setEncryption('tls') ->setTimeout(30) ->setPipelining(false) - ; + ; $this->assertEquals($ref, $smtp); } } diff --git a/tests/unit/Swift/Transport/FailoverTransportTest.php b/tests/unit/Swift/Transport/FailoverTransportTest.php index 822983499..58eb786fa 100644 --- a/tests/unit/Swift/Transport/FailoverTransportTest.php +++ b/tests/unit/Swift/Transport/FailoverTransportTest.php @@ -1,6 +1,6 @@ shouldReceive('send') ->twice() - ->with(\Mockery::anyOf($message1, $message2), \Mockery::any()) + ->with(Mockery::anyOf($message1, $message2), Mockery::any()) ->andReturnUsing(function () use (&$connectionState) { if ($connectionState) { return 1; @@ -63,7 +63,7 @@ public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() }); $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $e) { if ($connectionState1) { throw $e; @@ -84,7 +84,7 @@ public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() }); $t2->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2) { if ($connectionState2) { return 1; @@ -117,7 +117,7 @@ public function testZeroIsReturnedIfTransportReturnsZero() $testCase = $this; $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState, $testCase) { if (!$connectionState) { $testCase->fail(); @@ -158,7 +158,7 @@ public function testTransportsWhichThrowExceptionsAreNotRetried() }); $t1->shouldReceive('send') ->once() - ->with($message1, \Mockery::any()) + ->with($message1, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $e) { if ($connectionState1) { throw $e; @@ -166,13 +166,13 @@ public function testTransportsWhichThrowExceptionsAreNotRetried() }); $t1->shouldReceive('send') ->never() - ->with($message2, \Mockery::any()); + ->with($message2, Mockery::any()); $t1->shouldReceive('send') ->never() - ->with($message3, \Mockery::any()); + ->with($message3, Mockery::any()); $t1->shouldReceive('send') ->never() - ->with($message4, \Mockery::any()); + ->with($message4, Mockery::any()); $t2->shouldReceive('isStarted') ->zeroOrMoreTimes() @@ -188,7 +188,7 @@ public function testTransportsWhichThrowExceptionsAreNotRetried() }); $t2->shouldReceive('send') ->times(4) - ->with(\Mockery::anyOf($message1, $message2, $message3, $message4), \Mockery::any()) + ->with(Mockery::anyOf($message1, $message2, $message3, $message4), Mockery::any()) ->andReturnUsing(function () use (&$connectionState2) { if ($connectionState2) { return 1; @@ -227,7 +227,7 @@ public function testExceptionIsThrownIfAllTransportsDie() }); $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $e) { if ($connectionState1) { throw $e; @@ -248,7 +248,7 @@ public function testExceptionIsThrownIfAllTransportsDie() }); $t2->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $e) { if ($connectionState2) { throw $e; @@ -328,7 +328,7 @@ public function testTransportShowsAsNotStartedIfAllDelegatesDead() }); $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $e) { if ($connectionState1) { $connectionState1 = false; @@ -350,7 +350,7 @@ public function testTransportShowsAsNotStartedIfAllDelegatesDead() }); $t2->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $e) { if ($connectionState2) { $connectionState2 = false; @@ -395,7 +395,7 @@ public function testRestartingTransportRestartsDeadDelegates() }); $t1->shouldReceive('send') ->once() - ->with($message1, \Mockery::any()) + ->with($message1, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $e) { if ($connectionState1) { $connectionState1 = false; @@ -404,7 +404,7 @@ public function testRestartingTransportRestartsDeadDelegates() }); $t1->shouldReceive('send') ->once() - ->with($message2, \Mockery::any()) + ->with($message2, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1) { if ($connectionState1) { return 10; @@ -425,7 +425,7 @@ public function testRestartingTransportRestartsDeadDelegates() }); $t2->shouldReceive('send') ->once() - ->with($message1, \Mockery::any()) + ->with($message1, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $e) { if ($connectionState2) { $connectionState2 = false; @@ -434,7 +434,7 @@ public function testRestartingTransportRestartsDeadDelegates() }); $t2->shouldReceive('send') ->never() - ->with($message2, \Mockery::any()); + ->with($message2, Mockery::any()); $transport = $this->getTransport([$t1, $t2]); $transport->start(); @@ -445,7 +445,7 @@ public function testRestartingTransportRestartsDeadDelegates() } catch (Exception $e) { $this->assertFalse($transport->isStarted()); } - //Restart and re-try + // Restart and re-try $transport->start(); $this->assertTrue($transport->isStarted()); $this->assertEquals(10, $transport->send($message2)); diff --git a/tests/unit/Swift/Transport/LoadBalancedTransportTest.php b/tests/unit/Swift/Transport/LoadBalancedTransportTest.php index 70997a48c..ca4983c82 100644 --- a/tests/unit/Swift/Transport/LoadBalancedTransportTest.php +++ b/tests/unit/Swift/Transport/LoadBalancedTransportTest.php @@ -1,6 +1,6 @@ shouldReceive('send') ->once() - ->with($message1, \Mockery::any()) + ->with($message1, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $testCase) { if ($connectionState1) { return 1; @@ -35,7 +35,7 @@ public function testEachTransportIsUsedInTurn() }); $t1->shouldReceive('send') ->never() - ->with($message2, \Mockery::any()); + ->with($message2, Mockery::any()); $t2->shouldReceive('isStarted') ->zeroOrMoreTimes() @@ -51,7 +51,7 @@ public function testEachTransportIsUsedInTurn() }); $t2->shouldReceive('send') ->once() - ->with($message2, \Mockery::any()) + ->with($message2, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $testCase) { if ($connectionState2) { return 1; @@ -60,7 +60,7 @@ public function testEachTransportIsUsedInTurn() }); $t2->shouldReceive('send') ->never() - ->with($message1, \Mockery::any()); + ->with($message1, Mockery::any()); $transport = $this->getTransport([$t1, $t2]); $transport->start(); @@ -94,7 +94,7 @@ public function testTransportsAreReusedInRotatingFashion() }); $t1->shouldReceive('send') ->once() - ->with($message1, \Mockery::any()) + ->with($message1, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $testCase) { if ($connectionState1) { return 1; @@ -103,10 +103,10 @@ public function testTransportsAreReusedInRotatingFashion() }); $t1->shouldReceive('send') ->never() - ->with($message2, \Mockery::any()); + ->with($message2, Mockery::any()); $t1->shouldReceive('send') ->once() - ->with($message3, \Mockery::any()) + ->with($message3, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $testCase) { if ($connectionState1) { return 1; @@ -115,7 +115,7 @@ public function testTransportsAreReusedInRotatingFashion() }); $t1->shouldReceive('send') ->never() - ->with($message4, \Mockery::any()); + ->with($message4, Mockery::any()); $t2->shouldReceive('isStarted') ->zeroOrMoreTimes() @@ -131,7 +131,7 @@ public function testTransportsAreReusedInRotatingFashion() }); $t2->shouldReceive('send') ->once() - ->with($message2, \Mockery::any()) + ->with($message2, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $testCase) { if ($connectionState2) { return 1; @@ -140,10 +140,10 @@ public function testTransportsAreReusedInRotatingFashion() }); $t2->shouldReceive('send') ->never() - ->with($message1, \Mockery::any()); + ->with($message1, Mockery::any()); $t2->shouldReceive('send') ->once() - ->with($message4, \Mockery::any()) + ->with($message4, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $testCase) { if ($connectionState2) { return 1; @@ -152,7 +152,7 @@ public function testTransportsAreReusedInRotatingFashion() }); $t2->shouldReceive('send') ->never() - ->with($message3, \Mockery::any()); + ->with($message3, Mockery::any()); $transport = $this->getTransport([$t1, $t2]); $transport->start(); @@ -188,7 +188,7 @@ public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() }); $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $e, $testCase) { if ($connectionState1) { throw $e; @@ -210,7 +210,7 @@ public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() }); $t2->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $testCase) { if ($connectionState2) { return 1; @@ -245,7 +245,7 @@ public function testMessageIsTriedOnNextTransportIfZeroReturned() }); $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1) { if ($connectionState1) { return 0; @@ -268,7 +268,7 @@ public function testMessageIsTriedOnNextTransportIfZeroReturned() }); $t2->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2) { if ($connectionState2) { return 1; @@ -304,7 +304,7 @@ public function testZeroIsReturnedIfAllTransportsReturnZero() }); $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1) { if ($connectionState1) { return 0; @@ -327,7 +327,7 @@ public function testZeroIsReturnedIfAllTransportsReturnZero() }); $t2->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2) { if ($connectionState2) { return 0; @@ -340,83 +340,84 @@ public function testZeroIsReturnedIfAllTransportsReturnZero() $transport->start(); $this->assertEquals(0, $transport->send($message)); } -/* -FIXME: Does not work anymore after upgrading Mockery - public function testTransportsWhichThrowExceptionsAreNotRetried() - { - $e = new Swift_TransportException('maur b0rken'); - - $message1 = $this->getMockery('Swift_Mime_SimpleMessage'); - $message2 = $this->getMockery('Swift_Mime_SimpleMessage'); - $message3 = $this->getMockery('Swift_Mime_SimpleMessage'); - $message4 = $this->getMockery('Swift_Mime_SimpleMessage'); - $t1 = $this->getMockery('Swift_Transport'); - $t2 = $this->getMockery('Swift_Transport'); - $connectionState1 = false; - $connectionState2 = false; - - $testCase = $this; - $t1->shouldReceive('isStarted') - ->zeroOrMoreTimes() - ->andReturnUsing(function () use (&$connectionState1) { - return $connectionState1; - }); - $t1->shouldReceive('start') - ->once() - ->andReturnUsing(function () use (&$connectionState1) { - if (!$connectionState1) { - $connectionState1 = true; - } - }); - $t1->shouldReceive('send') - ->once() - ->with($message1, \Mockery::any()) - ->andReturnUsing(function () use (&$connectionState1, $e, $testCase) { - if ($connectionState1) { - throw $e; - } - $testCase->fail(); - }); - $t1->shouldReceive('send') - ->never() - ->with($message2, \Mockery::any()); - $t1->shouldReceive('send') - ->never() - ->with($message3, \Mockery::any()); - $t1->shouldReceive('send') - ->never() - ->with($message4, \Mockery::any()); - $t2->shouldReceive('isStarted') - ->zeroOrMoreTimes() - ->andReturnUsing(function () use (&$connectionState2) { - return $connectionState2; - }); - $t2->shouldReceive('start') - ->once() - ->andReturnUsing(function () use (&$connectionState2) { - if (!$connectionState2) { - $connectionState2 = true; - } - }); - $t2->shouldReceive('send') - ->times(4) - ->with(\Mockery::anyOf($message1, $message3, $message3, $message4), \Mockery::any()) - ->andReturnUsing(function () use (&$connectionState2, $testCase) { - if ($connectionState2) { - return 1; - } - $testCase->fail(); - }); - - $transport = $this->getTransport([$t1, $t2]); - $transport->start(); - $this->assertEquals(1, $transport->send($message1)); - $this->assertEquals(1, $transport->send($message2)); - $this->assertEquals(1, $transport->send($message3)); - $this->assertEquals(1, $transport->send($message4)); - } -*/ + /* + FIXME: Does not work anymore after upgrading Mockery + public function testTransportsWhichThrowExceptionsAreNotRetried() + { + $e = new Swift_TransportException('maur b0rken'); + + $message1 = $this->getMockery('Swift_Mime_SimpleMessage'); + $message2 = $this->getMockery('Swift_Mime_SimpleMessage'); + $message3 = $this->getMockery('Swift_Mime_SimpleMessage'); + $message4 = $this->getMockery('Swift_Mime_SimpleMessage'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $testCase = $this; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState1, $e, $testCase) { + if ($connectionState1) { + throw $e; + } + $testCase->fail(); + }); + $t1->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message3, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message4, \Mockery::any()); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function () use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function () use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->times(4) + ->with(\Mockery::anyOf($message1, $message3, $message3, $message4), \Mockery::any()) + ->andReturnUsing(function () use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + + $transport = $this->getTransport([$t1, $t2]); + $transport->start(); + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + $this->assertEquals(1, $transport->send($message3)); + $this->assertEquals(1, $transport->send($message4)); + } + */ public function testExceptionIsThrownIfAllTransportsDie() { $e = new Swift_TransportException('b0rken'); @@ -441,7 +442,7 @@ public function testExceptionIsThrownIfAllTransportsDie() }); $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $e) { if ($connectionState1) { throw $e; @@ -462,7 +463,7 @@ public function testExceptionIsThrownIfAllTransportsDie() }); $t2->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $e) { if ($connectionState2) { throw $e; @@ -540,7 +541,7 @@ public function testTransportShowsAsNotStartedIfAllDelegatesDead() }); $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $e) { if ($connectionState1) { throw $e; @@ -561,7 +562,7 @@ public function testTransportShowsAsNotStartedIfAllDelegatesDead() }); $t2->shouldReceive('send') ->once() - ->with($message, \Mockery::any()) + ->with($message, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $e) { if ($connectionState2) { throw $e; @@ -604,7 +605,7 @@ public function testRestartingTransportRestartsDeadDelegates() }); $t1->shouldReceive('send') ->once() - ->with($message1, \Mockery::any()) + ->with($message1, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1, $e) { if ($connectionState1) { $connectionState1 = false; @@ -613,7 +614,7 @@ public function testRestartingTransportRestartsDeadDelegates() }); $t1->shouldReceive('send') ->once() - ->with($message2, \Mockery::any()) + ->with($message2, Mockery::any()) ->andReturnUsing(function () use (&$connectionState1) { if ($connectionState1) { return 10; @@ -634,7 +635,7 @@ public function testRestartingTransportRestartsDeadDelegates() }); $t2->shouldReceive('send') ->once() - ->with($message1, \Mockery::any()) + ->with($message1, Mockery::any()) ->andReturnUsing(function () use (&$connectionState2, $e) { if ($connectionState2) { throw $e; @@ -642,7 +643,7 @@ public function testRestartingTransportRestartsDeadDelegates() }); $t2->shouldReceive('send') ->never() - ->with($message2, \Mockery::any()); + ->with($message2, Mockery::any()); $transport = $this->getTransport([$t1, $t2]); $transport->start(); @@ -653,7 +654,7 @@ public function testRestartingTransportRestartsDeadDelegates() } catch (Exception $e) { $this->assertFalse($transport->isStarted()); } - //Restart and re-try + // Restart and re-try $transport->start(); $this->assertTrue($transport->isStarted()); $this->assertEquals(10, $transport->send($message2)); @@ -682,7 +683,7 @@ public function testFailureReferenceIsPassedToDelegates() }); $t1->shouldReceive('send') ->once() - ->with($message, \Mockery::on(function (&$var) use (&$failures, $testCase) { + ->with($message, Mockery::on(function (&$var) use (&$failures, $testCase) { return $testCase->varsAreReferences($var, $failures); })) ->andReturnUsing(function () use (&$connectionState) { diff --git a/tests/unit/Swift/Transport/SendmailTransportTest.php b/tests/unit/Swift/Transport/SendmailTransportTest.php index fe40d6c8a..2bdb931b8 100644 --- a/tests/unit/Swift/Transport/SendmailTransportTest.php +++ b/tests/unit/Swift/Transport/SendmailTransportTest.php @@ -33,7 +33,7 @@ public function testCommandCanBeSetAndFetched() $this->assertEquals('/usr/sbin/sendmail -oi -t', $sendmail->getCommand()); } - public function testSendingMessageIn_t_ModeUsesSimplePipe() + public function testSendingMessageInTModeUsesSimplePipe() { $buf = $this->getBuffer(); $sendmail = $this->getSendmail($buf); @@ -60,7 +60,7 @@ public function testSendingMessageIn_t_ModeUsesSimplePipe() $this->assertEquals(2, $sendmail->send($message)); } - public function testSendingIn_t_ModeWith_i_FlagDoesntEscapeDot() + public function testSendingInTModeWithIFlagDoesntEscapeDot() { $buf = $this->getBuffer(); $sendmail = $this->getSendmail($buf); @@ -87,7 +87,7 @@ public function testSendingIn_t_ModeWith_i_FlagDoesntEscapeDot() $this->assertEquals(2, $sendmail->send($message)); } - public function testSendingInTModeWith_oi_FlagDoesntEscapeDot() + public function testSendingInTModeWithOiFlagDoesntEscapeDot() { $buf = $this->getBuffer(); $sendmail = $this->getSendmail($buf); diff --git a/tests/unit/Swift/Transport/StreamBufferTest.php b/tests/unit/Swift/Transport/StreamBufferTest.php index 7a9d22857..d89afbced 100644 --- a/tests/unit/Swift/Transport/StreamBufferTest.php +++ b/tests/unit/Swift/Transport/StreamBufferTest.php @@ -1,6 +1,6 @@