Update formatting of includes/upload/
[lhc/web/wiklou.git] / includes / upload / UploadFromUrl.php
index 19b4dfd..b605640 100644 (file)
@@ -41,7 +41,7 @@ class UploadFromUrl extends UploadBase {
         * user is not allowed, return the name of the user right as a string. If
         * the user is allowed, have the parent do further permissions checking.
         *
-        * @param $user User
+        * @param User $user
         *
         * @return bool|string
         */
@@ -49,6 +49,7 @@ class UploadFromUrl extends UploadBase {
                if ( !$user->isAllowed( 'upload_by_url' ) ) {
                        return 'upload_by_url';
                }
+
                return parent::isAllowed( $user );
        }
 
@@ -58,6 +59,7 @@ class UploadFromUrl extends UploadBase {
         */
        public static function isEnabled() {
                global $wgAllowCopyUploads;
+
                return $wgAllowCopyUploads && parent::isEnabled();
        }
 
@@ -66,7 +68,7 @@ class UploadFromUrl extends UploadBase {
         * The domains in the whitelist can include wildcard characters (*) in place
         * of any of the domain levels, e.g. '*.flickr.com' or 'upload.*.gov.uk'.
         *
-        * @param $url string
+        * @param string $url
         * @return bool
         */
        public static function isAllowedHost( $url ) {
@@ -103,13 +105,14 @@ class UploadFromUrl extends UploadBase {
                        }
                        */
                }
+
                return $valid;
        }
 
        /**
         * Checks whether the URL is not allowed.
         *
-        * @param $url string
+        * @param string $url
         * @return bool
         */
        public static function isAllowedUrl( $url ) {
@@ -118,15 +121,16 @@ class UploadFromUrl extends UploadBase {
                        wfRunHooks( 'IsUploadAllowedFromUrl', array( $url, &$allowed ) );
                        self::$allowedUrls[$url] = $allowed;
                }
+
                return self::$allowedUrls[$url];
        }
 
        /**
         * Entry point for API upload
         *
-        * @param $name string
-        * @param $url string
-        * @param $async mixed Whether the download should be performed
+        * @param string $name
+        * @param string $url
+        * @param bool|string $async Whether the download should be performed
         * asynchronous. False for synchronous, async or async-leavemessage for
         * asynchronous download.
         * @throws MWException
@@ -147,7 +151,7 @@ class UploadFromUrl extends UploadBase {
 
        /**
         * Entry point for SpecialUpload
-        * @param $request WebRequest object
+        * @param WebRequest $request
         */
        public function initializeFromRequest( &$request ) {
                $desiredDestName = $request->getText( 'wpDestFile' );
@@ -162,13 +166,14 @@ class UploadFromUrl extends UploadBase {
        }
 
        /**
-        * @param $request WebRequest object
+        * @param WebRequest $request
         * @return bool
         */
        public static function isValidRequest( $request ) {
                global $wgUser;
 
                $url = $request->getVal( 'wpUploadFileURL' );
+
                return !empty( $url )
                        && Http::isValidURI( $url )
                        && $wgUser->isAllowed( 'upload_by_url' );
@@ -184,7 +189,7 @@ class UploadFromUrl extends UploadBase {
        /**
         * Download the file (if not async)
         *
-        * @param Array $httpOptions Array of options for MWHttpRequest. Ignored if async.
+        * @param array $httpOptions Array of options for MWHttpRequest. Ignored if async.
         *   This could be used to override the timeout on the http request.
         * @return Status
         */
@@ -202,6 +207,7 @@ class UploadFromUrl extends UploadBase {
                if ( !$this->mAsync ) {
                        return $this->reallyFetchFile( $httpOptions );
                }
+
                return Status::newGood();
        }
 
@@ -213,15 +219,16 @@ class UploadFromUrl extends UploadBase {
        protected function makeTemporaryFile() {
                $tmpFile = TempFSFile::factory( 'URL' );
                $tmpFile->bind( $this );
+
                return $tmpFile->getPath();
        }
 
        /**
         * Callback: save a chunk of the result of a HTTP request to the temporary file
         *
-        * @param $req mixed
-        * @param $buffer string
-        * @return int number of bytes handled
+        * @param mixed $req
+        * @param string $buffer
+        * @return int Number of bytes handled
         */
        public function saveTempFileChunk( $req, $buffer ) {
                $nbytes = fwrite( $this->mTmpHandle, $buffer );
@@ -241,7 +248,7 @@ class UploadFromUrl extends UploadBase {
         * Download the file, save it to the temporary file and update the file
         * size and set $mRemoveTempFile to true.
         *
-        * @param Array $httpOptions Array of options for MWHttpRequest
+        * @param array $httpOptions Array of options for MWHttpRequest
         * @return Status
         */
        protected function reallyFetchFile( $httpOptions = array() ) {
@@ -259,12 +266,12 @@ class UploadFromUrl extends UploadBase {
                $this->mRemoveTempFile = true;
                $this->mFileSize = 0;
 
-               $options = $httpOptions + array(
-                       'followRedirects' => true,
-               );
+               $options = $httpOptions + array( 'followRedirects' => true );
+
                if ( $wgCopyUploadProxy !== false ) {
                        $options['proxy'] = $wgCopyUploadProxy;
                }
+
                if ( $wgCopyUploadTimeout && !isset( $options['timeout'] ) ) {
                        $options['timeout'] = $wgCopyUploadTimeout;
                }
@@ -297,42 +304,46 @@ class UploadFromUrl extends UploadBase {
                if ( $this->mAsync ) {
                        return array( 'status' => UploadBase::OK );
                }
+
                return parent::verifyUpload();
        }
 
        /**
         * Wrapper around the parent function in order to defer checking warnings
         * until the file really has been fetched.
-        * @return Array
+        * @return array
         */
        public function checkWarnings() {
                if ( $this->mAsync ) {
                        $this->mIgnoreWarnings = false;
+
                        return array();
                }
+
                return parent::checkWarnings();
        }
 
        /**
         * Wrapper around the parent function in order to defer checking protection
         * until we are sure that the file can actually be uploaded
-        * @param $user User
+        * @param User $user
         * @return bool|mixed
         */
        public function verifyTitlePermissions( $user ) {
                if ( $this->mAsync ) {
                        return true;
                }
+
                return parent::verifyTitlePermissions( $user );
        }
 
        /**
         * Wrapper around the parent function in order to defer uploading to the
         * job queue for asynchronous uploads
-        * @param $comment string
-        * @param $pageText string
-        * @param $watch bool
-        * @param $user User
+        * @param string $comment
+        * @param string $pageText
+        * @param bool $watch
+        * @param User $user
         * @return Status
         */
        public function performUpload( $comment, $pageText, $watch, $user ) {
@@ -346,11 +357,11 @@ class UploadFromUrl extends UploadBase {
        }
 
        /**
-        * @param $comment
-        * @param $pageText
-        * @param $watch
-        * @param $user User
-        * @return String
+        * @param string $comment
+        * @param string $pageText
+        * @param bool $watch
+        * @param User $user
+        * @return string
         */
        protected function insertJob( $comment, $pageText, $watch, $user ) {
                $sessionKey = $this->stashSession();
@@ -367,7 +378,7 @@ class UploadFromUrl extends UploadBase {
                ) );
                $job->initializeSessionData();
                JobQueueGroup::singleton()->push( $job );
+
                return $sessionKey;
        }
-
 }