From 157ccd50c0593f796d24a2f63d51e7d195fe059a Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Mon, 17 Jul 2023 08:44:38 +0200 Subject: [PATCH] Add native types and PHPStan --- composer.json | 4 +- phpstan-baseline.neon | 51 +++++++++++++++++ phpstan.neon | 8 +++ src/MailHog.php | 115 ++++++++++++++------------------------- src/TestsEmails.php | 124 +++++++++++++++++++++--------------------- 5 files changed, 164 insertions(+), 138 deletions(-) create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon diff --git a/composer.json b/composer.json index 74ff3fa..afcba2c 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ ], "require": { "php": "~8.1.0", - "ericmartel/codeception-email": "^1.0", - "guzzlehttp/guzzle": "^6.1 || ^7.0" + "guzzlehttp/guzzle": "^6.1 || ^7.0", + "codeception/codeception": "^5.0" }, "autoload": { "psr-4": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..4b23813 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,51 @@ +parameters: + ignoreErrors: + - + message: "#^Access to an undefined property object\\:\\:\\$Body\\.$#" + count: 1 + path: src/MailHog.php + + - + message: "#^Access to an undefined property object\\:\\:\\$Content\\.$#" + count: 11 + path: src/MailHog.php + + - + message: "#^Access to an undefined property object\\:\\:\\$MIME\\.$#" + count: 1 + path: src/MailHog.php + + - + message: "#^Cannot access property \\$ID on object\\|null\\.$#" + count: 1 + path: src/MailHog.php + + - + message: "#^Method Codeception\\\\Module\\\\MailHog\\:\\:getFullEmail\\(\\) should return object but returns mixed\\.$#" + count: 1 + path: src/MailHog.php + + - + message: "#^Parameter \\#1 \\$inbox of method Codeception\\\\Module\\\\MailHog\\:\\:sortEmails\\(\\) expects array\\, mixed given\\.$#" + count: 1 + path: src/MailHog.php + + - + message: "#^Parameter \\#1 \\$string of function mb_decode_mimeheader expects string, string\\|null given\\.$#" + count: 1 + path: src/MailHog.php + + - + message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, array\\|string given\\.$#" + count: 1 + path: src/MailHog.php + + - + message: "#^Property Codeception\\\\Module\\\\MailHog\\:\\:\\$fetchedEmails \\(array\\\\) does not accept mixed\\.$#" + count: 1 + path: src/MailHog.php + + - + message: "#^Variable \\$response might not be defined\\.$#" + count: 1 + path: src/MailHog.php diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..ec413c4 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,8 @@ +includes: + - phpstan-baseline.neon +parameters: + level: max + phpVersion: 80100 + reportUnmatchedIgnoredErrors: true + paths: + - src diff --git a/src/MailHog.php b/src/MailHog.php index 0d6f28b..5e18b62 100644 --- a/src/MailHog.php +++ b/src/MailHog.php @@ -12,6 +12,7 @@ use Codeception\Module; use Codeception\TestInterface; +use Exception; class MailHog extends Module { @@ -27,46 +28,46 @@ class MailHog extends Module /** * Raw email header data converted to JSON * - * @var array + * @var array */ protected $fetchedEmails; /** * Currently selected set of email headers to work with * - * @var array + * @var array */ protected $currentInbox; /** * Starts as the same data as the current inbox, but items are removed as they're used * - * @var array + * @var array */ protected $unreadInbox; /** * Contains the currently open email on which test operations are conducted * - * @var mixed + * @var object */ protected $openedEmail; /** * Codeception exposed variables * - * @var array + * @var array */ protected array $config = ['url', 'port', 'guzzleRequestOptions', 'deleteEmailsAfterScenario', 'timeout']; /** * Codeception required variables * - * @var array + * @var array */ protected array $requiredFields = ['url', 'port']; - public function _initialize() + public function _initialize(): void { $url = trim($this->config['url'], '/') . ':' . $this->config['port']; @@ -83,7 +84,7 @@ public function _initialize() /** * Method executed after each scenario */ - public function _after(TestInterface $test) + public function _after(TestInterface $test): void { if (isset($this->config['deleteEmailsAfterScenario']) && $this->config['deleteEmailsAfterScenario']) { $this->deleteAllEmails(); @@ -95,7 +96,7 @@ public function _after(TestInterface $test) * * Accessible from tests, deletes all emails */ - public function deleteAllEmails() + public function deleteAllEmails(): void { try { $this->mailhog->request('DELETE', '/api/v1/messages'); @@ -109,7 +110,7 @@ public function deleteAllEmails() * * Accessible from tests, fetches all emails */ - public function fetchEmails() + public function fetchEmails(): void { $this->fetchedEmails = []; @@ -133,7 +134,7 @@ public function fetchEmails() * * @param string $address Recipient address' inbox */ - public function accessInboxFor($address) + public function accessInboxFor(string $address): void { $inbox = []; @@ -160,7 +161,7 @@ public function accessInboxFor($address) * * @param string $address Recipient address' inbox */ - public function accessInboxForTo($address) + public function accessInboxForTo(string $address): void { $inbox = []; @@ -179,7 +180,7 @@ public function accessInboxForTo($address) * * @param string $address Recipient address' inbox */ - public function accessInboxForCc($address) + public function accessInboxForCc(string $address): void { $inbox = []; @@ -198,7 +199,7 @@ public function accessInboxForCc($address) * * @param string $address Recipient address' inbox */ - public function accessInboxForBcc($address) + public function accessInboxForBcc(string $address): void { $inbox = []; @@ -215,7 +216,7 @@ public function accessInboxForBcc($address) * * Pops the most recent unread email and assigns it as the email to conduct tests on */ - public function openNextUnreadEmail() + public function openNextUnreadEmail(): void { $this->openedEmail = $this->getMostRecentUnreadEmail(); } @@ -226,9 +227,9 @@ public function openNextUnreadEmail() * Main method called by the tests, providing either the currently open email or the next unread one * * @param bool $fetchNextUnread Goes to the next Unread Email - * @return mixed Returns a JSON encoded Email + * @return object Returns a JSON encoded Email */ - protected function getOpenedEmail($fetchNextUnread = false) + protected function getOpenedEmail(bool $fetchNextUnread = false): object { if ($fetchNextUnread || $this->openedEmail == null) { $this->openNextUnreadEmail(); @@ -242,9 +243,9 @@ protected function getOpenedEmail($fetchNextUnread = false) * * Pops the most recent unread email, fails if the inbox is empty * - * @return mixed Returns a JSON encoded Email + * @return object Returns a JSON encoded Email */ - protected function getMostRecentUnreadEmail() + protected function getMostRecentUnreadEmail(): object { if (empty($this->unreadInbox)) { $this->fail('Unread Inbox is Empty'); @@ -260,9 +261,9 @@ protected function getMostRecentUnreadEmail() * Returns the full content of an email * * @param string $id ID from the header - * @return mixed Returns a JSON encoded Email + * @return object Returns a JSON encoded Email */ - protected function getFullEmail($id) + protected function getFullEmail(string $id): object { try { $response = $this->mailhog->request('GET', "/api/v1/messages/{$id}"); @@ -277,11 +278,8 @@ protected function getFullEmail($id) * Get Email Subject * * Returns the subject of an email - * - * @param mixed $email Email - * @return string Subject */ - protected function getEmailSubject($email) + protected function getEmailSubject(object $email): string { return $this->getDecodedEmailProperty($email, $email->Content->Headers->Subject[0]); } @@ -290,11 +288,8 @@ protected function getEmailSubject($email) * Get Email Body * * Returns the body of an email - * - * @param mixed $email Email - * @return string Body */ - protected function getEmailBody($email) + protected function getEmailBody(object $email): string { return $this->getDecodedEmailProperty($email, $email->Content->Body); } @@ -303,11 +298,8 @@ protected function getEmailBody($email) * Get Email To * * Returns the string containing the persons included in the To field - * - * @param mixed $email Email - * @return string To */ - protected function getEmailTo($email) + protected function getEmailTo(object $email): string { return $this->getDecodedEmailProperty($email, $email->Content->Headers->To[0]); } @@ -316,11 +308,8 @@ protected function getEmailTo($email) * Get Email CC * * Returns the string containing the persons included in the CC field - * - * @param mixed $email Email - * @return string CC */ - protected function getEmailCC($email) + protected function getEmailCC(object $email): string { $emailCc = ''; if (isset($email->Content->Headers->Cc)) { @@ -333,11 +322,8 @@ protected function getEmailCC($email) * Get Email BCC * * Returns the string containing the persons included in the BCC field - * - * @param mixed $email Email - * @return string BCC */ - protected function getEmailBCC($email) + protected function getEmailBCC(object $email): string { $emailBcc = ''; if (isset($email->Content->Headers->Bcc)) { @@ -350,11 +336,8 @@ protected function getEmailBCC($email) * Get Email Recipients * * Returns the string containing all of the recipients, such as To, CC and if provided BCC - * - * @param mixed $email Email - * @return string Recipients */ - protected function getEmailRecipients($email) + protected function getEmailRecipients(object $email): string { $recipients = []; if (isset($email->Content->Headers->To)) { @@ -376,11 +359,8 @@ protected function getEmailRecipients($email) * Get Email Sender * * Returns the string containing the sender of the email - * - * @param mixed $email Email - * @return string Sender */ - protected function getEmailSender($email) + protected function getEmailSender(object $email): string { return $this->getDecodedEmailProperty($email, $email->Content->Headers->From[0]); } @@ -389,11 +369,8 @@ protected function getEmailSender($email) * Get Email Reply To * * Returns the string containing the address to reply to - * - * @param mixed $email Email - * @return string ReplyTo */ - protected function getEmailReplyTo($email) + protected function getEmailReplyTo(object $email): string { return $this->getDecodedEmailProperty($email, $email->Content->Headers->{'Reply-To'}[0]); } @@ -402,22 +379,16 @@ protected function getEmailReplyTo($email) * Get Email Priority * * Returns the priority of the email - * - * @param mixed $email Email - * @return string Priority */ - protected function getEmailPriority($email) + protected function getEmailPriority(object $email): string { return $this->getDecodedEmailProperty($email, $email->Content->Headers->{'X-Priority'}[0]); } /** * Returns the decoded email property - * - * @param string $property - * @return string */ - protected function getDecodedEmailProperty($email, $property) + protected function getDecodedEmailProperty(object $email, string $property): string { if ((string)$property != '') { if (!empty($email->Content->Headers->{'Content-Transfer-Encoding'}) && @@ -453,9 +424,9 @@ protected function getDecodedEmailProperty($email, $property) * * Sets the current inbox to work on, also create a copy of it to handle unread emails * - * @param array $inbox Inbox + * @param array $inbox Inbox */ - protected function setCurrentInbox($inbox) + protected function setCurrentInbox(array $inbox): void { $this->currentInbox = $inbox; $this->unreadInbox = $inbox; @@ -466,9 +437,9 @@ protected function setCurrentInbox($inbox) * * Returns the complete current inbox * - * @return array Current Inbox + * @return array Current Inbox */ - protected function getCurrentInbox() + protected function getCurrentInbox(): array { return $this->currentInbox; } @@ -478,9 +449,9 @@ protected function getCurrentInbox() * * Returns the inbox containing unread emails * - * @return array Unread Inbox + * @return array Unread Inbox */ - protected function getUnreadInbox() + protected function getUnreadInbox(): array { return $this->unreadInbox; } @@ -490,9 +461,9 @@ protected function getUnreadInbox() * * Sorts the inbox based on the timestamp * - * @param array $inbox Inbox to sort + * @param array $inbox Inbox to sort */ - protected function sortEmails($inbox) + protected function sortEmails(array $inbox): void { usort($inbox, [$this, 'sortEmailsByCreationDatePredicate']); } @@ -501,12 +472,8 @@ protected function sortEmails($inbox) * Get Email To * * Returns the string containing the persons included in the To field - * - * @param mixed $emailA Email - * @param mixed $emailB Email - * @return int Which email should go first */ - public static function sortEmailsByCreationDatePredicate($emailA, $emailB) + public static function sortEmailsByCreationDatePredicate(object $emailA, object $emailB): int { $sortKeyA = $emailA->Content->Headers->Date; $sortKeyB = $emailB->Content->Headers->Date; diff --git a/src/TestsEmails.php b/src/TestsEmails.php index 9ff7b10..f17d46c 100644 --- a/src/TestsEmails.php +++ b/src/TestsEmails.php @@ -17,7 +17,7 @@ trait TestsEmails * * Checks if there are any emails in the inbox */ - public function haveEmails() + public function haveEmails(): void { $currentInbox = $this->getCurrentInbox(); $this->assertGreaterThan(0, count($currentInbox)); @@ -29,7 +29,7 @@ public function haveEmails() * Checks that the amount of emails in the inbox is exactly $expected * @params int $expected Number of expected emails */ - public function haveNumberOfEmails($expected) + public function haveNumberOfEmails(int $expected): void { $currentInbox = $this->getCurrentInbox(); $this->assertEquals($expected, count($currentInbox)); @@ -40,7 +40,7 @@ public function haveNumberOfEmails($expected) * * Checks that there are no emails in the inbox */ - public function dontHaveEmails() + public function dontHaveEmails(): void { $currentInbox = $this->getCurrentInbox(); $this->assertEquals(0, count($currentInbox)); @@ -51,7 +51,7 @@ public function dontHaveEmails() * * Checks that there is at least one unread email **/ - public function haveUnreadEmails() + public function haveUnreadEmails(): void { $unreadInbox = $this->getUnreadInbox(); $this->assertGreaterThan(0, count($unreadInbox)); @@ -63,7 +63,7 @@ public function haveUnreadEmails() * Checks that the amount of emails in the unread inbox is exactly $expected * @params int $expected Number of expected emails */ - public function haveNumberOfUnreadEmails($expected) + public function haveNumberOfUnreadEmails(int $expected): void { $unreadInbox = $this->getUnreadInbox(); $this->assertEquals($expected, count($unreadInbox)); @@ -74,7 +74,7 @@ public function haveNumberOfUnreadEmails($expected) * * Checks that there are no unread emails in the inbox */ - public function dontHaveUnreadEmails() + public function dontHaveUnreadEmails(): void { $unreadInbox = $this->getUnreadInbox(); $this->assertEquals(0, count($unreadInbox)); @@ -87,7 +87,7 @@ public function dontHaveUnreadEmails() * * @param string $expected Text */ - public function seeInOpenedEmailBody($expected) + public function seeInOpenedEmailBody(string $expected): void { $email = $this->getOpenedEmail(); $this->seeInEmailBody($email, $expected); @@ -100,7 +100,7 @@ public function seeInOpenedEmailBody($expected) * * @param string $expected Text */ - public function seeInOpenedEmailSubject($expected) + public function seeInOpenedEmailSubject(string $expected): void { $email = $this->getOpenedEmail(); $this->seeInEmailSubject($email, $expected); @@ -113,7 +113,7 @@ public function seeInOpenedEmailSubject($expected) * * @param string $expected Text */ - public function dontSeeInOpenedEmailBody($expected) + public function dontSeeInOpenedEmailBody(string $expected): void { $email = $this->getOpenedEmail(); $this->dontSeeInEmailBody($email, $expected); @@ -126,7 +126,7 @@ public function dontSeeInOpenedEmailBody($expected) * * @param string $expected Text */ - public function dontSeeInOpenedEmailSubject($expected) + public function dontSeeInOpenedEmailSubject(string $expected): void { $email = $this->getOpenedEmail(); $this->dontSeeInEmailSubject($email, $expected); @@ -137,10 +137,10 @@ public function dontSeeInOpenedEmailSubject($expected) * * Checks that the body of $email contains $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function seeInEmailBody($email, $expected) + public function seeInEmailBody(object $email, string $expected): void { $this->assertStringContainsString($expected, $this->getEmailBody($email), 'Email Body Contains'); } @@ -150,10 +150,10 @@ public function seeInEmailBody($email, $expected) * * Checks that the body of $email does not contain $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function dontSeeInEmailBody($email, $expected) + public function dontSeeInEmailBody(object $email, string $expected): void { $this->assertStringNotContainsString($expected, $this->getEmailBody($email), "Email Body Doesn't Contain"); } @@ -163,10 +163,10 @@ public function dontSeeInEmailBody($email, $expected) * * Checks that the subject of $email contains $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function seeInEmailSubject($email, $expected) + public function seeInEmailSubject(object $email, string $expected): void { $this->assertStringContainsString($expected, $this->getEmailSubject($email), 'Email Subject Contains'); } @@ -176,10 +176,10 @@ public function seeInEmailSubject($email, $expected) * * Checks that the subject of $email does not contain $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function dontSeeInEmailSubject($email, $expected) + public function dontSeeInEmailSubject(object $email, string $expected): void { $this->assertStringNotContainsString($expected, $this->getEmailSubject($email), "Email Subject Doesn't Contain"); } @@ -191,7 +191,7 @@ public function dontSeeInEmailSubject($email, $expected) * * @param string $expected Text */ - public function seeInOpenedEmailSender($expected) + public function seeInOpenedEmailSender(string $expected): void { $email = $this->getOpenedEmail(); $this->seeInEmailSender($email, $expected); @@ -204,7 +204,7 @@ public function seeInOpenedEmailSender($expected) * * @param string $expected Text */ - public function dontSeeInOpenedEmailSender($expected) + public function dontSeeInOpenedEmailSender(string $expected): void { $email = $this->getOpenedEmail(); $this->dontSeeInEmailSender($email, $expected); @@ -215,10 +215,10 @@ public function dontSeeInOpenedEmailSender($expected) * * Checks if the sender of $email contains $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function seeInEmailSender($email, $expected) + public function seeInEmailSender(object $email, string $expected): void { $this->assertStringContainsString($expected, $this->getEmailSender($email)); } @@ -228,10 +228,10 @@ public function seeInEmailSender($email, $expected) * * Checks if the sender of $email does not contain $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function dontSeeInEmailSender($email, $expected) + public function dontSeeInEmailSender(object $email, string $expected): void { $this->assertStringNotContainsString($expected, $this->getEmailSender($email)); } @@ -243,7 +243,7 @@ public function dontSeeInEmailSender($email, $expected) * * @param string $expected Text */ - public function seeInOpenedEmailReplyTo($expected) + public function seeInOpenedEmailReplyTo(string $expected): void { $email = $this->getOpenedEmail(); $this->seeInEmailReplyTo($email, $expected); @@ -256,7 +256,7 @@ public function seeInOpenedEmailReplyTo($expected) * * @param string $expected Text */ - public function dontSeeInOpenedEmailReplyTo($expected) + public function dontSeeInOpenedEmailReplyTo(string $expected): void { $email = $this->getOpenedEmail(); $this->dontSeeInEmailReplyTo($email, $expected); @@ -267,10 +267,10 @@ public function dontSeeInOpenedEmailReplyTo($expected) * * Checks if the ReplyTo of $email contains $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function seeInEmailReplyTo($email, $expected) + public function seeInEmailReplyTo(object $email, string $expected): void { $this->assertStringContainsString($expected, $this->getEmailReplyTo($email)); } @@ -280,10 +280,10 @@ public function seeInEmailReplyTo($email, $expected) * * Checks if the ReplyTo of $email does not contain $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function dontSeeInEmailReplyTo($email, $expected) + public function dontSeeInEmailReplyTo(object $email, string $expected): void { $this->assertStringNotContainsString($expected, $this->getEmailReplyTo($email)); } @@ -295,7 +295,7 @@ public function dontSeeInEmailReplyTo($email, $expected) * * @param string $expected Text */ - public function seeInOpenedEmailRecipients($expected) + public function seeInOpenedEmailRecipients(string $expected): void { $email = $this->getOpenedEmail(); $this->seeInEmailRecipients($email, $expected); @@ -308,7 +308,7 @@ public function seeInOpenedEmailRecipients($expected) * * @param string $expected Text */ - public function dontSeeInOpenedEmailRecipients($expected) + public function dontSeeInOpenedEmailRecipients(string $expected): void { $email = $this->getOpenedEmail(); $this->dontSeeInEmailRecipients($email, $expected); @@ -319,10 +319,10 @@ public function dontSeeInOpenedEmailRecipients($expected) * * Checks that the recipients of $email contain $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function seeInEmailRecipients($email, $expected) + public function seeInEmailRecipients(object $email, string $expected): void { $this->assertStringContainsString($expected, $this->getEmailRecipients($email)); } @@ -332,10 +332,10 @@ public function seeInEmailRecipients($email, $expected) * * Checks that the recipients of $email do not contain $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function dontSeeInEmailRecipients($email, $expected) + public function dontSeeInEmailRecipients(object $email, string $expected): void { $this->assertStringNotContainsString($expected, $this->getEmailRecipients($email)); } @@ -347,7 +347,7 @@ public function dontSeeInEmailRecipients($email, $expected) * * @param string $expected Text */ - public function seeInOpenedEmailToField($expected) + public function seeInOpenedEmailToField(string $expected): void { $email = $this->getOpenedEmail(); $this->seeInEmailToField($email, $expected); @@ -360,7 +360,7 @@ public function seeInOpenedEmailToField($expected) * * @param string $expected Text */ - public function dontSeeInOpenedEmailToField($expected) + public function dontSeeInOpenedEmailToField(string $expected): void { $email = $this->getOpenedEmail(); $this->dontSeeInEmailToField($email, $expected); @@ -371,10 +371,10 @@ public function dontSeeInOpenedEmailToField($expected) * * Checks that the To field of $email contains $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function seeInEmailToField($email, $expected) + public function seeInEmailToField(object $email, string $expected): void { $this->assertStringContainsString($expected, $this->getEmailTo($email)); } @@ -384,10 +384,10 @@ public function seeInEmailToField($email, $expected) * * Checks that the To field of $email does not contain $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function dontSeeInEmailToField($email, $expected) + public function dontSeeInEmailToField(object $email, string $expected): void { $this->assertStringNotContainsString($expected, $this->getEmailTo($email)); } @@ -399,7 +399,7 @@ public function dontSeeInEmailToField($email, $expected) * * @param string $expected Text */ - public function seeInOpenedEmailCCField($expected) + public function seeInOpenedEmailCCField(string $expected): void { $email = $this->getOpenedEmail(); $this->seeInEmailCCField($email, $expected); @@ -412,7 +412,7 @@ public function seeInOpenedEmailCCField($expected) * * @param string $expected Text */ - public function dontSeeInOpenedEmailCCField($expected) + public function dontSeeInOpenedEmailCCField(string $expected): void { $email = $this->getOpenedEmail(); $this->dontSeeInEmailCCField($email, $expected); @@ -423,10 +423,10 @@ public function dontSeeInOpenedEmailCCField($expected) * * Checks that the CC field of $email contains $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function seeInEmailCCField($email, $expected) + public function seeInEmailCCField(object $email, string $expected): void { $this->assertStringContainsString($expected, $this->getEmailCC($email)); } @@ -436,10 +436,10 @@ public function seeInEmailCCField($email, $expected) * * Checks that the CC field of $email does not contain $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function dontSeeInEmailCCField($email, $expected) + public function dontSeeInEmailCCField(object $email, string $expected): void { $this->assertStringNotContainsString($expected, $this->getEmailCC($email)); } @@ -453,7 +453,7 @@ public function dontSeeInEmailCCField($email, $expected) * * @param string $expected Text */ - public function seeInOpenedEmailBCCField($expected) + public function seeInOpenedEmailBCCField(string $expected): void { $email = $this->getOpenedEmail(); $this->seeInEmailBCCField($email, $expected); @@ -468,7 +468,7 @@ public function seeInOpenedEmailBCCField($expected) * * @param string $expected Text */ - public function dontSeeInOpenedEmailBCCField($expected) + public function dontSeeInOpenedEmailBCCField(string $expected): void { $email = $this->getOpenedEmail(); $this->dontSeeInEmailBCCField($email, $expected); @@ -481,10 +481,10 @@ public function dontSeeInOpenedEmailBCCField($expected) * * Warning: it is possible for an email to have its BCC field empty, it doesn't mean that another instance of the same email doesn't exist. * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function seeInEmailBCCField($email, $expected) + public function seeInEmailBCCField(object $email, string $expected): void { $this->assertStringContainsString($expected, $this->getEmailBCC($email)); } @@ -496,10 +496,10 @@ public function seeInEmailBCCField($email, $expected) * * Warning: it is possible for an email to have its BCC field empty, it doesn't mean that another instance of the same email doesn't exist. * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected Text */ - public function dontSeeInEmailBCCField($email, $expected) + public function dontSeeInEmailBCCField(object $email, string $expected): void { $this->assertStringNotContainsString($expected, $this->getEmailBCC($email)); } @@ -511,7 +511,7 @@ public function dontSeeInEmailBCCField($email, $expected) * * @param string $expected priority */ - public function seeInOpenedEmailPriority($expected) + public function seeInOpenedEmailPriority(string $expected): void { $email = $this->getOpenedEmail(); $this->seeInEmailPriority($email, $expected); @@ -524,7 +524,7 @@ public function seeInOpenedEmailPriority($expected) * * @param string $expected priority */ - public function dontSeeInOpenedEmailPriority($expected) + public function dontSeeInOpenedEmailPriority(string $expected): void { $email = $this->getOpenedEmail(); $this->dontSeeInEmailPriority($email, $expected); @@ -535,10 +535,10 @@ public function dontSeeInOpenedEmailPriority($expected) * * Checks that the priority of $email contains $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected priority */ - public function seeInEmailPriority($email, $expected) + public function seeInEmailPriority(object $email, string $expected): void { $this->assertStringContainsString($expected, $this->getEmailPriority($email)); } @@ -548,19 +548,19 @@ public function seeInEmailPriority($email, $expected) * * Checks that the priority of $email does not contain $expected * - * @param mixed $email a JSON encoded email + * @param object $email a JSON encoded email * @param string $expected priority */ - public function dontSeeInEmailPriority($email, $expected) + public function dontSeeInEmailPriority(object $email, string $expected): void { $this->assertStringNotContainsString($expected, $this->getEmailPriority($email)); } /** * @param string $content_type_alternative MIME-part Content-Type - * @return string Body + * @return string|null Body */ - public function grabBodyFromEmail($content_type_alternative = null) + public function grabBodyFromEmail(string $content_type_alternative = null): ?string { $email = $this->getOpenedEmail();