Merge "Function type hints for LinkHolderArray.php"
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index 521b361..01c0aaf 100644 (file)
@@ -32,44 +32,52 @@ class SpecialUpload extends SpecialPage {
        /**
         * Constructor : initialise object
         * Get data POSTed through the form and assign them to the object
-        * @param $request WebRequest : data posted.
+        * @param WebRequest $request Data posted.
         */
        public function __construct( $request = null ) {
                parent::__construct( 'Upload', 'upload' );
        }
 
        /** Misc variables **/
-       public $mRequest; // The WebRequest or FauxRequest this form is supposed to handle
+
+       /** @var WebRequest|FauxRequest The request this form is supposed to handle */
+       public $mRequest;
        public $mSourceType;
 
-       /**
-        * @var UploadBase
-        */
+       /** @var UploadBase */
        public $mUpload;
 
-       /**
-        * @var LocalFile
-        */
+       /** @var LocalFile */
        public $mLocalFile;
        public $mUploadClicked;
 
        /** User input variables from the "description" section **/
-       public $mDesiredDestName; // The requested target file name
+
+       /** @var string The requested target file name */
+       public $mDesiredDestName;
        public $mComment;
        public $mLicense;
 
        /** User input variables from the root section **/
+
        public $mIgnoreWarning;
        public $mWatchthis;
        public $mCopyrightStatus;
        public $mCopyrightSource;
 
        /** Hidden variables **/
+
        public $mDestWarningAck;
-       public $mForReUpload; // The user followed an "overwrite this file" link
-       public $mCancelUpload; // The user clicked "Cancel and return to upload form" button
+
+       /** @var bool The user followed an "overwrite this file" link */
+       public $mForReUpload;
+
+       /** @var bool The user clicked "Cancel and return to upload form" button */
+       public $mCancelUpload;
        public $mTokenOk;
-       public $mUploadSuccessful = false; // Subclasses can use this to determine whether a file was uploaded
+
+       /** @var bool Subclasses can use this to determine whether a file was uploaded */
+       public $mUploadSuccessful = false;
 
        /** Text injection points for hooks not using HTMLForm **/
        public $uploadFormTextTop;
@@ -125,8 +133,8 @@ class SpecialUpload extends SpecialPage {
         * Handle permission checking elsewhere in order to be able to show
         * custom error messages.
         *
-        * @param $user User object
-        * @return Boolean
+        * @param User $user
+        * @return bool
         */
        public function userCanExecute( User $user ) {
                return UploadBase::isEnabled() && parent::userCanExecute( $user );
@@ -134,6 +142,7 @@ class SpecialUpload extends SpecialPage {
 
        /**
         * Special page entry point
+        * @param string $par
         */
        public function execute( $par ) {
                $this->setHeaders();
@@ -178,7 +187,7 @@ class SpecialUpload extends SpecialPage {
                } else {
                        # Backwards compatibility hook
                        if ( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) ) {
-                               wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" );
+                               wfDebug( "Hook 'UploadForm:initial' broke output of the upload form\n" );
 
                                return;
                        }
@@ -194,7 +203,7 @@ class SpecialUpload extends SpecialPage {
        /**
         * Show the main upload form
         *
-        * @param $form Mixed: an HTMLForm instance or HTML string to show
+        * @param HTMLForm|string $form An HTMLForm instance or HTML string to show
         */
        protected function showUploadForm( $form ) {
                # Add links if file was previously deleted
@@ -213,8 +222,8 @@ class SpecialUpload extends SpecialPage {
         * Get an UploadForm instance with title and text properly set.
         *
         * @param string $message HTML string to add to the form
-        * @param string $sessionKey session key in case this is a stashed upload
-        * @param $hideIgnoreWarning Boolean: whether to hide "ignore warning" check box
+        * @param string $sessionKey Session key in case this is a stashed upload
+        * @param bool $hideIgnoreWarning Whether to hide "ignore warning" check box
         * @return UploadForm
         */
        protected function getUploadForm( $message = '', $sessionKey = '', $hideIgnoreWarning = false ) {
@@ -320,9 +329,9 @@ class SpecialUpload extends SpecialPage {
         * Stashes the upload, shows the main form, but adds a "continue anyway button".
         * Also checks whether there are actually warnings to display.
         *
-        * @param $warnings Array
-        * @return boolean true if warnings were displayed, false if there are no
-        *         warnings and it should continue processing
+        * @param array $warnings
+        * @return bool True if warnings were displayed, false if there are no
+        *   warnings and it should continue processing
         */
        protected function showUploadWarning( $warnings ) {
                # If there are no warnings, or warnings we can ignore, return early.
@@ -449,7 +458,14 @@ class SpecialUpload extends SpecialPage {
                } else {
                        $pageText = false;
                }
-               $status = $this->mUpload->performUpload( $this->mComment, $pageText, $this->mWatchthis, $this->getUser() );
+
+               $status = $this->mUpload->performUpload(
+                       $this->mComment,
+                       $pageText,
+                       $this->mWatchthis,
+                       $this->getUser()
+               );
+
                if ( !$status->isGood() ) {
                        $this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
 
@@ -464,13 +480,15 @@ class SpecialUpload extends SpecialPage {
 
        /**
         * Get the initial image page text based on a comment and optional file status information
-        * @param $comment string
-        * @param $license string
-        * @param $copyStatus string
-        * @param $source string
+        * @param string $comment
+        * @param string $license
+        * @param string $copyStatus
+        * @param string $source
         * @return string
         */
-       public static function getInitialPageText( $comment = '', $license = '', $copyStatus = '', $source = '' ) {
+       public static function getInitialPageText( $comment = '', $license = '',
+               $copyStatus = '', $source = ''
+       ) {
                global $wgUseCopyrightUpload, $wgForceUIMsgAsContentMsg;
 
                $msg = array();
@@ -518,7 +536,7 @@ class SpecialUpload extends SpecialPage {
         *
         * Note that the page target can be changed *on the form*, so our check
         * state can get out of sync.
-        * @return Bool|String
+        * @return bool|string
         */
        protected function getWatchCheck() {
                if ( $this->getUser()->getOption( 'watchdefault' ) ) {
@@ -546,7 +564,7 @@ class SpecialUpload extends SpecialPage {
        /**
         * Provides output to the user for a result of UploadBase::verifyUpload
         *
-        * @param array $details result of UploadBase::verifyUpload
+        * @param array $details Result of UploadBase::verifyUpload
         * @throws MWException
         */
        protected function processVerificationError( $details ) {
@@ -625,7 +643,7 @@ class SpecialUpload extends SpecialPage {
        /**
         * Remove a temporarily kept file stashed by saveTempUploadedFile().
         *
-        * @return Boolean: success
+        * @return bool Success
         */
        protected function unsaveUploadedFile() {
                if ( !( $this->mUpload instanceof UploadFromStash ) ) {
@@ -647,8 +665,8 @@ class SpecialUpload extends SpecialPage {
         * Formats a result of UploadBase::getExistsWarning as HTML
         * This check is static and can be done pre-upload via AJAX
         *
-        * @param array $exists the result of UploadBase::getExistsWarning
-        * @return String: empty string if there is no warning or an HTML fragment
+        * @param array $exists The result of UploadBase::getExistsWarning
+        * @return string Empty string if there is no warning or an HTML fragment
         */
        public static function getExistsWarning( $exists ) {
                if ( !$exists ) {
@@ -699,7 +717,7 @@ class SpecialUpload extends SpecialPage {
 
        /**
         * Construct a warning and a gallery from an array of duplicate files.
-        * @param $dupes array
+        * @param array $dupes
         * @return string
         */
        public function getDupeWarning( $dupes ) {
@@ -790,7 +808,7 @@ class UploadForm extends HTMLForm {
         * Get the descriptor of the fieldset that contains the file source
         * selection. The section is 'source'
         *
-        * @return Array: descriptor array
+        * @return array Descriptor array
         */
        protected function getSourceSection() {
                global $wgCopyUploadsFromSpecialUpload;
@@ -884,29 +902,38 @@ class UploadForm extends HTMLForm {
        /**
         * Get the messages indicating which extensions are preferred and prohibitted.
         *
-        * @return String: HTML string containing the message
+        * @return string HTML string containing the message
         */
        protected function getExtensionsMessage() {
                # Print a list of allowed file extensions, if so configured.  We ignore
                # MIME type here, it's incomprehensible to most people and too long.
                global $wgCheckFileExtensions, $wgStrictFileExtensions,
-                  $wgFileExtensions, $wgFileBlacklist;
+                       $wgFileExtensions, $wgFileBlacklist;
 
                if ( $wgCheckFileExtensions ) {
                        if ( $wgStrictFileExtensions ) {
                                # Everything not permitted is banned
                                $extensionsList =
                                        '<div id="mw-upload-permitted">' .
-                                       $this->msg( 'upload-permitted', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) )->parseAsBlock() .
+                                       $this->msg(
+                                               'upload-permitted',
+                                               $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) )
+                                       )->parseAsBlock() .
                                        "</div>\n";
                        } else {
                                # We have to list both preferred and prohibited
                                $extensionsList =
                                        '<div id="mw-upload-preferred">' .
-                                               $this->msg( 'upload-preferred', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) ) )->parseAsBlock() .
+                                               $this->msg(
+                                                       'upload-preferred',
+                                                       $this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions ) )
+                                               )->parseAsBlock() .
                                        "</div>\n" .
                                        '<div id="mw-upload-prohibited">' .
-                                               $this->msg( 'upload-prohibited', $this->getContext()->getLanguage()->commaList( array_unique( $wgFileBlacklist ) ) )->parseAsBlock() .
+                                               $this->msg(
+                                                       'upload-prohibited',
+                                                       $this->getContext()->getLanguage()->commaList( array_unique( $wgFileBlacklist ) )
+                                               )->parseAsBlock() .
                                        "</div>\n";
                        }
                } else {
@@ -921,7 +948,7 @@ class UploadForm extends HTMLForm {
         * Get the descriptor of the fieldset that contains the file description
         * input. The section is 'description'
         *
-        * @return Array: descriptor array
+        * @return array Descriptor array
         */
        protected function getDescriptionSection() {
                if ( $this->mSessionKey ) {
@@ -1019,7 +1046,7 @@ class UploadForm extends HTMLForm {
         * Get the descriptor of the fieldset that contains the upload options,
         * such as "watch this file". The section is 'options'
         *
-        * @return Array: descriptor array
+        * @return array Descriptor array
         */
        protected function getOptionsSection() {
                $user = $this->getUser();
@@ -1072,7 +1099,8 @@ class UploadForm extends HTMLForm {
         * Add upload JS to the OutputPage
         */
        protected function addUploadJS() {
-               global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview, $wgEnableAPI, $wgStrictFileExtensions;
+               global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview,
+                       $wgEnableAPI, $wgStrictFileExtensions;
 
                $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
                $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview && $wgEnableAPI;
@@ -1117,7 +1145,7 @@ class UploadForm extends HTMLForm {
 class UploadSourceField extends HTMLTextField {
 
        /**
-        * @param $cellAttributes array
+        * @param array $cellAttributes
         * @return string
         */
        function getLabelHtml( $cellAttributes = array() ) {