From a933848aa276128149f6579c62b4635f25320a35 Mon Sep 17 00:00:00 2001 From: Usman Ikram Date: Thu, 20 Feb 2020 22:00:16 +0100 Subject: [PATCH] Fix type error in email validation --- system/Email/Email.php | 6 +++--- tests/system/Email/EmailTest.php | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 tests/system/Email/EmailTest.php diff --git a/system/Email/Email.php b/system/Email/Email.php index ee0e0149cc62..5ace58aca267 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -510,7 +510,7 @@ public function setReplyTo($replyto, $name = '') /** * Set Recipients * - * @param string $to + * @param string|array $to * * @return Email */ @@ -892,7 +892,7 @@ protected function getMimeMessage() /** * Validate Email Address * - * @param string $email + * @param string|array $email * * @return boolean */ @@ -907,7 +907,7 @@ public function validateEmail($email) { if (! $this->isValidEmail($val)) { - $this->setErrorMessage(lang('Email.invalidAddress', $val)); + $this->setErrorMessage(lang('Email.invalidAddress', [$val])); return false; } } diff --git a/tests/system/Email/EmailTest.php b/tests/system/Email/EmailTest.php new file mode 100644 index 000000000000..3802866780f4 --- /dev/null +++ b/tests/system/Email/EmailTest.php @@ -0,0 +1,13 @@ +validate = true; + $email = new \CodeIgniter\Email\Email($config); + $email->setTo('invalid'); + $this->assertStringContainsString('Invalid email address: invalid', $email->printDebugger()); + } +}