Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/private/Mail/Attachment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
*
Expand Down Expand Up @@ -45,7 +46,7 @@ public function __construct(\Swift_Mime_Attachment $attachment) {
* @return $this
* @since 13.0.0
*/
public function setFilename($filename) {
public function setFilename(string $filename): IAttachment {
$this->swiftAttachment->setFilename($filename);
return $this;
}
Expand All @@ -55,7 +56,7 @@ public function setFilename($filename) {
* @return $this
* @since 13.0.0
*/
public function setContentType($contentType) {
public function setContentType(string $contentType): IAttachment {
$this->swiftAttachment->setContentType($contentType);
return $this;
}
Expand All @@ -65,15 +66,15 @@ public function setContentType($contentType) {
* @return $this
* @since 13.0.0
*/
public function setBody($body) {
public function setBody(string $body): IAttachment {
$this->swiftAttachment->setBody($body);
return $this;
}

/**
* @return \Swift_Mime_Attachment
*/
public function getSwiftAttachment() {
public function getSwiftAttachment(): \Swift_Mime_Attachment {
return $this->swiftAttachment;
}

Expand Down
35 changes: 18 additions & 17 deletions lib/private/Mail/EMailTemplate.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright 2017, Morris Jobke <hey@morrisjobke.de>
* @copyright 2017, Lukas Reschke <lukas@statuscode.ch>
Expand Down Expand Up @@ -367,7 +368,7 @@ public function __construct(Defaults $themingDefaults,
*
* @param string $subject
*/
public function setSubject($subject) {
public function setSubject(string $subject) {
$this->subject = $subject;
}

Expand All @@ -391,7 +392,7 @@ public function addHeader() {
* @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;
}
Expand Down Expand Up @@ -424,7 +425,7 @@ protected function ensureBodyIsOpened() {
* @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;
}
Expand All @@ -447,13 +448,13 @@ public function addBodyText($text, $plainText = '') {
* @param string $text Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
* @param string $metaInfo Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email
* @param string $icon Absolute path, must be 16*16 pixels
* @param string $plainText Text that is used in the plain text email
* @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
* @param string $plainMetaInfo Meta info that is used in the plain text email
* @param string|bool $plainMetaInfo Meta info that is used in the plain text email
* 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 = '', $plainText = '', $plainMetaInfo = '') {
$this->ensureBodyListOpened();

if ($plainText === '') {
Expand Down Expand Up @@ -513,12 +514,12 @@ protected function ensureBodyListClosed() {
* @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;
}
Expand Down Expand Up @@ -554,7 +555,7 @@ public function addBodyButtonGroup($textLeft,
*
* @since 12.0.0
*/
public function addBodyButton($text, $url, $plainText = '') {
public function addBodyButton(string $text, string $url, $plainText = '') {
if ($this->footerAdded) {
return;
}
Expand Down Expand Up @@ -598,7 +599,7 @@ protected function ensureBodyIsClosed() {
*
* @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.');
}
Expand All @@ -621,7 +622,7 @@ public function addFooter($text = '') {
*
* @return string
*/
public function renderSubject() {
public function renderSubject(): string {
return $this->subject;
}

Expand All @@ -630,7 +631,7 @@ public function renderSubject() {
*
* @return string
*/
public function renderHtml() {
public function renderHtml(): string {
if (!$this->footerAdded) {
$this->footerAdded = true;
$this->ensureBodyIsClosed();
Expand All @@ -644,7 +645,7 @@ public function renderHtml() {
*
* @return string
*/
public function renderText() {
public function renderText(): string {
if (!$this->footerAdded) {
$this->footerAdded = true;
$this->ensureBodyIsClosed();
Expand Down
21 changes: 11 additions & 10 deletions lib/private/Mail/Mailer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
Expand Down Expand Up @@ -91,7 +92,7 @@ public function __construct(IConfig $config,
*
* @return IMessage
*/
public function createMessage() {
public function createMessage(): IMessage {
return new Message(new \Swift_Message());
}

Expand All @@ -102,7 +103,7 @@ public function createMessage() {
* @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));
}

Expand All @@ -112,7 +113,7 @@ public function createAttachment($data = null, $filename = null, $contentType =
* @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));
}

Expand All @@ -124,7 +125,7 @@ public function createAttachmentFromPath($path, $contentType = null) {
* @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)) {
Expand Down Expand Up @@ -156,7 +157,7 @@ public function createEMailTemplate($emailId, array $data = []) {
* @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())) {
Expand Down Expand Up @@ -191,7 +192,7 @@ public function send(IMessage $message) {
* @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));
}

Expand All @@ -203,7 +204,7 @@ public function validateMailAddress($email) {
* @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;
}
Expand Down Expand Up @@ -246,7 +247,7 @@ protected function getInstance() {
*
* @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'));
Expand All @@ -269,7 +270,7 @@ protected function getSmtpInstance() {
*
* @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';
Expand All @@ -287,7 +288,7 @@ protected function getSendMailInstance() {
*
* @return \Swift_MailTransport
*/
protected function getMailInstance() {
protected function getMailInstance(): \Swift_MailTransport {
return \Swift_MailTransport::newInstance();
}

Expand Down
Loading