From e258e45a3847983df6824b8028262e6eb5eb688f Mon Sep 17 00:00:00 2001 From: Zaahid Bateson Date: Mon, 18 Mar 2024 00:31:53 -0700 Subject: [PATCH] PhpCsFixer cleanup --- .php-cs-fixer.dist.php | 4 +-- src/Error.php | 4 +-- src/ErrorBag.php | 9 +++--- src/Header/AbstractHeader.php | 32 +++++++++---------- .../Consumer/AbstractConsumerService.php | 27 ++++++++-------- .../Consumer/AddressBaseConsumerService.php | 6 ++-- .../Consumer/AddressEmailConsumerService.php | 2 +- .../Consumer/AddressGroupConsumerService.php | 5 ++- .../Consumer/CommentConsumerService.php | 4 +-- src/Header/Consumer/DateConsumerService.php | 2 +- .../Consumer/GenericConsumerService.php | 2 +- src/Header/Consumer/IConsumerService.php | 2 +- src/Header/Consumer/IdBaseConsumerService.php | 2 +- src/Header/Consumer/IdConsumerService.php | 4 +-- .../GenericReceivedConsumerService.php | 2 +- .../Consumer/ReceivedConsumerService.php | 4 +-- .../Consumer/SubjectConsumerService.php | 4 +-- src/Header/DateHeader.php | 4 +-- src/Header/HeaderFactory.php | 10 +++--- src/Header/IHeaderPart.php | 2 +- src/Header/IdHeader.php | 7 ++-- src/Header/Part/AddressGroupPart.php | 4 +-- src/Header/Part/AddressPart.php | 2 +- src/Header/Part/DatePart.php | 2 +- src/Header/Part/HeaderPart.php | 4 +-- src/IMessage.php | 4 +-- src/MailMimeParser.php | 19 +++++------ src/Message.php | 12 +++---- src/Message/Factory/IMessagePartFactory.php | 8 +---- src/Message/Factory/IMimePartFactory.php | 6 ---- .../Factory/PartStreamContainerFactory.php | 3 -- src/Message/Helper/PrivacyHelper.php | 2 +- src/Message/IMessagePart.php | 2 +- src/Message/IMimePart.php | 3 +- src/Message/IMultiPart.php | 14 ++++---- src/Message/MessagePart.php | 8 ++--- src/Message/MimePart.php | 6 ++-- src/Message/MultiPart.php | 21 +++++------- src/Message/PartFilter.php | 1 - src/Message/PartHeaderContainer.php | 2 +- src/Message/UUEncodedPart.php | 2 +- src/Parser/MessageParserService.php | 2 +- src/Parser/NonMimeParserService.php | 3 -- .../Proxy/ParserMessageProxyFactory.php | 6 ---- src/Parser/Proxy/ParserMimePartProxy.php | 32 +++++++++---------- .../Proxy/ParserMimePartProxyFactory.php | 9 ------ src/Parser/Proxy/ParserPartProxy.php | 4 +-- src/Parser/Proxy/ParserPartProxyFactory.php | 1 - .../Proxy/ParserUUEncodedPartProxyFactory.php | 3 -- src/Stream/HeaderStream.php | 6 ++-- src/Stream/MessagePartStream.php | 4 +-- src/di_config.php | 9 +----- tests/MailMimeParser/ErrorBagTest.php | 4 +-- tests/MailMimeParser/ErrorTest.php | 4 +-- .../Header/AddressHeaderTest.php | 8 ++--- .../Consumer/AbstractConsumerServiceTest.php | 2 +- .../Received/DomainConsumerServiceTest.php | 3 +- .../GenericReceivedConsumerServiceTest.php | 2 +- .../ReceivedDateConsumerServiceTest.php | 2 +- .../MailMimeParser/Header/DateHeaderTest.php | 2 +- .../Header/GenericHeaderTest.php | 2 +- .../Header/HeaderFactoryTest.php | 2 +- tests/MailMimeParser/Header/IdHeaderTest.php | 2 +- .../Header/ParameterHeaderTest.php | 2 +- .../Header/Part/AddressGroupPartTest.php | 5 ++- .../Header/Part/AddressPartTest.php | 2 +- .../Header/Part/CommentPartTest.php | 2 +- .../Header/Part/DatePartTest.php | 2 +- .../Header/Part/HeaderPartFactoryTest.php | 2 +- .../Header/Part/HeaderPartTest.php | 2 +- .../Header/Part/LiteralPartTest.php | 2 +- .../Part/MimeLiteralPartFactoryTest.php | 2 +- .../Header/Part/MimeLiteralPartTest.php | 2 +- .../Header/Part/ParameterPartTest.php | 2 +- .../Header/Part/ReceivedDomainPartTest.php | 2 +- .../Header/Part/ReceivedPartTest.php | 2 +- .../Header/Part/SplitParameterTokenTest.php | 2 +- .../MailMimeParser/Header/Part/TokenTest.php | 2 +- .../Header/ReceivedHeaderTest.php | 2 +- .../IntegrationTests/EmailFunctionalTest.php | 3 -- tests/MailMimeParser/MailMimeParserTest.php | 6 ++-- tests/MailMimeParser/MessageTest.php | 2 +- .../Parser/ParserManagerServiceTest.php | 2 +- tests/generate-encoded.php | 1 + tests/generate-mime-encoded.php | 1 + 85 files changed, 182 insertions(+), 243 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 53d0197f..2626f872 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -10,6 +10,6 @@ return $config->setFinder(PhpCsFixer\Finder::create() ->exclude('vendor') - ->in(__DIR__.'\src') - ->in(__DIR__.'\tests') + ->in(__DIR__.'/src') + ->in(__DIR__.'/tests') ); diff --git a/src/Error.php b/src/Error.php index a0c9565e..544cda20 100644 --- a/src/Error.php +++ b/src/Error.php @@ -7,9 +7,9 @@ namespace ZBateson\MailMimeParser; -use Throwable; use InvalidArgumentException; use Psr\Log\LogLevel; +use Throwable; /** * Holds information about an error or notice that happened on a specific @@ -90,7 +90,7 @@ public function getPsrLevel() : string */ public function getClass() : string { - return get_class($this->object); + return \get_class($this->object); } /** diff --git a/src/ErrorBag.php b/src/ErrorBag.php index 3f09d874..8019f309 100644 --- a/src/ErrorBag.php +++ b/src/ErrorBag.php @@ -41,7 +41,6 @@ public function __construct() /** * Returns the class name. Override to identify objects in logs. * - * @return string */ public function getErrorLoggingContextName() : string { @@ -83,7 +82,7 @@ public function addError(string $message, string $psrLogLevel, ?Throwable $excep return $this; } - public function getErrors(bool $validate = false, string $minPsrLevel = LogLevel::ERROR): array + public function getErrors(bool $validate = false, string $minPsrLevel = LogLevel::ERROR) : array { if ($validate && !$this->validated) { $this->validated = true; @@ -91,7 +90,7 @@ public function getErrors(bool $validate = false, string $minPsrLevel = LogLevel } return \array_values(\array_filter( $this->errors, - function ($e) use ($minPsrLevel) { + function($e) use ($minPsrLevel) { return $e->isPsrLevelGreaterOrEqualTo($minPsrLevel); } )); @@ -99,13 +98,13 @@ function ($e) use ($minPsrLevel) { public function hasErrors(bool $validate = false, string $minPsrLevel = LogLevel::ERROR) : bool { - return (count($this->getErrors($validate, $minPsrLevel)) > 0); + return (\count($this->getErrors($validate, $minPsrLevel)) > 0); } public function getAllErrors(bool $validate = false, string $minPsrLevel = LogLevel::ERROR) : array { $arr = \array_values(\array_map( - function ($e) use ($validate, $minPsrLevel) { + function($e) use ($validate, $minPsrLevel) { return $e->getAllErrors($validate, $minPsrLevel) ?? []; }, $this->getErrorBagChildren() diff --git a/src/Header/AbstractHeader.php b/src/Header/AbstractHeader.php index 6d3ca1e3..48af79f9 100644 --- a/src/Header/AbstractHeader.php +++ b/src/Header/AbstractHeader.php @@ -7,11 +7,11 @@ namespace ZBateson\MailMimeParser\Header; -use ZBateson\MailMimeParser\MailMimeParser; +use Psr\Log\LogLevel; use ZBateson\MailMimeParser\ErrorBag; use ZBateson\MailMimeParser\Header\Consumer\IConsumerService; use ZBateson\MailMimeParser\Header\Part\CommentPart; -use Psr\Log\LogLevel; +use ZBateson\MailMimeParser\MailMimeParser; /** * Abstract base class representing a mime email's header. @@ -40,14 +40,14 @@ abstract class AbstractHeader extends ErrorBag implements IHeader protected array $allParts = []; /** - * @var string[] array of comments, initialized on demand in getComments() + * @var string the raw value */ - private ?array $comments = null; + protected string $rawValue; /** - * @var string the raw value + * @var string[] array of comments, initialized on demand in getComments() */ - protected string $rawValue; + private ?array $comments = null; /** * Assigns the header's name and raw value, then calls parseHeaderValue to @@ -76,7 +76,7 @@ public function __construct( */ protected function filterAndAssignToParts() : void { - $this->parts = \array_values(\array_filter($this->allParts, function ($p) { + $this->parts = \array_values(\array_filter($this->allParts, function($p) { return !($p instanceof CommentPart); })); } @@ -117,10 +117,10 @@ public function getComments() : array { if ($this->comments === null) { $this->comments = \array_values(\array_map( - function ($p) { return $p->getComment(); }, + function($p) { return $p->getComment(); }, \array_filter( $this->allParts, - function ($p) { return ($p instanceof CommentPart); } + function($p) { return ($p instanceof CommentPart); } ) )); } @@ -150,7 +150,7 @@ public function __toString() : string return "{$this->name}: {$this->rawValue}"; } - public function getErrorLoggingContextName(): string + public function getErrorLoggingContextName() : string { return 'Header::' . $this->getName(); } @@ -162,10 +162,10 @@ protected function getErrorBagChildren() : array protected function validate() : void { - if (strlen(trim($this->name)) === 0) { + if (\strlen(\trim($this->name)) === 0) { $this->addError('Header doesn\'t have a name', LogLevel::ERROR); } - if (strlen(trim($this->rawValue)) === 0) { + if (\strlen(\trim($this->rawValue)) === 0) { $this->addError('Header doesn\'t have a value', LogLevel::NOTICE); } } @@ -187,11 +187,11 @@ protected static function getHeaderPartsFrom(string $nameOrLine, ?string $value $valuePart = $value; if ($value === null) { // full header line - $parts = explode(':', $nameOrLine, 2); - $namePart = (count($parts) > 1) ? $parts[0] : ''; - $valuePart = trim((count($parts) > 1) ? $parts[1] : $parts[0]); + $parts = \explode(':', $nameOrLine, 2); + $namePart = (\count($parts) > 1) ? $parts[0] : ''; + $valuePart = \trim((\count($parts) > 1) ? $parts[1] : $parts[0]); } - return [ $namePart, $valuePart ]; + return [$namePart, $valuePart]; } /** diff --git a/src/Header/Consumer/AbstractConsumerService.php b/src/Header/Consumer/AbstractConsumerService.php index 11bf8fbc..20eb7b95 100644 --- a/src/Header/Consumer/AbstractConsumerService.php +++ b/src/Header/Consumer/AbstractConsumerService.php @@ -8,14 +8,14 @@ namespace ZBateson\MailMimeParser\Header\Consumer; use ArrayIterator; +use DI\Attribute\Inject; use Iterator; use NoRewindIterator; -use DI\Attribute\Inject; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; use ZBateson\MailMimeParser\Header\IHeaderPart; use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; use ZBateson\MailMimeParser\Header\Part\MimeLiteralPart; -use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; /** * Abstract base class for all header token consumers. @@ -35,12 +35,6 @@ abstract class AbstractConsumerService implements IConsumerService */ protected HeaderPartFactory $partFactory; - /** - * @var ?string the generated token split pattern on first run, so it doesn't - * need to be regenerated every time. - */ - private ?string $tokenSplitPattern = null; - /** * @var AbstractConsumerService[] array of sub-consumers used by this * consumer if any, or an empty array if none exist. @@ -48,7 +42,12 @@ abstract class AbstractConsumerService implements IConsumerService protected array $subConsumers = []; /** - * @param HeaderPartFactory $partFactory + * @var ?string the generated token split pattern on first run, so it doesn't + * need to be regenerated every time. + */ + private ?string $tokenSplitPattern = null; + + /** * @param AbstractConsumerService[] $subConsumers */ public function __construct(HeaderPartFactory $partFactory, array $subConsumers = []) @@ -60,12 +59,12 @@ public function __construct(HeaderPartFactory $partFactory, array $subConsumers public function __invoke(string $value) : array { - $this->logger->debug('Starting ${class} for "${value}"', [ 'class' => static::class, 'value' => $value ]); + $this->logger->debug('Starting ${class} for "${value}"', ['class' => static::class, 'value' => $value]); if ($value !== '') { $parts = $this->parseRawValue($value); $this->logger->debug( 'Ending ${class} for "${value}": parsed into ${cnt} header part objects', - [ 'class' => static::class, 'value' => $value, 'cnt' => count($parts) ] + ['class' => static::class, 'value' => $value, 'cnt' => \count($parts)] ); return $parts; } @@ -173,7 +172,7 @@ protected function splitRawValue($rawValue) : array $this->tokenSplitPattern = $this->getTokenSplitPattern(); $this->logger->debug( 'Configuring ${class} with token split pattern: ${pattern}', - [ 'class' => static::class, 'pattern' => $this->tokenSplitPattern] + ['class' => static::class, 'pattern' => $this->tokenSplitPattern] ); } return \preg_split( @@ -245,7 +244,7 @@ protected function getConsumerTokenParts(Iterator $tokens) : array if ($consumer->isStartToken($token)) { $this->logger->debug( 'Token: "${value}" in ${class} starting sub-consumer ${consumer}', - [ 'value' => $token, 'class' => static::class, 'consumer' => get_class($consumer) ] + ['value' => $token, 'class' => static::class, 'consumer' => \get_class($consumer)] ); $this->advanceToNextToken($tokens, true); return $consumer->parseTokensIntoParts($tokens); diff --git a/src/Header/Consumer/AddressBaseConsumerService.php b/src/Header/Consumer/AddressBaseConsumerService.php index 92069686..588b5829 100644 --- a/src/Header/Consumer/AddressBaseConsumerService.php +++ b/src/Header/Consumer/AddressBaseConsumerService.php @@ -7,9 +7,9 @@ namespace ZBateson\MailMimeParser\Header\Consumer; -use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; -use ZBateson\MailMimeParser\Header\IHeaderPart; use Iterator; +use ZBateson\MailMimeParser\Header\IHeaderPart; +use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; /** * Serves as a base-consumer for recipient/sender email address headers (like @@ -27,7 +27,7 @@ public function __construct( HeaderPartFactory $partFactory, AddressConsumerService $addressConsumerService ) { - parent::__construct($partFactory, [ $addressConsumerService ]); + parent::__construct($partFactory, [$addressConsumerService]); } /** diff --git a/src/Header/Consumer/AddressEmailConsumerService.php b/src/Header/Consumer/AddressEmailConsumerService.php index 2c948433..945fc0ba 100644 --- a/src/Header/Consumer/AddressEmailConsumerService.php +++ b/src/Header/Consumer/AddressEmailConsumerService.php @@ -29,7 +29,7 @@ public function __construct( ) { parent::__construct( $partFactory, - [ $commentConsumerService, $quotedStringConsumerService ] + [$commentConsumerService, $quotedStringConsumerService] ); } diff --git a/src/Header/Consumer/AddressGroupConsumerService.php b/src/Header/Consumer/AddressGroupConsumerService.php index db51b2f6..021d6d5f 100644 --- a/src/Header/Consumer/AddressGroupConsumerService.php +++ b/src/Header/Consumer/AddressGroupConsumerService.php @@ -7,8 +7,8 @@ namespace ZBateson\MailMimeParser\Header\Consumer; -use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; use ZBateson\MailMimeParser\Header\Part\AddressGroupPart; +use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; /** * Parses a single group of addresses (as a named-group part of an address @@ -37,8 +37,7 @@ public function __construct(HeaderPartFactory $partFactory) /** * Needs to be called in AddressConsumerService's constructor to avoid a * circular dependency. - * - * @param AddressConsumerService $subConsumer + * */ public function setAddressConsumerService(AddressConsumerService $subConsumer) : void { diff --git a/src/Header/Consumer/CommentConsumerService.php b/src/Header/Consumer/CommentConsumerService.php index f443b87a..3f5579bf 100644 --- a/src/Header/Consumer/CommentConsumerService.php +++ b/src/Header/Consumer/CommentConsumerService.php @@ -7,11 +7,11 @@ namespace ZBateson\MailMimeParser\Header\Consumer; -use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory; +use Iterator; use ZBateson\MailMimeParser\Header\IHeaderPart; use ZBateson\MailMimeParser\Header\Part\CommentPart; use ZBateson\MailMimeParser\Header\Part\LiteralPart; -use Iterator; +use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory; /** * Consumes all tokens within parentheses as comments. diff --git a/src/Header/Consumer/DateConsumerService.php b/src/Header/Consumer/DateConsumerService.php index 90d460b4..892c1af7 100644 --- a/src/Header/Consumer/DateConsumerService.php +++ b/src/Header/Consumer/DateConsumerService.php @@ -45,7 +45,7 @@ protected function processParts(array $parts) : array foreach ($parts as $part) { $strValue .= $part->getValue(); } - $comments = \array_values(\array_filter($parts, function ($part) { + $comments = \array_values(\array_filter($parts, function($part) { return ($part instanceof CommentPart); })); return \array_merge([$this->partFactory->newDatePart($strValue)], $comments); diff --git a/src/Header/Consumer/GenericConsumerService.php b/src/Header/Consumer/GenericConsumerService.php index 9b42509f..5b8b0f4d 100644 --- a/src/Header/Consumer/GenericConsumerService.php +++ b/src/Header/Consumer/GenericConsumerService.php @@ -25,7 +25,7 @@ public function __construct( ) { parent::__construct( $partFactory, - [ $commentConsumerService, $quotedStringConsumerService ] + [$commentConsumerService, $quotedStringConsumerService] ); } } diff --git a/src/Header/Consumer/IConsumerService.php b/src/Header/Consumer/IConsumerService.php index 20013c34..cd124ab4 100644 --- a/src/Header/Consumer/IConsumerService.php +++ b/src/Header/Consumer/IConsumerService.php @@ -22,5 +22,5 @@ interface IConsumerService * @return \ZBateson\MailMimeParser\Header\IHeaderPart[] the array of parsed * parts */ - function __invoke(string $value) : array; + public function __invoke(string $value) : array; } diff --git a/src/Header/Consumer/IdBaseConsumerService.php b/src/Header/Consumer/IdBaseConsumerService.php index 829d280e..7e787705 100644 --- a/src/Header/Consumer/IdBaseConsumerService.php +++ b/src/Header/Consumer/IdBaseConsumerService.php @@ -7,8 +7,8 @@ namespace ZBateson\MailMimeParser\Header\Consumer; -use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; use ZBateson\MailMimeParser\Header\IHeaderPart; +use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; /** * Serves as a base-consumer for ID headers (like Message-ID and Content-ID). diff --git a/src/Header/Consumer/IdConsumerService.php b/src/Header/Consumer/IdConsumerService.php index 1612d871..9da17700 100644 --- a/src/Header/Consumer/IdConsumerService.php +++ b/src/Header/Consumer/IdConsumerService.php @@ -65,10 +65,10 @@ protected function getPartForToken(string $token, bool $isLiteral) : ?IHeaderPar */ protected function processParts(array $parts) : array { - $id = \array_reduce(\array_filter($parts), function ($c, $p) { + $id = \array_reduce(\array_filter($parts), function($c, $p) { return $c . $p->getValue(); }, ''); - return array_merge([$this->partFactory->newLiteralPart($id)], \array_values(\array_filter($parts, function ($p) { + return \array_merge([$this->partFactory->newLiteralPart($id)], \array_values(\array_filter($parts, function($p) { return ($p instanceof CommentPart); }))); } diff --git a/src/Header/Consumer/Received/GenericReceivedConsumerService.php b/src/Header/Consumer/Received/GenericReceivedConsumerService.php index 7f2a7e09..6ecdac77 100644 --- a/src/Header/Consumer/Received/GenericReceivedConsumerService.php +++ b/src/Header/Consumer/Received/GenericReceivedConsumerService.php @@ -56,7 +56,7 @@ public function __construct( CommentConsumerService $commentConsumerService, string $partName ) { - parent::__construct($partFactory, [ $commentConsumerService ]); + parent::__construct($partFactory, [$commentConsumerService]); $this->partName = $partName; } diff --git a/src/Header/Consumer/ReceivedConsumerService.php b/src/Header/Consumer/ReceivedConsumerService.php index 9dc1ab72..b3d130c1 100644 --- a/src/Header/Consumer/ReceivedConsumerService.php +++ b/src/Header/Consumer/ReceivedConsumerService.php @@ -8,11 +8,11 @@ namespace ZBateson\MailMimeParser\Header\Consumer; use Iterator; -use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; -use ZBateson\MailMimeParser\Header\Part\Token; use ZBateson\MailMimeParser\Header\Consumer\Received\DomainConsumerService; use ZBateson\MailMimeParser\Header\Consumer\Received\GenericReceivedConsumerService; use ZBateson\MailMimeParser\Header\Consumer\Received\ReceivedDateConsumerService; +use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; +use ZBateson\MailMimeParser\Header\Part\Token; /** * Parses a Received header into ReceivedParts, ReceivedDomainParts, a DatePart, diff --git a/src/Header/Consumer/SubjectConsumerService.php b/src/Header/Consumer/SubjectConsumerService.php index b0438585..0c976b89 100644 --- a/src/Header/Consumer/SubjectConsumerService.php +++ b/src/Header/Consumer/SubjectConsumerService.php @@ -7,9 +7,9 @@ namespace ZBateson\MailMimeParser\Header\Consumer; -use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory; -use ZBateson\MailMimeParser\Header\IHeaderPart; use Iterator; +use ZBateson\MailMimeParser\Header\IHeaderPart; +use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory; /** * Extends AbstractGenericConsumerService to use a MimeLiteralPartFactory, and diff --git a/src/Header/DateHeader.php b/src/Header/DateHeader.php index 41d9d0d3..72d36a7a 100644 --- a/src/Header/DateHeader.php +++ b/src/Header/DateHeader.php @@ -7,10 +7,10 @@ namespace ZBateson\MailMimeParser\Header; -use ZBateson\MailMimeParser\Header\Consumer\DateConsumerService; -use ZBateson\MailMimeParser\Header\Part\DatePart; use DateTime; use DateTimeImmutable; +use ZBateson\MailMimeParser\Header\Consumer\DateConsumerService; +use ZBateson\MailMimeParser\Header\Part\DatePart; /** * Reads a DatePart value header in either RFC 2822 or RFC 822 format. diff --git a/src/Header/HeaderFactory.php b/src/Header/HeaderFactory.php index 95bc4469..f6744f88 100644 --- a/src/Header/HeaderFactory.php +++ b/src/Header/HeaderFactory.php @@ -8,18 +8,18 @@ namespace ZBateson\MailMimeParser\Header; use DI\Attribute\Inject; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; +use ReflectionClass; use ZBateson\MailMimeParser\Header\Consumer\AddressBaseConsumerService; use ZBateson\MailMimeParser\Header\Consumer\DateConsumerService; use ZBateson\MailMimeParser\Header\Consumer\GenericConsumerMimeLiteralPartService; +use ZBateson\MailMimeParser\Header\Consumer\IConsumerService; use ZBateson\MailMimeParser\Header\Consumer\IdBaseConsumerService; use ZBateson\MailMimeParser\Header\Consumer\ParameterConsumerService; use ZBateson\MailMimeParser\Header\Consumer\ReceivedConsumerService; use ZBateson\MailMimeParser\Header\Consumer\SubjectConsumerService; use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory; -use ZBateson\MailMimeParser\Header\Consumer\IConsumerService; -use ReflectionClass; -use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; /** * Constructs various IHeader types depending on the type of header passed. @@ -178,7 +178,7 @@ public function newInstance(string $name, string $value) : IHeader $class = $this->getClassFor($name); $this->logger->debug( 'Creating {$class} for header with name "{$name}" and value "{$value}"', - [ 'class' => $class, 'name' => $name, 'value' => $value ] + ['class' => $class, 'name' => $name, 'value' => $value] ); return $this->newInstanceOf($name, $value, $class); } diff --git a/src/Header/IHeaderPart.php b/src/Header/IHeaderPart.php index c424f381..0e43b62b 100644 --- a/src/Header/IHeaderPart.php +++ b/src/Header/IHeaderPart.php @@ -7,8 +7,8 @@ namespace ZBateson\MailMimeParser\Header; -use ZBateson\MailMimeParser\IErrorBag; use Stringable; +use ZBateson\MailMimeParser\IErrorBag; /** * Represents a single parsed part of a header line's value. diff --git a/src/Header/IdHeader.php b/src/Header/IdHeader.php index eae9c02b..ab427700 100644 --- a/src/Header/IdHeader.php +++ b/src/Header/IdHeader.php @@ -7,9 +7,9 @@ namespace ZBateson\MailMimeParser\Header; -use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory; use ZBateson\MailMimeParser\Header\Consumer\IdBaseConsumerService; use ZBateson\MailMimeParser\Header\Part\CommentPart; +use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory; /** * Represents a Content-ID, Message-ID, In-Reply-To or References header. @@ -50,9 +50,10 @@ public function getId() : ?string public function getIds() : array { return \array_values(\array_map( - function ($p) { + function($p) { return $p->getValue(); - }, \array_filter($this->parts, function ($p) { + }, + \array_filter($this->parts, function($p) { return !($p instanceof CommentPart); }) )); diff --git a/src/Header/Part/AddressGroupPart.php b/src/Header/Part/AddressGroupPart.php index b66151ea..68fea236 100644 --- a/src/Header/Part/AddressGroupPart.php +++ b/src/Header/Part/AddressGroupPart.php @@ -7,8 +7,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use Psr\Log\LogLevel; +use ZBateson\MbWrapper\MbWrapper; /** * Holds a group of addresses, and an optional group name. @@ -80,7 +80,7 @@ protected function getErrorBagChildren() : array protected function validate() : void { - if ($this->value === null || mb_strlen($this->value) === 0) { + if ($this->value === null || \mb_strlen($this->value) === 0) { $this->addError('Address group doesn\'t have a name', LogLevel::ERROR); } if (empty($this->addresses)) { diff --git a/src/Header/Part/AddressPart.php b/src/Header/Part/AddressPart.php index 96d33d8d..0cd86987 100644 --- a/src/Header/Part/AddressPart.php +++ b/src/Header/Part/AddressPart.php @@ -7,8 +7,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use Psr\Log\LogLevel; +use ZBateson\MbWrapper\MbWrapper; /** * Holds a single address or name/address pair. diff --git a/src/Header/Part/DatePart.php b/src/Header/Part/DatePart.php index 7e1fa01b..ecc9b6ec 100644 --- a/src/Header/Part/DatePart.php +++ b/src/Header/Part/DatePart.php @@ -7,10 +7,10 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use DateTime; use Exception; use Psr\Log\LogLevel; +use ZBateson\MbWrapper\MbWrapper; /** * Parses a header into a DateTime object. diff --git a/src/Header/Part/HeaderPart.php b/src/Header/Part/HeaderPart.php index 7854acd8..931baffd 100644 --- a/src/Header/Part/HeaderPart.php +++ b/src/Header/Part/HeaderPart.php @@ -7,9 +7,9 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; -use ZBateson\MailMimeParser\Header\IHeaderPart; use ZBateson\MailMimeParser\ErrorBag; +use ZBateson\MailMimeParser\Header\IHeaderPart; +use ZBateson\MbWrapper\MbWrapper; /** * Abstract base class representing a single part of a parsed header. diff --git a/src/IMessage.php b/src/IMessage.php index 8e799bf5..cd546076 100644 --- a/src/IMessage.php +++ b/src/IMessage.php @@ -7,9 +7,9 @@ namespace ZBateson\MailMimeParser; -use ZBateson\MailMimeParser\Message\IMimePart; -use ZBateson\MailMimeParser\Message\IMessagePart; use Psr\Http\Message\StreamInterface; +use ZBateson\MailMimeParser\Message\IMessagePart; +use ZBateson\MailMimeParser\Message\IMimePart; /** * An interface representing an email message. diff --git a/src/MailMimeParser.php b/src/MailMimeParser.php index b3c1846e..c8c578a6 100644 --- a/src/MailMimeParser.php +++ b/src/MailMimeParser.php @@ -7,13 +7,13 @@ namespace ZBateson\MailMimeParser; +use DI\Container; +use DI\ContainerBuilder; +use DI\Definition\Source\DefinitionSource; use GuzzleHttp\Psr7\CachingStream; use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\StreamInterface; use Psr\Log\LoggerInterface; -use DI\Container; -use DI\ContainerBuilder; -use DI\Definition\Source\DefinitionSource; use ZBateson\MailMimeParser\Parser\MessageParserService; /** @@ -62,19 +62,18 @@ class MailMimeParser protected Container $container; /** - * @var Container The static global container + * @var MessageParserService for parsing messages */ - private static ?Container $globalContainer = null; + protected MessageParserService $messageParser; /** - * @var MessageParserService for parsing messages + * @var Container The static global container */ - protected MessageParserService $messageParser; + private static ?Container $globalContainer = null; /** * Returns the global php-di container instance. * - * @return Container */ public static function getGlobalContainer() : Container { @@ -102,8 +101,6 @@ public static function setGlobalPhpDiConfiguration(array|string|DefinitionSource /** * Registers the provided logger globally. * - * @param LoggerInterface $logger - * @return void */ public static function setGlobalLogger(LoggerInterface $logger) : void { @@ -137,7 +134,7 @@ public function __construct(?LoggerInterface $logger = null, array|string|Defini $builder->addDefinitions($phpDiContainerConfig); } if ($logger !== null) { - $builder->addDefinitions([ LoggerInterface::class => $logger ]); + $builder->addDefinitions([LoggerInterface::class => $logger]); } $this->container = $builder->build(); } diff --git a/src/Message.php b/src/Message.php index 0fc3cab0..941fb1e6 100644 --- a/src/Message.php +++ b/src/Message.php @@ -10,9 +10,9 @@ use GuzzleHttp\Psr7; use Psr\Http\Message\StreamInterface; use ZBateson\MailMimeParser\Header\HeaderConsts; -use ZBateson\MailMimeParser\Message\IMessagePart; use ZBateson\MailMimeParser\Message\Helper\MultipartHelper; use ZBateson\MailMimeParser\Message\Helper\PrivacyHelper; +use ZBateson\MailMimeParser\Message\IMessagePart; use ZBateson\MailMimeParser\Message\MimePart; use ZBateson\MailMimeParser\Message\PartChildrenContainer; use ZBateson\MailMimeParser\Message\PartFilter; @@ -319,20 +319,20 @@ public function setSignature(string $body) : static return $this; } - public function getMessageId(): ?string + public function getMessageId() : ?string { return $this->getHeaderValue(HeaderConsts::MESSAGE_ID); } - public function getErrorLoggingContextName(): string + public function getErrorLoggingContextName() : string { $params = ''; if (!empty($this->getMessageId())) { $params .= ', message-id=' . $this->getContentId(); } $params .= ', content-type=' . $this->getContentType(); - $nsClass = get_class($this); - $class = substr($nsClass, (strrpos($nsClass, '\\') ?? -1) + 1); - return $class . '(' . spl_object_id($this) . $params . ')'; + $nsClass = static::class; + $class = \substr($nsClass, (\strrpos($nsClass, '\\') ?? -1) + 1); + return $class . '(' . \spl_object_id($this) . $params . ')'; } } diff --git a/src/Message/Factory/IMessagePartFactory.php b/src/Message/Factory/IMessagePartFactory.php index c8daa3d8..6729da54 100644 --- a/src/Message/Factory/IMessagePartFactory.php +++ b/src/Message/Factory/IMessagePartFactory.php @@ -7,8 +7,8 @@ namespace ZBateson\MailMimeParser\Message\Factory; -use ZBateson\MailMimeParser\Stream\StreamFactory; use ZBateson\MailMimeParser\Message\IMessagePart; +use ZBateson\MailMimeParser\Stream\StreamFactory; /** * Abstract factory for subclasses of IMessagePart. @@ -17,14 +17,8 @@ */ abstract class IMessagePartFactory { - /** - * @var StreamFactory - */ protected StreamFactory $streamFactory; - /** - * @var PartStreamContainerFactory - */ protected PartStreamContainerFactory $partStreamContainerFactory; public function __construct( diff --git a/src/Message/Factory/IMimePartFactory.php b/src/Message/Factory/IMimePartFactory.php index 30178442..40b7edd6 100644 --- a/src/Message/Factory/IMimePartFactory.php +++ b/src/Message/Factory/IMimePartFactory.php @@ -18,14 +18,8 @@ */ class IMimePartFactory extends IMessagePartFactory { - /** - * @var PartHeaderContainerFactory - */ protected PartHeaderContainerFactory $partHeaderContainerFactory; - /** - * @var PartChildrenContainerFactory - */ protected PartChildrenContainerFactory $partChildrenContainerFactory; public function __construct( diff --git a/src/Message/Factory/PartStreamContainerFactory.php b/src/Message/Factory/PartStreamContainerFactory.php index a3e0cdae..4f42c3ae 100644 --- a/src/Message/Factory/PartStreamContainerFactory.php +++ b/src/Message/Factory/PartStreamContainerFactory.php @@ -17,9 +17,6 @@ */ class PartStreamContainerFactory { - /** - * @var StreamFactory - */ protected StreamFactory $streamFactory; public function __construct(StreamFactory $streamFactory) diff --git a/src/Message/Helper/PrivacyHelper.php b/src/Message/Helper/PrivacyHelper.php index 91a759ff..fb17bb84 100644 --- a/src/Message/Helper/PrivacyHelper.php +++ b/src/Message/Helper/PrivacyHelper.php @@ -7,12 +7,12 @@ namespace ZBateson\MailMimeParser\Message\Helper; +use Psr\Http\Message\StreamInterface; use ZBateson\MailMimeParser\Header\HeaderConsts; use ZBateson\MailMimeParser\IMessage; use ZBateson\MailMimeParser\Message\Factory\IMimePartFactory; use ZBateson\MailMimeParser\Message\Factory\IUUEncodedPartFactory; use ZBateson\MailMimeParser\Message\IMessagePart; -use Psr\Http\Message\StreamInterface; /** * Provides routines to set or retrieve the signature part of a signed message. diff --git a/src/Message/IMessagePart.php b/src/Message/IMessagePart.php index fcfc8aca..baef622e 100644 --- a/src/Message/IMessagePart.php +++ b/src/Message/IMessagePart.php @@ -24,7 +24,7 @@ * * @author Zaahid Bateson */ -interface IMessagePart extends SplSubject, IErrorBag +interface IMessagePart extends IErrorBag, SplSubject { /** * Returns this part's parent. diff --git a/src/Message/IMimePart.php b/src/Message/IMimePart.php index 5eccb7ea..c91618f3 100644 --- a/src/Message/IMimePart.php +++ b/src/Message/IMimePart.php @@ -7,8 +7,8 @@ namespace ZBateson\MailMimeParser\Message; -use ZBateson\MailMimeParser\Header\IHeader; use Traversable; +use ZBateson\MailMimeParser\Header\IHeader; /** * An interface representation of any MIME email part. @@ -125,7 +125,6 @@ public function getAllHeaders() : array; * array of raw headers in this part. * @see IMimePart::getRawHeaderIterator() to retrieve an iterator traversing * a two-dimensional string[] array of raw headers. - * @param string $name * @return IHeader[] an array of header objects */ public function getAllHeadersByName(string $name) : array; diff --git a/src/Message/IMultiPart.php b/src/Message/IMultiPart.php index ed5a58c8..0e87fbcf 100644 --- a/src/Message/IMultiPart.php +++ b/src/Message/IMultiPart.php @@ -44,7 +44,7 @@ interface IMultiPart extends IMessagePart * returning true if the part should be included. * @return IMessagePart|null A matching part, or null if not found. */ - public function getPart(int $index, callable $fnFilter = null) : ?IMessagePart; + public function getPart(int $index, ?callable $fnFilter = null) : ?IMessagePart; /** * Returns the current part, all child parts, and child parts of all @@ -70,7 +70,7 @@ public function getPart(int $index, callable $fnFilter = null) : ?IMessagePart; * returning true if the part should be included. * @return IMessagePart[] An array of matching parts. */ - public function getAllParts(callable $fnFilter = null) : array; + public function getAllParts(?callable $fnFilter = null) : array; /** * Returns the total number of parts in this and all children. @@ -93,7 +93,7 @@ public function getAllParts(callable $fnFilter = null) : array; * returning true if the part should be included. * @return int The number of matching parts. */ - public function getPartCount(callable $fnFilter = null) : int; + public function getPartCount(?callable $fnFilter = null) : int; /** * Returns the direct child at the given 0-based index and optional filter, @@ -118,7 +118,7 @@ public function getPartCount(callable $fnFilter = null) : int; * @return IMessagePart|null The matching direct child part or null if not * found. */ - public function getChild(int $index, callable $fnFilter = null) : ?IMessagePart; + public function getChild(int $index, ?callable $fnFilter = null) : ?IMessagePart; /** * Returns an array of all direct child parts, optionally filtering them @@ -140,7 +140,7 @@ public function getChild(int $index, callable $fnFilter = null) : ?IMessagePart; * returning true if the part should be included. * @return IMessagePart[] An array of matching child parts. */ - public function getChildParts(callable $fnFilter = null) : array; + public function getChildParts(?callable $fnFilter = null) : array; /** * Returns the number of direct children under this part (optionally @@ -163,7 +163,7 @@ public function getChildParts(callable $fnFilter = null) : array; * @return int The number of children, or number of children matching the * the passed filtering callable. */ - public function getChildCount(callable $fnFilter = null) : int; + public function getChildCount(?callable $fnFilter = null) : int; /** * Returns a \RecursiveIterator of child parts. @@ -288,5 +288,5 @@ public function removePart(IMessagePart $part) : ?int; * returning true if the part should be included. * @return int The number of removed parts. */ - public function removeAllParts(callable $fnFilter = null) : int; + public function removeAllParts(?callable $fnFilter = null) : int; } diff --git a/src/Message/MessagePart.php b/src/Message/MessagePart.php index ed786bb2..55f811e1 100644 --- a/src/Message/MessagePart.php +++ b/src/Message/MessagePart.php @@ -233,16 +233,16 @@ public function __toString() : string return $this->getStream()->getContents(); } - public function getErrorLoggingContextName(): string + public function getErrorLoggingContextName() : string { $params = ''; if (!empty($this->getContentId())) { $params .= ', content-id=' . $this->getContentId(); } $params .= ', content-type=' . $this->getContentType(); - $nsClass = get_class($this); - $class = substr($nsClass, (strrpos($nsClass, '\\') ?? -1) + 1); - return $class . '(' . spl_object_id($this) . $params . ')'; + $nsClass = static::class; + $class = \substr($nsClass, (\strrpos($nsClass, '\\') ?? -1) + 1); + return $class . '(' . \spl_object_id($this) . $params . ')'; } protected function getErrorBagChildren() : array diff --git a/src/Message/MimePart.php b/src/Message/MimePart.php index c2a9a0e7..030bbbe1 100644 --- a/src/Message/MimePart.php +++ b/src/Message/MimePart.php @@ -7,13 +7,13 @@ namespace ZBateson\MailMimeParser\Message; +use Traversable; use ZBateson\MailMimeParser\Header\HeaderConsts; use ZBateson\MailMimeParser\Header\HeaderFactory; use ZBateson\MailMimeParser\Header\IHeader; use ZBateson\MailMimeParser\Header\ParameterHeader; use ZBateson\MailMimeParser\IMessage; use ZBateson\MailMimeParser\MailMimeParser; -use Traversable; /** * A mime email message part. @@ -293,8 +293,8 @@ public function removeSingleHeader(string $name, int $offset = 0) : static return $this; } - public function getErrorBagChildren(): array + public function getErrorBagChildren() : array { - return \array_merge([ $this->headerContainer ], parent::getErrorBagChildren()); + return \array_merge([$this->headerContainer], parent::getErrorBagChildren()); } } diff --git a/src/Message/MultiPart.php b/src/Message/MultiPart.php index 80056904..defef0c0 100644 --- a/src/Message/MultiPart.php +++ b/src/Message/MultiPart.php @@ -42,12 +42,7 @@ private function getAllPartsIterator() : AppendIterator return $iter; } - /** - * - * @param callable $fnFilter - * @return IMessagePart|null - */ - private function iteratorFindAt(Iterator $iter, int $index, callable $fnFilter = null) : ?IMessagePart + private function iteratorFindAt(Iterator $iter, int $index, ?callable $fnFilter = null) : ?IMessagePart { $pos = 0; foreach ($iter as $part) { @@ -61,7 +56,7 @@ private function iteratorFindAt(Iterator $iter, int $index, callable $fnFilter = return null; } - public function getPart(int $index, callable $fnFilter = null) : ?IMessagePart + public function getPart(int $index, ?callable $fnFilter = null) : ?IMessagePart { return $this->iteratorFindAt( $this->getAllPartsIterator(), @@ -70,7 +65,7 @@ public function getPart(int $index, callable $fnFilter = null) : ?IMessagePart ); } - public function getAllParts(callable $fnFilter = null) : array + public function getAllParts(?callable $fnFilter = null) : array { $array = \iterator_to_array($this->getAllPartsIterator(), false); if ($fnFilter !== null) { @@ -79,12 +74,12 @@ public function getAllParts(callable $fnFilter = null) : array return $array; } - public function getPartCount(callable $fnFilter = null) : int + public function getPartCount(?callable $fnFilter = null) : int { return \count($this->getAllParts($fnFilter)); } - public function getChild(int $index, callable $fnFilter = null) : ?IMessagePart + public function getChild(int $index, ?callable $fnFilter = null) : ?IMessagePart { return $this->iteratorFindAt( $this->partChildrenContainer, @@ -98,7 +93,7 @@ public function getChildIterator() : RecursiveIterator return $this->partChildrenContainer; } - public function getChildParts(callable $fnFilter = null) : array + public function getChildParts(?callable $fnFilter = null) : array { $array = \iterator_to_array($this->partChildrenContainer, false); if ($fnFilter !== null) { @@ -107,7 +102,7 @@ public function getChildParts(callable $fnFilter = null) : array return $array; } - public function getChildCount(callable $fnFilter = null) : int + public function getChildCount(?callable $fnFilter = null) : int { return \count($this->getChildParts($fnFilter)); } @@ -160,7 +155,7 @@ public function removePart(IMessagePart $part) : ?int return $position; } - public function removeAllParts(callable $fnFilter = null) : int + public function removeAllParts(?callable $fnFilter = null) : int { $parts = $this->getAllParts($fnFilter); $count = \count($parts); diff --git a/src/Message/PartFilter.php b/src/Message/PartFilter.php index 63df2852..50b4a9bf 100644 --- a/src/Message/PartFilter.php +++ b/src/Message/PartFilter.php @@ -100,7 +100,6 @@ public static function fromInlineContentType(string $mimeType) : callable * passing true (defaults to false). * @param bool $includeSignedParts Optionally include signed parts (defaults * to false). - * @return callable */ public static function fromDisposition(string $disposition, bool $includeMultipart = false, bool $includeSignedParts = false) : callable { diff --git a/src/Message/PartHeaderContainer.php b/src/Message/PartHeaderContainer.php index 6036d121..e67461d1 100644 --- a/src/Message/PartHeaderContainer.php +++ b/src/Message/PartHeaderContainer.php @@ -7,9 +7,9 @@ namespace ZBateson\MailMimeParser\Message; -use Traversable; use ArrayIterator; use IteratorAggregate; +use Traversable; use ZBateson\MailMimeParser\ErrorBag; use ZBateson\MailMimeParser\Header\HeaderFactory; use ZBateson\MailMimeParser\Header\IHeader; diff --git a/src/Message/UUEncodedPart.php b/src/Message/UUEncodedPart.php index 5965b614..af5d5857 100644 --- a/src/Message/UUEncodedPart.php +++ b/src/Message/UUEncodedPart.php @@ -112,7 +112,7 @@ public function setUnixFileMode(int $mode) : static return $this; } - public function getErrorBagChildren(): array + public function getErrorBagChildren() : array { return \array_merge([]); } diff --git a/src/Parser/MessageParserService.php b/src/Parser/MessageParserService.php index 76cee1f6..6598f9e9 100644 --- a/src/Parser/MessageParserService.php +++ b/src/Parser/MessageParserService.php @@ -8,8 +8,8 @@ namespace ZBateson\MailMimeParser\Parser; use Psr\Http\Message\StreamInterface; -use ZBateson\MailMimeParser\Message\Factory\PartHeaderContainerFactory; use ZBateson\MailMimeParser\IMessage; +use ZBateson\MailMimeParser\Message\Factory\PartHeaderContainerFactory; /** * Parses a mail mime message into its component parts. To invoke, call diff --git a/src/Parser/NonMimeParserService.php b/src/Parser/NonMimeParserService.php index 670f2feb..5bf78781 100644 --- a/src/Parser/NonMimeParserService.php +++ b/src/Parser/NonMimeParserService.php @@ -22,9 +22,6 @@ */ class NonMimeParserService extends AbstractParserService { - /** - * @var UUEncodedPartHeaderContainerFactory - */ protected UUEncodedPartHeaderContainerFactory $partHeaderContainerFactory; public function __construct( diff --git a/src/Parser/Proxy/ParserMessageProxyFactory.php b/src/Parser/Proxy/ParserMessageProxyFactory.php index 0e04ac5f..85a3a1ca 100644 --- a/src/Parser/Proxy/ParserMessageProxyFactory.php +++ b/src/Parser/Proxy/ParserMessageProxyFactory.php @@ -26,14 +26,8 @@ */ class ParserMessageProxyFactory extends ParserMimePartProxyFactory { - /** - * @var MultipartHelper - */ protected MultipartHelper $multipartHelper; - /** - * @var PrivacyHelper - */ protected PrivacyHelper $privacyHelper; public function __construct( diff --git a/src/Parser/Proxy/ParserMimePartProxy.php b/src/Parser/Proxy/ParserMimePartProxy.php index 47b8392b..fdb8e9f3 100644 --- a/src/Parser/Proxy/ParserMimePartProxy.php +++ b/src/Parser/Proxy/ParserMimePartProxy.php @@ -7,10 +7,10 @@ namespace ZBateson\MailMimeParser\Parser\Proxy; -use ZBateson\MailMimeParser\Header\ParameterHeader; +use Psr\Log\LogLevel; use ZBateson\MailMimeParser\Header\HeaderConsts; +use ZBateson\MailMimeParser\Header\ParameterHeader; use ZBateson\MailMimeParser\Message\IMessagePart; -use Psr\Log\LogLevel; /** * A bi-directional parser-to-part proxy for MimeParser and IMimeParts. @@ -31,19 +31,6 @@ class ParserMimePartProxy extends ParserPartProxy */ protected bool $parentBoundaryFound = false; - /** - * @var ?string NULL if the current part does not have a boundary, and - * otherwise contains the value of the boundary parameter of the - * content-type header if the part contains one. - */ - private ?string $mimeBoundary = null; - - /** - * @var bool FALSE if not queried for in the content-type header of this - * part and set in $mimeBoundary. - */ - private bool $mimeBoundaryQueried = false; - /** * @var bool true once all children of this part have been parsed. */ @@ -65,6 +52,19 @@ class ParserMimePartProxy extends ParserPartProxy */ protected ?ParserPartProxy $lastAddedChild = null; + /** + * @var ?string NULL if the current part does not have a boundary, and + * otherwise contains the value of the boundary parameter of the + * content-type header if the part contains one. + */ + private ?string $mimeBoundary = null; + + /** + * @var bool FALSE if not queried for in the content-type header of this + * part and set in $mimeBoundary. + */ + private bool $mimeBoundaryQueried = false; + /** * Ensures that the last child added to this part is fully parsed (content * and children). @@ -140,7 +140,6 @@ public function getContentType() : ?ParameterHeader * Returns the parsed boundary parameter of the Content-Type header if set * for a multipart message part. * - * @return string */ public function getMimeBoundary() : ?string { @@ -203,7 +202,6 @@ public function isEndBoundaryFound() : bool * flag used by isParentBoundaryFound() to true on this part and all parent * parts. * - * @return static */ public function setEof() : static { diff --git a/src/Parser/Proxy/ParserMimePartProxyFactory.php b/src/Parser/Proxy/ParserMimePartProxyFactory.php index cc4cd3fd..71b6c88e 100644 --- a/src/Parser/Proxy/ParserMimePartProxyFactory.php +++ b/src/Parser/Proxy/ParserMimePartProxyFactory.php @@ -28,19 +28,10 @@ class ParserMimePartProxyFactory extends ParserPartProxyFactory */ protected StreamFactory $streamFactory; - /** - * @var ParserPartStreamContainerFactory - */ protected ParserPartStreamContainerFactory $parserPartStreamContainerFactory; - /** - * @var PartHeaderContainerFactory - */ protected PartHeaderContainerFactory $partHeaderContainerFactory; - /** - * @var ParserPartChildrenContainerFactory - */ protected ParserPartChildrenContainerFactory $parserPartChildrenContainerFactory; public function __construct( diff --git a/src/Parser/Proxy/ParserPartProxy.php b/src/Parser/Proxy/ParserPartProxy.php index 5732f26a..dd841bb7 100644 --- a/src/Parser/Proxy/ParserPartProxy.php +++ b/src/Parser/Proxy/ParserPartProxy.php @@ -7,11 +7,11 @@ namespace ZBateson\MailMimeParser\Parser\Proxy; +use Psr\Http\Message\StreamInterface; use ZBateson\MailMimeParser\Message\IMessagePart; +use ZBateson\MailMimeParser\Message\PartHeaderContainer; use ZBateson\MailMimeParser\Parser\IParserService; use ZBateson\MailMimeParser\Parser\PartBuilder; -use ZBateson\MailMimeParser\Message\PartHeaderContainer; -use Psr\Http\Message\StreamInterface; /** * Proxy between a MessagePart and a Parser. diff --git a/src/Parser/Proxy/ParserPartProxyFactory.php b/src/Parser/Proxy/ParserPartProxyFactory.php index 4ccbc628..96857e44 100644 --- a/src/Parser/Proxy/ParserPartProxyFactory.php +++ b/src/Parser/Proxy/ParserPartProxyFactory.php @@ -20,7 +20,6 @@ abstract class ParserPartProxyFactory /** * Constructs a new ParserPartProxy wrapping an IMessagePart object. * - * @return ParserPartProxy */ abstract public function newInstance(PartBuilder $partBuilder, IParserService $parser) : ParserPartProxy; } diff --git a/src/Parser/Proxy/ParserUUEncodedPartProxyFactory.php b/src/Parser/Proxy/ParserUUEncodedPartProxyFactory.php index ed0df3e4..9d9c33da 100644 --- a/src/Parser/Proxy/ParserUUEncodedPartProxyFactory.php +++ b/src/Parser/Proxy/ParserUUEncodedPartProxyFactory.php @@ -26,9 +26,6 @@ class ParserUUEncodedPartProxyFactory extends ParserPartProxyFactory */ protected StreamFactory $streamFactory; - /** - * @var ParserPartStreamContainerFactory - */ protected ParserPartStreamContainerFactory $parserPartStreamContainerFactory; public function __construct(StreamFactory $sdf, ParserPartStreamContainerFactory $parserPartStreamContainerFactory) diff --git a/src/Stream/HeaderStream.php b/src/Stream/HeaderStream.php index e9cd385f..18b930f6 100644 --- a/src/Stream/HeaderStream.php +++ b/src/Stream/HeaderStream.php @@ -8,12 +8,12 @@ namespace ZBateson\MailMimeParser\Stream; use ArrayIterator; -use Traversable; use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\StreamDecoratorTrait; use Psr\Http\Message\StreamInterface; use SplObserver; use SplSubject; +use Traversable; use ZBateson\MailMimeParser\Header\HeaderConsts; use ZBateson\MailMimeParser\Message\IMessagePart; use ZBateson\MailMimeParser\Message\IMimePart; @@ -32,13 +32,13 @@ class HeaderStream implements SplObserver, StreamInterface { use StreamDecoratorTrait; - private ?StreamInterface $stream; - /** * @var IMessagePart the part to read from. */ protected IMessagePart $part; + private ?StreamInterface $stream; + public function __construct(IMessagePart $part) { $this->part = $part; diff --git a/src/Stream/MessagePartStream.php b/src/Stream/MessagePartStream.php index bf253a56..eed17edd 100644 --- a/src/Stream/MessagePartStream.php +++ b/src/Stream/MessagePartStream.php @@ -27,8 +27,6 @@ class MessagePartStream implements SplObserver, StreamInterface { use StreamDecoratorTrait; - private ?StreamInterface $stream; - /** * @var StreamFactory For creating needed stream decorators. */ @@ -44,6 +42,8 @@ class MessagePartStream implements SplObserver, StreamInterface */ protected ?AppendStream $appendStream = null; + private ?StreamInterface $stream; + /** * Constructor * diff --git a/src/di_config.php b/src/di_config.php index b24201e5..0d5a0d95 100644 --- a/src/di_config.php +++ b/src/di_config.php @@ -2,16 +2,9 @@ use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; -use ZBateson\MailMimeParser\Header\HeaderFactory; -use ZBateson\MailMimeParser\Header\Consumer\AddressBaseConsumerService; -use ZBateson\MailMimeParser\Header\Consumer\DateConsumerService; -use ZBateson\MailMimeParser\Header\Consumer\GenericConsumerMimeLiteralPartService; -use ZBateson\MailMimeParser\Header\Consumer\IdBaseConsumerService; -use ZBateson\MailMimeParser\Header\Consumer\ParameterConsumerService; -use ZBateson\MailMimeParser\Header\Consumer\ReceivedConsumerService; -use ZBateson\MailMimeParser\Header\Consumer\SubjectConsumerService; use ZBateson\MailMimeParser\Header\Consumer\Received\DomainConsumerService; use ZBateson\MailMimeParser\Header\Consumer\Received\GenericReceivedConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\ReceivedConsumerService; return [ LoggerInterface::class => DI\autowire(NullLogger::class), diff --git a/tests/MailMimeParser/ErrorBagTest.php b/tests/MailMimeParser/ErrorBagTest.php index 104fea36..0a4098fe 100644 --- a/tests/MailMimeParser/ErrorBagTest.php +++ b/tests/MailMimeParser/ErrorBagTest.php @@ -34,7 +34,7 @@ public function testInstance() : void public function testGetErrorLoggingContextName() : void { $ob = $this->newErrorBagStub(); - $this->assertEquals(get_class($ob), $ob->getErrorLoggingContextName()); + $this->assertEquals(\get_class($ob), $ob->getErrorLoggingContextName()); } public function testAddHasAndGetErrors() : void @@ -65,7 +65,7 @@ public function testGetHasFilteredErrors() : void $ob = $this->newErrorBagStub(); $mb = $this->getMockBuilder('\\' . Error::class) ->disableOriginalConstructor(); - + $this->assertSame($ob, $ob->addError('test1', LogLevel::ERROR)); $this->assertSame($ob, $ob->addError('test2', LogLevel::NOTICE)); diff --git a/tests/MailMimeParser/ErrorTest.php b/tests/MailMimeParser/ErrorTest.php index 2e6fb9ab..f6bbe9d7 100644 --- a/tests/MailMimeParser/ErrorTest.php +++ b/tests/MailMimeParser/ErrorTest.php @@ -2,9 +2,9 @@ namespace ZBateson\MailMimeParser; +use InvalidArgumentException; use PHPUnit\Framework\TestCase; use Psr\Log\LogLevel; -use InvalidArgumentException; /** * Description of ErrorTest @@ -47,7 +47,7 @@ public function testConstructorInvalidArgumentExceptionForBadPsrLevel() : void public function testGetObjectAndClass() : void { $ob = new Error('', LogLevel::DEBUG, $this->errorBagMock); - $this->assertSame(get_class($this->errorBagMock), $ob->getClass()); + $this->assertSame(\get_class($this->errorBagMock), $ob->getClass()); $this->assertSame($this->errorBagMock, $ob->getObject()); } diff --git a/tests/MailMimeParser/Header/AddressHeaderTest.php b/tests/MailMimeParser/Header/AddressHeaderTest.php index ac762cbb..a8477486 100644 --- a/tests/MailMimeParser/Header/AddressHeaderTest.php +++ b/tests/MailMimeParser/Header/AddressHeaderTest.php @@ -3,11 +3,11 @@ namespace ZBateson\MailMimeParser\Header; use PHPUnit\Framework\TestCase; -use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; -use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; -use ZBateson\MailMimeParser\Header\Consumer\AddressGroupConsumerService; -use ZBateson\MailMimeParser\Header\Consumer\AddressEmailConsumerService; use ZBateson\MailMimeParser\Header\Consumer\AddressConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\AddressEmailConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\AddressGroupConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; /** * Description of AddressHeaderTest diff --git a/tests/MailMimeParser/Header/Consumer/AbstractConsumerServiceTest.php b/tests/MailMimeParser/Header/Consumer/AbstractConsumerServiceTest.php index 00eb38be..f44fc964 100644 --- a/tests/MailMimeParser/Header/Consumer/AbstractConsumerServiceTest.php +++ b/tests/MailMimeParser/Header/Consumer/AbstractConsumerServiceTest.php @@ -3,8 +3,8 @@ namespace ZBateson\MailMimeParser\Header\Consumer; use PHPUnit\Framework\TestCase; -use ZBateson\MailMimeParser\Header\Part\Token; use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; +use ZBateson\MailMimeParser\Header\Part\Token; /** * Description of AbstractConsumerServiceTest diff --git a/tests/MailMimeParser/Header/Consumer/Received/DomainConsumerServiceTest.php b/tests/MailMimeParser/Header/Consumer/Received/DomainConsumerServiceTest.php index b0788f16..a451627a 100644 --- a/tests/MailMimeParser/Header/Consumer/Received/DomainConsumerServiceTest.php +++ b/tests/MailMimeParser/Header/Consumer/Received/DomainConsumerServiceTest.php @@ -3,9 +3,8 @@ namespace ZBateson\MailMimeParser\Header\Consumer\Received; use PHPUnit\Framework\TestCase; -use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; - +use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; /** * Description of DomainConsumerServiceTest diff --git a/tests/MailMimeParser/Header/Consumer/Received/GenericReceivedConsumerServiceTest.php b/tests/MailMimeParser/Header/Consumer/Received/GenericReceivedConsumerServiceTest.php index ce8ef778..2c2ea7a2 100644 --- a/tests/MailMimeParser/Header/Consumer/Received/GenericReceivedConsumerServiceTest.php +++ b/tests/MailMimeParser/Header/Consumer/Received/GenericReceivedConsumerServiceTest.php @@ -3,8 +3,8 @@ namespace ZBateson\MailMimeParser\Header\Consumer\Received; use PHPUnit\Framework\TestCase; -use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; /** * Description of GenericReceivedConsumerServiceTest diff --git a/tests/MailMimeParser/Header/Consumer/Received/ReceivedDateConsumerServiceTest.php b/tests/MailMimeParser/Header/Consumer/Received/ReceivedDateConsumerServiceTest.php index 4ed2e65a..27823243 100644 --- a/tests/MailMimeParser/Header/Consumer/Received/ReceivedDateConsumerServiceTest.php +++ b/tests/MailMimeParser/Header/Consumer/Received/ReceivedDateConsumerServiceTest.php @@ -4,8 +4,8 @@ use DateTime; use PHPUnit\Framework\TestCase; -use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; /** * Description of ReceivedDateConsumerServiceTest diff --git a/tests/MailMimeParser/Header/DateHeaderTest.php b/tests/MailMimeParser/Header/DateHeaderTest.php index 668a39a0..e4f2eb7e 100644 --- a/tests/MailMimeParser/Header/DateHeaderTest.php +++ b/tests/MailMimeParser/Header/DateHeaderTest.php @@ -3,8 +3,8 @@ namespace ZBateson\MailMimeParser\Header; use PHPUnit\Framework\TestCase; -use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; /** * Description of DateHeaderTest diff --git a/tests/MailMimeParser/Header/GenericHeaderTest.php b/tests/MailMimeParser/Header/GenericHeaderTest.php index 17b58f87..f2b23bb1 100644 --- a/tests/MailMimeParser/Header/GenericHeaderTest.php +++ b/tests/MailMimeParser/Header/GenericHeaderTest.php @@ -4,8 +4,8 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LogLevel; -use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; /** * Description of GenericHeaderTest diff --git a/tests/MailMimeParser/Header/HeaderFactoryTest.php b/tests/MailMimeParser/Header/HeaderFactoryTest.php index da2e47fe..649fd241 100644 --- a/tests/MailMimeParser/Header/HeaderFactoryTest.php +++ b/tests/MailMimeParser/Header/HeaderFactoryTest.php @@ -38,7 +38,7 @@ protected function setUp() : void ->setConstructorArgs([$charsetConverter]) ->setMethods(['__toString']) ->getMock(); - + $abcs = $this->getMockBuilder(AddressBaseConsumerService::class) ->disableOriginalConstructor() ->setMethods(['__invoke']) diff --git a/tests/MailMimeParser/Header/IdHeaderTest.php b/tests/MailMimeParser/Header/IdHeaderTest.php index adc16999..3b3c5af6 100644 --- a/tests/MailMimeParser/Header/IdHeaderTest.php +++ b/tests/MailMimeParser/Header/IdHeaderTest.php @@ -3,9 +3,9 @@ namespace ZBateson\MailMimeParser\Header; use PHPUnit\Framework\TestCase; -use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; use ZBateson\MailMimeParser\Header\Consumer\IdConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; /** * Description of IdHeaderTest diff --git a/tests/MailMimeParser/Header/ParameterHeaderTest.php b/tests/MailMimeParser/Header/ParameterHeaderTest.php index 3e22f426..e04325df 100644 --- a/tests/MailMimeParser/Header/ParameterHeaderTest.php +++ b/tests/MailMimeParser/Header/ParameterHeaderTest.php @@ -3,8 +3,8 @@ namespace ZBateson\MailMimeParser\Header; use PHPUnit\Framework\TestCase; -use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; /** * Description of ParametersHeaderTest diff --git a/tests/MailMimeParser/Header/Part/AddressGroupPartTest.php b/tests/MailMimeParser/Header/Part/AddressGroupPartTest.php index dba8f540..ab6b195c 100644 --- a/tests/MailMimeParser/Header/Part/AddressGroupPartTest.php +++ b/tests/MailMimeParser/Header/Part/AddressGroupPartTest.php @@ -4,9 +4,8 @@ use PHPUnit\Framework\TestCase; -use ZBateson\MbWrapper\MbWrapper; -use ZBateson\MailMimeParser\Header\Part\AddressPart; use Psr\Log\LogLevel; +use ZBateson\MbWrapper\MbWrapper; /** * Description of AddressGroupTest @@ -29,7 +28,7 @@ public function testNameGroup() : void $this->getMockBuilder(AddressPart::class)->disableOriginalConstructor()->getMock(), $this->getMockBuilder(AddressPart::class)->disableOriginalConstructor()->getMock() ]; - + $part = new AddressGroupPart($csConverter, $members, $name); $this->assertEquals($name, $part->getName()); $this->assertEquals($members, $part->getAddresses()); diff --git a/tests/MailMimeParser/Header/Part/AddressPartTest.php b/tests/MailMimeParser/Header/Part/AddressPartTest.php index 9bb06563..83ffe705 100644 --- a/tests/MailMimeParser/Header/Part/AddressPartTest.php +++ b/tests/MailMimeParser/Header/Part/AddressPartTest.php @@ -2,9 +2,9 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; use Psr\Log\LogLevel; +use ZBateson\MbWrapper\MbWrapper; /** * Description of AddressPartTest diff --git a/tests/MailMimeParser/Header/Part/CommentPartTest.php b/tests/MailMimeParser/Header/Part/CommentPartTest.php index f5dfbccb..b4ab4e48 100644 --- a/tests/MailMimeParser/Header/Part/CommentPartTest.php +++ b/tests/MailMimeParser/Header/Part/CommentPartTest.php @@ -2,8 +2,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; +use ZBateson\MbWrapper\MbWrapper; /** * Description of CommentTest diff --git a/tests/MailMimeParser/Header/Part/DatePartTest.php b/tests/MailMimeParser/Header/Part/DatePartTest.php index 719751b2..3aa8c9c1 100644 --- a/tests/MailMimeParser/Header/Part/DatePartTest.php +++ b/tests/MailMimeParser/Header/Part/DatePartTest.php @@ -2,9 +2,9 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; use Psr\Log\LogLevel; +use ZBateson\MbWrapper\MbWrapper; /** * Description of DateTest diff --git a/tests/MailMimeParser/Header/Part/HeaderPartFactoryTest.php b/tests/MailMimeParser/Header/Part/HeaderPartFactoryTest.php index dd08978b..6d17ceff 100644 --- a/tests/MailMimeParser/Header/Part/HeaderPartFactoryTest.php +++ b/tests/MailMimeParser/Header/Part/HeaderPartFactoryTest.php @@ -2,8 +2,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; +use ZBateson\MbWrapper\MbWrapper; /** * Description of HeaderPartFactoryTest diff --git a/tests/MailMimeParser/Header/Part/HeaderPartTest.php b/tests/MailMimeParser/Header/Part/HeaderPartTest.php index 61d76463..2f1be57c 100644 --- a/tests/MailMimeParser/Header/Part/HeaderPartTest.php +++ b/tests/MailMimeParser/Header/Part/HeaderPartTest.php @@ -2,9 +2,9 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; use ZBateson\MailMimeParser\ErrorBag; +use ZBateson\MbWrapper\MbWrapper; /** * Description of HeaderPartTest diff --git a/tests/MailMimeParser/Header/Part/LiteralPartTest.php b/tests/MailMimeParser/Header/Part/LiteralPartTest.php index 160ea323..761b35dc 100644 --- a/tests/MailMimeParser/Header/Part/LiteralPartTest.php +++ b/tests/MailMimeParser/Header/Part/LiteralPartTest.php @@ -2,8 +2,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; +use ZBateson\MbWrapper\MbWrapper; /** * Description of LiteralTest diff --git a/tests/MailMimeParser/Header/Part/MimeLiteralPartFactoryTest.php b/tests/MailMimeParser/Header/Part/MimeLiteralPartFactoryTest.php index 14fdae69..af7e46b3 100644 --- a/tests/MailMimeParser/Header/Part/MimeLiteralPartFactoryTest.php +++ b/tests/MailMimeParser/Header/Part/MimeLiteralPartFactoryTest.php @@ -2,8 +2,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; +use ZBateson\MbWrapper\MbWrapper; /** * Description of MimeLiteralPartFactoryTest diff --git a/tests/MailMimeParser/Header/Part/MimeLiteralPartTest.php b/tests/MailMimeParser/Header/Part/MimeLiteralPartTest.php index eeed5764..18588db4 100644 --- a/tests/MailMimeParser/Header/Part/MimeLiteralPartTest.php +++ b/tests/MailMimeParser/Header/Part/MimeLiteralPartTest.php @@ -2,8 +2,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; +use ZBateson\MbWrapper\MbWrapper; /** * Description of MimeLiteralTest diff --git a/tests/MailMimeParser/Header/Part/ParameterPartTest.php b/tests/MailMimeParser/Header/Part/ParameterPartTest.php index 92a0f1ed..454af35b 100644 --- a/tests/MailMimeParser/Header/Part/ParameterPartTest.php +++ b/tests/MailMimeParser/Header/Part/ParameterPartTest.php @@ -2,9 +2,9 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; use Psr\Log\LogLevel; +use ZBateson\MbWrapper\MbWrapper; /** * Description of ParameterTest diff --git a/tests/MailMimeParser/Header/Part/ReceivedDomainPartTest.php b/tests/MailMimeParser/Header/Part/ReceivedDomainPartTest.php index f79a2d85..e3c4d594 100644 --- a/tests/MailMimeParser/Header/Part/ReceivedDomainPartTest.php +++ b/tests/MailMimeParser/Header/Part/ReceivedDomainPartTest.php @@ -2,8 +2,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; +use ZBateson\MbWrapper\MbWrapper; /** * Description of ReceivedDomainTest diff --git a/tests/MailMimeParser/Header/Part/ReceivedPartTest.php b/tests/MailMimeParser/Header/Part/ReceivedPartTest.php index 3bff354d..3446d9dc 100644 --- a/tests/MailMimeParser/Header/Part/ReceivedPartTest.php +++ b/tests/MailMimeParser/Header/Part/ReceivedPartTest.php @@ -2,8 +2,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; +use ZBateson\MbWrapper\MbWrapper; /** * Description of ReceivedTest diff --git a/tests/MailMimeParser/Header/Part/SplitParameterTokenTest.php b/tests/MailMimeParser/Header/Part/SplitParameterTokenTest.php index 9541c0c1..e66ed4f0 100644 --- a/tests/MailMimeParser/Header/Part/SplitParameterTokenTest.php +++ b/tests/MailMimeParser/Header/Part/SplitParameterTokenTest.php @@ -2,8 +2,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; +use ZBateson\MbWrapper\MbWrapper; /** * Description of ParameterTest diff --git a/tests/MailMimeParser/Header/Part/TokenTest.php b/tests/MailMimeParser/Header/Part/TokenTest.php index ef4cc447..30d732e8 100644 --- a/tests/MailMimeParser/Header/Part/TokenTest.php +++ b/tests/MailMimeParser/Header/Part/TokenTest.php @@ -2,8 +2,8 @@ namespace ZBateson\MailMimeParser\Header\Part; -use ZBateson\MbWrapper\MbWrapper; use PHPUnit\Framework\TestCase; +use ZBateson\MbWrapper\MbWrapper; /** * Description of TokenTest diff --git a/tests/MailMimeParser/Header/ReceivedHeaderTest.php b/tests/MailMimeParser/Header/ReceivedHeaderTest.php index 3ad2adfc..25f10f85 100644 --- a/tests/MailMimeParser/Header/ReceivedHeaderTest.php +++ b/tests/MailMimeParser/Header/ReceivedHeaderTest.php @@ -4,8 +4,8 @@ use DateTime; use PHPUnit\Framework\TestCase; -use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; use ZBateson\MailMimeParser\Header\Consumer\CommentConsumerService; +use ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumerService; use ZBateson\MailMimeParser\Header\Consumer\Received\DomainConsumerService; use ZBateson\MailMimeParser\Header\Consumer\Received\GenericReceivedConsumerService; use ZBateson\MailMimeParser\Header\Consumer\Received\ReceivedDateConsumerService; diff --git a/tests/MailMimeParser/IntegrationTests/EmailFunctionalTest.php b/tests/MailMimeParser/IntegrationTests/EmailFunctionalTest.php index cd301430..c1a66a76 100644 --- a/tests/MailMimeParser/IntegrationTests/EmailFunctionalTest.php +++ b/tests/MailMimeParser/IntegrationTests/EmailFunctionalTest.php @@ -8,9 +8,6 @@ use ZBateson\MailMimeParser\MailMimeParser; use ZBateson\MailMimeParser\Message; use ZBateson\MailMimeParser\Message\IMimePart; -use Monolog\Logger; -use Monolog\Handler\StreamHandler; -use Monolog\Processor\IntrospectionProcessor; /** * Description of EmailFunctionalTest diff --git a/tests/MailMimeParser/MailMimeParserTest.php b/tests/MailMimeParser/MailMimeParserTest.php index a281a188..875205cf 100644 --- a/tests/MailMimeParser/MailMimeParserTest.php +++ b/tests/MailMimeParser/MailMimeParserTest.php @@ -31,7 +31,7 @@ public function testParseFromHandle() : void ->method('parse') ->willReturn($exp); - $mmp = new MailMimeParser(phpDiContainerConfig: [ MessageParserService::class => $mockParser ]); + $mmp = new MailMimeParser(phpDiContainerConfig: [MessageParserService::class => $mockParser]); $ret = $mmp->parse($handle, true); $this->assertEquals($exp, $ret); @@ -52,7 +52,7 @@ public function testParseFromStream() : void ->method('parse') ->willReturn($exp); - $mmp = new MailMimeParser(phpDiContainerConfig: [ MessageParserService::class => $mockParser ]); + $mmp = new MailMimeParser(phpDiContainerConfig: [MessageParserService::class => $mockParser]); $ret = $mmp->parse(Psr7\Utils::streamFor($handle), true); $this->assertEquals($exp, $ret); @@ -69,7 +69,7 @@ public function testParseFromString() : void ->method('parse') ->willReturn($exp); - $mmp = new MailMimeParser(phpDiContainerConfig: [ MessageParserService::class => $mockParser ]); + $mmp = new MailMimeParser(phpDiContainerConfig: [MessageParserService::class => $mockParser]); $ret = $mmp->parse('This is a test', false); $this->assertEquals($exp, $ret); diff --git a/tests/MailMimeParser/MessageTest.php b/tests/MailMimeParser/MessageTest.php index 39bb561a..f733ce69 100644 --- a/tests/MailMimeParser/MessageTest.php +++ b/tests/MailMimeParser/MessageTest.php @@ -2,9 +2,9 @@ namespace ZBateson\MailMimeParser; +use GuzzleHttp\Psr7\Utils; use PHPUnit\Framework\TestCase; use ZBateson\MailMimeParser\Message\PartChildrenContainer; -use GuzzleHttp\Psr7\Utils; /** * Description of MessageTest diff --git a/tests/MailMimeParser/Parser/ParserManagerServiceTest.php b/tests/MailMimeParser/Parser/ParserManagerServiceTest.php index af9e106d..47182b05 100644 --- a/tests/MailMimeParser/Parser/ParserManagerServiceTest.php +++ b/tests/MailMimeParser/Parser/ParserManagerServiceTest.php @@ -131,7 +131,7 @@ public function testCreateParserProxyForPart() : void $this->nonMimeParser->expects($this->never()) ->method('getParserPartProxyFactory'); - + $proxyFactory->expects($this->once()) ->method('newInstance') ->with($partBuilder, $this->mimeParser) diff --git a/tests/generate-encoded.php b/tests/generate-encoded.php index 7d3d9698..bab235d2 100755 --- a/tests/generate-encoded.php +++ b/tests/generate-encoded.php @@ -1,5 +1,6 @@ #!/usr/bin/env php