From 0cef93829998fd6d5879f91fb34639a5a193365c Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma <roeland@famdouma.nl>
Date: Thu, 1 Mar 2018 21:15:39 +0100
Subject: [PATCH] Make \OCP\Mail strict

* Fix typehints
* Made strict

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
---
 lib/private/Mail/Attachment.php    |  9 ++++---
 lib/private/Mail/EMailTemplate.php | 31 +++++++++++-----------
 lib/private/Mail/Mailer.php        | 21 +++++++--------
 lib/private/Mail/Message.php       | 41 +++++++++++++++---------------
 lib/public/Mail/IAttachment.php    | 13 +++++-----
 lib/public/Mail/IEMailTemplate.php | 21 +++++++--------
 lib/public/Mail/IMailer.php        | 13 +++++-----
 lib/public/Mail/IMessage.php       | 29 +++++++++++----------
 8 files changed, 93 insertions(+), 85 deletions(-)

diff --git a/lib/private/Mail/Attachment.php b/lib/private/Mail/Attachment.php
index 822fca5a24e..b696451e41c 100644
--- a/lib/private/Mail/Attachment.php
+++ b/lib/private/Mail/Attachment.php
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
  *
@@ -45,7 +46,7 @@ class Attachment implements IAttachment {
 	 * @return $this
 	 * @since 13.0.0
 	 */
-	public function setFilename($filename) {
+	public function setFilename(string $filename): IAttachment {
 		$this->swiftAttachment->setFilename($filename);
 		return $this;
 	}
@@ -55,7 +56,7 @@ class Attachment implements IAttachment {
 	 * @return $this
 	 * @since 13.0.0
 	 */
-	public function setContentType($contentType) {
+	public function setContentType(string $contentType): IAttachment {
 		$this->swiftAttachment->setContentType($contentType);
 		return $this;
 	}
@@ -65,7 +66,7 @@ class Attachment implements IAttachment {
 	 * @return $this
 	 * @since 13.0.0
 	 */
-	public function setBody($body) {
+	public function setBody(string $body): IAttachment {
 		$this->swiftAttachment->setBody($body);
 		return $this;
 	}
@@ -73,7 +74,7 @@ class Attachment implements IAttachment {
 	/**
 	 * @return \Swift_Mime_Attachment
 	 */
-	public function getSwiftAttachment() {
+	public function getSwiftAttachment(): \Swift_Mime_Attachment {
 		return $this->swiftAttachment;
 	}
 
diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php
index 38205af366e..dd62490edeb 100644
--- a/lib/private/Mail/EMailTemplate.php
+++ b/lib/private/Mail/EMailTemplate.php
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright 2017, Morris Jobke <hey@morrisjobke.de>
  * @copyright 2017, Lukas Reschke <lukas@statuscode.ch>
@@ -367,7 +368,7 @@ EOF;
 	 *
 	 * @param string $subject
 	 */
-	public function setSubject($subject) {
+	public function setSubject(string $subject) {
 		$this->subject = $subject;
 	}
 
@@ -391,7 +392,7 @@ EOF;
 	 * @param string|bool $plainTitle Title that is used in the plain text email
 	 *   if empty the $title is used, if false none will be used
 	 */
-	public function addHeading($title, $plainTitle = '') {
+	public function addHeading(string $title, $plainTitle = '') {
 		if ($this->footerAdded) {
 			return;
 		}
@@ -424,7 +425,7 @@ EOF;
 	 * @param string|bool $plainText Text that is used in the plain text email
 	 *   if empty the $text is used, if false none will be used
 	 */
-	public function addBodyText($text, $plainText = '') {
+	public function addBodyText(string $text, $plainText = '') {
 		if ($this->footerAdded) {
 			return;
 		}
@@ -453,7 +454,7 @@ EOF;
 	 *   if empty the $metaInfo is used, if false none will be used
 	 * @since 12.0.0
 	 */
-	public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') {
+	public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', string $plainText = '', string $plainMetaInfo = '') {
 		$this->ensureBodyListOpened();
 
 		if ($plainText === '') {
@@ -513,12 +514,12 @@ EOF;
 	 * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used
 	 * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used
 	 */
-	public function addBodyButtonGroup($textLeft,
-									   $urlLeft,
-									   $textRight,
-									   $urlRight,
-									   $plainTextLeft = '',
-									   $plainTextRight = '') {
+	public function addBodyButtonGroup(string $textLeft,
+									   string $urlLeft,
+									   string $textRight,
+									   string $urlRight,
+									   string $plainTextLeft = '',
+									   string $plainTextRight = '') {
 		if ($this->footerAdded) {
 			return;
 		}
@@ -554,7 +555,7 @@ EOF;
 	 *
 	 * @since 12.0.0
 	 */
-	public function addBodyButton($text, $url, $plainText = '') {
+	public function addBodyButton(string $text, string $url, string $plainText = '') {
 		if ($this->footerAdded) {
 			return;
 		}
@@ -598,7 +599,7 @@ EOF;
 	 *
 	 * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
 	 */
-	public function addFooter($text = '') {
+	public function addFooter(string $text = '') {
 		if($text === '') {
 			$text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.');
 		}
@@ -621,7 +622,7 @@ EOF;
 	 *
 	 * @return string
 	 */
-	public function renderSubject() {
+	public function renderSubject(): string {
 		return $this->subject;
 	}
 
@@ -630,7 +631,7 @@ EOF;
 	 *
 	 * @return string
 	 */
-	public function renderHtml() {
+	public function renderHtml(): string {
 		if (!$this->footerAdded) {
 			$this->footerAdded = true;
 			$this->ensureBodyIsClosed();
@@ -644,7 +645,7 @@ EOF;
 	 *
 	 * @return string
 	 */
-	public function renderText() {
+	public function renderText(): string {
 		if (!$this->footerAdded) {
 			$this->footerAdded = true;
 			$this->ensureBodyIsClosed();
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php
index 3637bb1e27d..5a054d2efd2 100644
--- a/lib/private/Mail/Mailer.php
+++ b/lib/private/Mail/Mailer.php
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2016, ownCloud, Inc.
  *
@@ -91,7 +92,7 @@ class Mailer implements IMailer {
 	 *
 	 * @return IMessage
 	 */
-	public function createMessage() {
+	public function createMessage(): IMessage {
 		return new Message(new \Swift_Message());
 	}
 
@@ -102,7 +103,7 @@ class Mailer implements IMailer {
 	 * @return IAttachment
 	 * @since 13.0.0
 	 */
-	public function createAttachment($data = null, $filename = null, $contentType = null) {
+	public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment {
 		return new Attachment(\Swift_Attachment::newInstance($data, $filename, $contentType));
 	}
 
@@ -112,7 +113,7 @@ class Mailer implements IMailer {
 	 * @return IAttachment
 	 * @since 13.0.0
 	 */
-	public function createAttachmentFromPath($path, $contentType = null) {
+	public function createAttachmentFromPath(string $path, $contentType = null): IAttachment {
 		return new Attachment(\Swift_Attachment::fromPath($path, $contentType));
 	}
 
@@ -124,7 +125,7 @@ class Mailer implements IMailer {
 	 * @return IEMailTemplate
 	 * @since 12.0.0
 	 */
-	public function createEMailTemplate($emailId, array $data = []) {
+	public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate {
 		$class = $this->config->getSystemValue('mail_template_class', '');
 
 		if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) {
@@ -156,7 +157,7 @@ class Mailer implements IMailer {
 	 * @throws \Exception In case it was not possible to send the message. (for example if an invalid mail address
 	 * has been supplied.)
 	 */
-	public function send(IMessage $message) {
+	public function send(IMessage $message): array {
 		$debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
 
 		if (empty($message->getFrom())) {
@@ -191,7 +192,7 @@ class Mailer implements IMailer {
 	 * @param string $email Email address to be validated
 	 * @return bool True if the mail address is valid, false otherwise
 	 */
-	public function validateMailAddress($email) {
+	public function validateMailAddress(string $email): bool {
 		return \Swift_Validate::email($this->convertEmail($email));
 	}
 
@@ -203,7 +204,7 @@ class Mailer implements IMailer {
 	 * @param string $email
 	 * @return string Converted mail address if `idn_to_ascii` exists
 	 */
-	protected function convertEmail($email) {
+	protected function convertEmail(string $email): string {
 		if (!function_exists('idn_to_ascii') || strpos($email, '@') === false) {
 			return $email;
 		}
@@ -246,7 +247,7 @@ class Mailer implements IMailer {
 	 *
 	 * @return \Swift_SmtpTransport
 	 */
-	protected function getSmtpInstance() {
+	protected function getSmtpInstance(): \Swift_SmtpTransport {
 		$transport = \Swift_SmtpTransport::newInstance();
 		$transport->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10));
 		$transport->setHost($this->config->getSystemValue('mail_smtphost', '127.0.0.1'));
@@ -269,7 +270,7 @@ class Mailer implements IMailer {
 	 *
 	 * @return \Swift_SendmailTransport
 	 */
-	protected function getSendMailInstance() {
+	protected function getSendMailInstance(): \Swift_SendmailTransport {
 		switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
 			case 'qmail':
 				$binaryPath = '/var/qmail/bin/sendmail';
@@ -287,7 +288,7 @@ class Mailer implements IMailer {
 	 *
 	 * @return \Swift_MailTransport
 	 */
-	protected function getMailInstance() {
+	protected function getMailInstance(): \Swift_MailTransport {
 		return \Swift_MailTransport::newInstance();
 	}
 
diff --git a/lib/private/Mail/Message.php b/lib/private/Mail/Message.php
index c695f0f4fb1..5d23c374d42 100644
--- a/lib/private/Mail/Message.php
+++ b/lib/private/Mail/Message.php
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2016, ownCloud, Inc.
  *
@@ -51,7 +52,7 @@ class Message implements IMessage {
 	 * @return $this
 	 * @since 13.0.0
 	 */
-	public function attach(IAttachment $attachment) {
+	public function attach(IAttachment $attachment): IMessage {
 		/** @var Attachment $attachment */
 		$this->swiftMessage->attach($attachment->getSwiftAttachment());
 		return $this;
@@ -64,12 +65,12 @@ class Message implements IMessage {
 	 * @param array $addresses Array of mail addresses, key will get converted
 	 * @return array Converted addresses if `idn_to_ascii` exists
 	 */
-	protected function convertAddresses($addresses) {
+	protected function convertAddresses(array $addresses): array {
 		if (!function_exists('idn_to_ascii')) {
 			return $addresses;
 		}
 
-		$convertedAddresses = array();
+		$convertedAddresses = [];
 
 		foreach($addresses as $email => $readableName) {
 			if(!is_numeric($email)) {
@@ -94,7 +95,7 @@ class Message implements IMessage {
 	 * @param array $addresses Example: array('sender@domain.org', 'other@domain.org' => 'A name')
 	 * @return $this
 	 */
-	public function setFrom(array $addresses) {
+	public function setFrom(array $addresses): IMessage {
 		$addresses = $this->convertAddresses($addresses);
 
 		$this->swiftMessage->setFrom($addresses);
@@ -106,7 +107,7 @@ class Message implements IMessage {
 	 *
 	 * @return array
 	 */
-	public function getFrom() {
+	public function getFrom(): array {
 		return $this->swiftMessage->getFrom();
 	}
 
@@ -116,7 +117,7 @@ class Message implements IMessage {
 	 * @param array $addresses
 	 * @return $this
 	 */
-	public function setReplyTo(array $addresses) {
+	public function setReplyTo(array $addresses): IMessage {
 		$addresses = $this->convertAddresses($addresses);
 
 		$this->swiftMessage->setReplyTo($addresses);
@@ -126,9 +127,9 @@ class Message implements IMessage {
 	/**
 	 * Returns the Reply-To address of this message
 	 *
-	 * @return array
+	 * @return string
 	 */
-	public function getReplyTo() {
+	public function getReplyTo(): string {
 		return $this->swiftMessage->getReplyTo();
 	}
 
@@ -138,7 +139,7 @@ class Message implements IMessage {
 	 * @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
 	 * @return $this
 	 */
-	public function setTo(array $recipients) {
+	public function setTo(array $recipients): IMessage {
 		$recipients = $this->convertAddresses($recipients);
 
 		$this->swiftMessage->setTo($recipients);
@@ -150,7 +151,7 @@ class Message implements IMessage {
 	 *
 	 * @return array
 	 */
-	public function getTo() {
+	public function getTo(): array {
 		return $this->swiftMessage->getTo();
 	}
 
@@ -160,7 +161,7 @@ class Message implements IMessage {
 	 * @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
 	 * @return $this
 	 */
-	public function setCc(array $recipients) {
+	public function setCc(array $recipients): IMessage {
 		$recipients = $this->convertAddresses($recipients);
 
 		$this->swiftMessage->setCc($recipients);
@@ -172,7 +173,7 @@ class Message implements IMessage {
 	 *
 	 * @return array
 	 */
-	public function getCc() {
+	public function getCc(): array {
 		return $this->swiftMessage->getCc();
 	}
 
@@ -182,7 +183,7 @@ class Message implements IMessage {
 	 * @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
 	 * @return $this
 	 */
-	public function setBcc(array $recipients) {
+	public function setBcc(array $recipients): IMessage {
 		$recipients = $this->convertAddresses($recipients);
 
 		$this->swiftMessage->setBcc($recipients);
@@ -194,7 +195,7 @@ class Message implements IMessage {
 	 *
 	 * @return array
 	 */
-	public function getBcc() {
+	public function getBcc(): array {
 		return $this->swiftMessage->getBcc();
 	}
 
@@ -204,7 +205,7 @@ class Message implements IMessage {
 	 * @param $subject
 	 * @return $this
 	 */
-	public function setSubject($subject) {
+	public function setSubject($subject): IMessage {
 		$this->swiftMessage->setSubject($subject);
 		return $this;
 	}
@@ -214,7 +215,7 @@ class Message implements IMessage {
 	 *
 	 * @return string
 	 */
-	public function getSubject() {
+	public function getSubject(): string {
 		return $this->swiftMessage->getSubject();
 	}
 
@@ -224,7 +225,7 @@ class Message implements IMessage {
 	 * @param string $body
 	 * @return $this
 	 */
-	public function setPlainBody($body) {
+	public function setPlainBody(string $body): IMessage {
 		$this->swiftMessage->setBody($body);
 		return $this;
 	}
@@ -234,7 +235,7 @@ class Message implements IMessage {
 	 *
 	 * @return string
 	 */
-	public function getPlainBody() {
+	public function getPlainBody(): string {
 		return $this->swiftMessage->getBody();
 	}
 
@@ -253,7 +254,7 @@ class Message implements IMessage {
 	 * Get's the underlying SwiftMessage
 	 * @return Swift_Message
 	 */
-	public function getSwiftMessage() {
+	public function getSwiftMessage(): Swift_Message {
 		return $this->swiftMessage;
 	}
 
@@ -271,7 +272,7 @@ class Message implements IMessage {
 	 * @param IEMailTemplate $emailTemplate
 	 * @return $this
 	 */
-	public function useTemplate(IEMailTemplate $emailTemplate) {
+	public function useTemplate(IEMailTemplate $emailTemplate): IMessage {
 		$this->setSubject($emailTemplate->renderSubject());
 		$this->setPlainBody($emailTemplate->renderText());
 		$this->setHtmlBody($emailTemplate->renderHtml());
diff --git a/lib/public/Mail/IAttachment.php b/lib/public/Mail/IAttachment.php
index 4b617d67f5e..71fa841b26c 100644
--- a/lib/public/Mail/IAttachment.php
+++ b/lib/public/Mail/IAttachment.php
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
  *
@@ -33,23 +34,23 @@ interface IAttachment {
 
 	/**
 	 * @param string $filename
-	 * @return $this
+	 * @return IAttachment
 	 * @since 13.0.0
 	 */
-	public function setFilename($filename);
+	public function setFilename(string $filename): IAttachment;
 
 	/**
 	 * @param string $contentType
-	 * @return $this
+	 * @return IAttachment
 	 * @since 13.0.0
 	 */
-	public function setContentType($contentType);
+	public function setContentType(string $contentType): IAttachment;
 
 	/**
 	 * @param string $body
-	 * @return $this
+	 * @return IAttachment
 	 * @since 13.0.0
 	 */
-	public function setBody($body);
+	public function setBody(string $body): IAttachment;
 
 }
diff --git a/lib/public/Mail/IEMailTemplate.php b/lib/public/Mail/IEMailTemplate.php
index 6d37c21ada1..6abcdd12b9c 100644
--- a/lib/public/Mail/IEMailTemplate.php
+++ b/lib/public/Mail/IEMailTemplate.php
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright 2017, Morris Jobke <hey@morrisjobke.de>
  *
@@ -62,7 +63,7 @@ interface IEMailTemplate {
 	 *
 	 * @since 13.0.0
 	 */
-	public function setSubject($subject);
+	public function setSubject(string $subject);
 
 	/**
 	 * Adds a header to the email
@@ -80,7 +81,7 @@ interface IEMailTemplate {
 	 *
 	 * @since 12.0.0
 	 */
-	public function addHeading($title, $plainTitle = '');
+	public function addHeading(string $title, $plainTitle = '');
 
 	/**
 	 * Adds a paragraph to the body of the email
@@ -91,7 +92,7 @@ interface IEMailTemplate {
 	 *
 	 * @since 12.0.0
 	 */
-	public function addBodyText($text, $plainText = '');
+	public function addBodyText(string $text, $plainText = '');
 
 	/**
 	 * Adds a list item to the body of the email
@@ -105,7 +106,7 @@ interface IEMailTemplate {
 	 *   if empty the $metaInfo is used, if false none will be used
 	 * @since 12.0.0
 	 */
-	public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '');
+	public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', string $plainText = '', string $plainMetaInfo = '');
 
 	/**
 	 * Adds a button group of two buttons to the body of the email
@@ -119,7 +120,7 @@ interface IEMailTemplate {
 	 *
 	 * @since 12.0.0
 	 */
-	public function addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft = '', $plainTextRight = '');
+	public function addBodyButtonGroup(string $textLeft, string $urlLeft, string $textRight, string $urlRight, string $plainTextLeft = '', string $plainTextRight = '');
 
 	/**
 	 * Adds a button to the body of the email
@@ -131,7 +132,7 @@ interface IEMailTemplate {
 	 *
 	 * @since 12.0.0
 	 */
-	public function addBodyButton($text, $url, $plainText = '');
+	public function addBodyButton(string $text, string $url, string $plainText = '');
 
 	/**
 	 * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
@@ -140,7 +141,7 @@ interface IEMailTemplate {
 	 *
 	 * @since 12.0.0
 	 */
-	public function addFooter($text = '');
+	public function addFooter(string $text = '');
 
 	/**
 	 * Returns the rendered email subject as string
@@ -149,7 +150,7 @@ interface IEMailTemplate {
 	 *
 	 * @since 13.0.0
 	 */
-	public function renderSubject();
+	public function renderSubject(): string;
 
 	/**
 	 * Returns the rendered HTML email as string
@@ -158,7 +159,7 @@ interface IEMailTemplate {
 	 *
 	 * @since 12.0.0
 	 */
-	public function renderHtml();
+	public function renderHtml(): string;
 
 	/**
 	 * Returns the rendered plain text email as string
@@ -167,5 +168,5 @@ interface IEMailTemplate {
 	 *
 	 * @since 12.0.0
 	 */
-	public function renderText();
+	public function renderText(): string;
 }
diff --git a/lib/public/Mail/IMailer.php b/lib/public/Mail/IMailer.php
index 10096548256..e8f5d6e7d03 100644
--- a/lib/public/Mail/IMailer.php
+++ b/lib/public/Mail/IMailer.php
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2016, ownCloud, Inc.
  *
@@ -51,7 +52,7 @@ interface IMailer {
 	 * @return IMessage
 	 * @since 8.1.0
 	 */
-	public function createMessage();
+	public function createMessage(): IMessage;
 
 	/**
 	 * @param string|null $data
@@ -60,7 +61,7 @@ interface IMailer {
 	 * @return IAttachment
 	 * @since 13.0.0
 	 */
-	public function createAttachment($data = null, $filename = null, $contentType = null);
+	public function createAttachment($data = null, $filename = null, $contentType = null): IAttachment;
 
 	/**
 	 * @param string $path
@@ -68,7 +69,7 @@ interface IMailer {
 	 * @return IAttachment
 	 * @since 13.0.0
 	 */
-	public function createAttachmentFromPath($path, $contentType = null);
+	public function createAttachmentFromPath(string $path, $contentType = null): IAttachment;
 
 	/**
 	 * Creates a new email template object
@@ -78,7 +79,7 @@ interface IMailer {
 	 * @return IEMailTemplate
 	 * @since 12.0.0 Parameters added in 12.0.3
 	 */
-	public function createEMailTemplate($emailId, array $data = []);
+	public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate;
 
 	/**
 	 * Send the specified message. Also sets the from address to the value defined in config.php
@@ -91,7 +92,7 @@ interface IMailer {
 	 * has been supplied.)
 	 * @since 8.1.0
 	 */
-	public function send(IMessage $message);
+	public function send(IMessage $message): array;
 
 	/**
 	 * Checks if an e-mail address is valid
@@ -100,5 +101,5 @@ interface IMailer {
 	 * @return bool True if the mail address is valid, false otherwise
 	 * @since 8.1.0
 	 */
-	public function validateMailAddress($email);
+	public function validateMailAddress(string $email): bool;
 }
diff --git a/lib/public/Mail/IMessage.php b/lib/public/Mail/IMessage.php
index cec47adc19d..638fd9d103f 100644
--- a/lib/public/Mail/IMessage.php
+++ b/lib/public/Mail/IMessage.php
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
  *
@@ -33,10 +34,10 @@ interface IMessage {
 
 	/**
 	 * @param IAttachment $attachment
-	 * @return $this
+	 * @return IMessage
 	 * @since 13.0.0
 	 */
-	public function attach(IAttachment $attachment);
+	public function attach(IAttachment $attachment): IMessage;
 
 	/**
 	 * Set the from address of this message.
@@ -44,51 +45,51 @@ interface IMessage {
 	 * If no "From" address is used \OC\Mail\Mailer will use mail_from_address and mail_domain from config.php
 	 *
 	 * @param array $addresses Example: array('sender@domain.org', 'other@domain.org' => 'A name')
-	 * @return $this
+	 * @return IMessage
 	 * @since 13.0.0
 	 */
-	public function setFrom(array $addresses);
+	public function setFrom(array $addresses): IMessage;
 
 	/**
 	 * Set the Reply-To address of this message
 	 *
 	 * @param array $addresses
-	 * @return $this
+	 * @return IMessage
 	 * @since 13.0.0
 	 */
-	public function setReplyTo(array $addresses);
+	public function setReplyTo(array $addresses): IMessage;
 
 	/**
 	 * Set the to addresses of this message.
 	 *
 	 * @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
-	 * @return $this
+	 * @return IMessage
 	 * @since 13.0.0
 	 */
-	public function setTo(array $recipients);
+	public function setTo(array $recipients): IMessage;
 
 	/**
 	 * Set the CC recipients of this message.
 	 *
 	 * @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
-	 * @return $this
+	 * @return IMessage
 	 * @since 13.0.0
 	 */
-	public function setCc(array $recipients);
+	public function setCc(array $recipients): IMessage;
 
 	/**
 	 * Set the BCC recipients of this message.
 	 *
 	 * @param array $recipients Example: array('recipient@domain.org', 'other@domain.org' => 'A name')
-	 * @return $this
+	 * @return IMessage
 	 * @since 13.0.0
 	 */
-	public function setBcc(array $recipients);
+	public function setBcc(array $recipients): IMessage;
 
 	/**
 	 * @param IEMailTemplate $emailTemplate
-	 * @return $this
+	 * @return IMessage
 	 * @since 13.0.0
 	 */
-	public function useTemplate(IEMailTemplate $emailTemplate);
+	public function useTemplate(IEMailTemplate $emailTemplate): IMessage;
 }
-- 
GitLab