Mail: Add visibility for some methods without method visibility
authorDerick Alangi <alangiderick@gmail.com>
Wed, 26 Jun 2019 10:11:33 +0000 (11:11 +0100)
committerD3r1ck01 <xsavitar.wiki@aol.com>
Sun, 30 Jun 2019 15:32:20 +0000 (15:32 +0000)
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
includes/mail/MailAddress.php
includes/mail/UserMailer.php

index 0b77651..7361032 100644 (file)
@@ -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;
                }
index 63a114d..1a5d08a 100644 (file)
@@ -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();
        }
 }
index 5d7030b..47fa16f 100644 (file)
@@ -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 );
        }