From 02bbbdfa5388959c445bb678b9a3366cc79679c0 Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Wed, 26 Jun 2019 11:11:33 +0100 Subject: [PATCH] Mail: Add visibility for some methods without method visibility Carefully, I checked usage of these methods in our code bases and added the best possible visibilities to them. Not sure if I missed something but let me know if I did. Used private & public where suitable for the various methods. As for __toString(), this is a magic method, so should be public per PHP docs. Change-Id: Ie0987f4a984cac2f5eb1d9e21a305ad9467a8eb2 --- includes/mail/EmailNotification.php | 9 ++++----- includes/mail/MailAddress.php | 4 ++-- includes/mail/UserMailer.php | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/includes/mail/EmailNotification.php b/includes/mail/EmailNotification.php index 0b77651bda..7361032937 100644 --- a/includes/mail/EmailNotification.php +++ b/includes/mail/EmailNotification.php @@ -407,7 +407,7 @@ class EmailNotification { * @param User $user * @param string $source */ - function compose( $user, $source ) { + private function compose( $user, $source ) { global $wgEnotifImpersonal; if ( !$this->composed_common ) { @@ -424,7 +424,7 @@ class EmailNotification { /** * Send any queued mails */ - function sendMails() { + private function sendMails() { global $wgEnotifImpersonal; if ( $wgEnotifImpersonal ) { $this->sendImpersonal( $this->mailTargets ); @@ -440,9 +440,8 @@ class EmailNotification { * @param User $watchingUser * @param string $source * @return Status - * @private */ - function sendPersonalised( $watchingUser, $source ) { + private function sendPersonalised( $watchingUser, $source ) { global $wgEnotifUseRealName; // From the PHP manual: // Note: The to parameter cannot be an address in the form of @@ -481,7 +480,7 @@ class EmailNotification { * @param MailAddress[] $addresses * @return Status|null */ - function sendImpersonal( $addresses ) { + private function sendImpersonal( $addresses ) { if ( empty( $addresses ) ) { return null; } diff --git a/includes/mail/MailAddress.php b/includes/mail/MailAddress.php index 63a114d2a9..1a5d08ac2a 100644 --- a/includes/mail/MailAddress.php +++ b/includes/mail/MailAddress.php @@ -71,7 +71,7 @@ class MailAddress { * Return formatted and quoted address to insert into SMTP headers * @return string */ - function toString() { + public function toString() { if ( !$this->address ) { return ''; } @@ -94,7 +94,7 @@ class MailAddress { return "$quoted <{$this->address}>"; } - function __toString() { + public function __toString() { return $this->toString(); } } diff --git a/includes/mail/UserMailer.php b/includes/mail/UserMailer.php index 5d7030bb62..47fa16f87f 100644 --- a/includes/mail/UserMailer.php +++ b/includes/mail/UserMailer.php @@ -64,7 +64,7 @@ class UserMailer { * * @return string */ - static function arrayToHeaderString( $headers, $endl = PHP_EOL ) { + private static function arrayToHeaderString( $headers, $endl = PHP_EOL ) { $strings = []; foreach ( $headers as $name => $value ) { // Prevent header injection by stripping newlines from value @@ -79,7 +79,7 @@ class UserMailer { * * @return string */ - static function makeMsgId() { + private static function makeMsgId() { global $wgSMTP, $wgServer; $domainId = WikiMap::getCurrentWikiDbDomain()->getId(); @@ -465,7 +465,7 @@ class UserMailer { * @param int $code Error number * @param string $string Error message */ - static function errorHandler( $code, $string ) { + private static function errorHandler( $code, $string ) { self::$mErrorString = preg_replace( '/^mail\(\)(\s*\[.*?\])?: /', '', $string ); } -- 2.20.1