From c824518716e1dfeb680bc8e8a7945d219287666e Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Fri, 23 Aug 2024 20:00:17 -0300 Subject: [PATCH] Upgrade coding standard --- composer.json | 2 +- src/Mailer.php | 6 +++--- src/Message.php | 18 +++++++++--------- tests/MessageMock.php | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index fb5f204..71f3cab 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ }, "require-dev": { "ext-xdebug": "*", - "aplus/coding-standard": "^2.0", + "aplus/coding-standard": "^2.8", "ergebnis/composer-normalize": "^2.23", "jetbrains/phpstorm-attributes": "^1.0", "phpmd/phpmd": "^2.13", diff --git a/src/Mailer.php b/src/Mailer.php index 5f95926..0c5754b 100644 --- a/src/Mailer.php +++ b/src/Mailer.php @@ -48,10 +48,10 @@ public function __construct( #[SensitiveParameter] array | string $username, #[SensitiveParameter] - string $password = null, + ?string $password = null, string $host = 'localhost', int $port = 587, - string $hostname = null + ?string $hostname = null ) { $this->config = \is_array($username) ? $this->makeConfig($username) @@ -280,7 +280,7 @@ public function send(Message $message) : bool return $this->sendMessage($message) === 250; } - protected function sendMessage(Message $message) : int | false + protected function sendMessage(Message $message) : false | int { if (!$this->connect()) { return false; diff --git a/src/Message.php b/src/Message.php index 7719e2c..448cd01 100644 --- a/src/Message.php +++ b/src/Message.php @@ -153,7 +153,7 @@ protected function getCharset() : string * * @return static */ - public function setBoundary(string $boundary = null) : static + public function setBoundary(?string $boundary = null) : static { $this->boundary = $boundary ?? \bin2hex(\random_bytes(16)); return $this; @@ -470,7 +470,7 @@ public function getSubject() : ?string * * @return static */ - public function addTo(string $address, string $name = null) : static + public function addTo(string $address, ?string $name = null) : static { $this->to[$address] = $name; $this->setHeader(Header::TO, static::formatAddressList($this->to)); @@ -506,7 +506,7 @@ public function removeTo() : static * * @return static */ - public function addCc(string $address, string $name = null) : static + public function addCc(string $address, ?string $name = null) : static { $this->cc[$address] = $name; $this->setHeader(Header::CC, static::formatAddressList($this->cc)); @@ -551,7 +551,7 @@ public function getRecipients() : array * * @return static */ - public function addBcc(string $address, string $name = null) : static + public function addBcc(string $address, ?string $name = null) : static { $this->bcc[$address] = $name; $this->setHeader(Header::BCC, static::formatAddressList($this->bcc)); @@ -587,7 +587,7 @@ public function removeBcc() : static * * @return static */ - public function addReplyTo(string $address, string $name = null) : static + public function addReplyTo(string $address, ?string $name = null) : static { $this->replyTo[$address] = $name; $this->setHeader(Header::REPLY_TO, static::formatAddressList($this->replyTo)); @@ -623,7 +623,7 @@ public function removeReplyTo() : static * * @return static */ - public function setFrom(string $address, string $name = null) : static + public function setFrom(string $address, ?string $name = null) : static { $this->from = [$address, $name]; $this->setHeader(Header::FROM, static::formatAddress($address, $name)); @@ -679,7 +679,7 @@ public function removeFrom() : static * * @return static */ - public function setDate(DateTime $datetime = null) : static + public function setDate(?DateTime $datetime = null) : static { $date = $datetime ? $datetime->format('r') : \date('r'); $this->setHeader(Header::DATE, $date); @@ -730,7 +730,7 @@ public function getXPriority() : ?XPriority * * @return static */ - public function setXMailer(string $xMailer = null) : static + public function setXMailer(?string $xMailer = null) : static { $xMailer ??= 'Aplus Mailer'; $this->setHeader(Header::X_MAILER, $xMailer); @@ -747,7 +747,7 @@ public function getXMailer() : ?string return $this->getHeader(Header::X_MAILER); } - protected static function formatAddress(string $address, string $name = null) : string + protected static function formatAddress(string $address, ?string $name = null) : string { return $name !== null ? '"' . $name . '" <' . $address . '>' : $address; } diff --git a/tests/MessageMock.php b/tests/MessageMock.php index 5991859..446d478 100644 --- a/tests/MessageMock.php +++ b/tests/MessageMock.php @@ -48,7 +48,7 @@ public function renderData() : string return parent::renderData(); } - public static function formatAddress(string $address, string $name = null) : string + public static function formatAddress(string $address, ?string $name = null) : string { return parent::formatAddress($address, $name); }