From 02a28663c1659330edc79029c2793abefd1a0ef4 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sat, 8 Oct 2022 15:07:46 +0200 Subject: [PATCH] Fixes for the phan upgrade, part 2 Change-Id: I1c6beba4ff6132b07cbf0a6c96be056509aa5eff --- includes/ProtectionForm.php | 1 + includes/language/Message.php | 2 +- includes/specials/SpecialBlock.php | 27 ++++++++++--------- includes/upload/UploadBase.php | 5 ++-- .../UploadChunkVerificationException.php | 4 +++ 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index 801db2cc37d..6b3a8026d7d 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -260,6 +260,7 @@ class ProtectionForm { * Show the input form with optional error message * * @param string|string[]|null $err Error message or null if there's no error + * @phan-param string|non-empty-array|null $err */ private function show( $err = null ) { $out = $this->mOut; diff --git a/includes/language/Message.php b/includes/language/Message.php index 88c08457d46..359f4dd3e87 100644 --- a/includes/language/Message.php +++ b/includes/language/Message.php @@ -449,7 +449,7 @@ class Message implements MessageSpecifier, Serializable { * * @param string|string[] ...$keys Message keys, or first argument as an array of all the * message keys. - * @param-taint $keys tainted + * @param-taint ...$keys tainted * * @return Message */ diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index a4befd3175e..e2094d4b51c 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -86,7 +86,10 @@ class SpecialBlock extends FormSpecialPage { /** @var bool */ protected $alreadyBlocked; - /** @var array */ + /** + * @var array[] + * @phan-var non-empty-array[] + */ protected $preErrors = []; /** @var NamespaceInfo */ @@ -192,18 +195,16 @@ class SpecialBlock extends FormSpecialPage { # Don't need to do anything if the form has been posted if ( !$this->getRequest()->wasPosted() && $this->preErrors ) { - if ( $this->preErrors ) { - # Mimic error messages normally generated by the form - $form->addHeaderText( (string)new OOUI\FieldLayout( - new OOUI\Widget( [] ), - [ - 'align' => 'top', - 'errors' => array_map( function ( $errMsg ) { - return new OOUI\HtmlSnippet( $this->msg( ...$errMsg )->parse() ); - }, $this->preErrors ), - ] - ) ); - } + # Mimic error messages normally generated by the form + $form->addHeaderText( (string)new OOUI\FieldLayout( + new OOUI\Widget( [] ), + [ + 'align' => 'top', + 'errors' => array_map( function ( $errMsg ) { + return new OOUI\HtmlSnippet( $this->msg( ...$errMsg )->parse() ); + }, $this->preErrors ), + ] + ) ); } } diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 435e2b29fbb..c802fd1de36 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -483,7 +483,7 @@ abstract class UploadBase { /** * Verifies that it's ok to include the uploaded file * - * @return array|bool True of the file is verified, array otherwise. + * @return array|true True of the file is verified, array otherwise. */ protected function verifyFile() { $config = MediaWikiServices::getInstance()->getMainConfig(); @@ -547,7 +547,8 @@ abstract class UploadBase { * Runs the blacklist checks, but not any checks that may * assume the entire file is present. * - * @return array|bool True if the file is valid, else an array with error message key. + * @return array|true True if the file is valid, else an array with error message key. + * @phan-return non-empty-array|true */ protected function verifyPartialFile() { $config = MediaWikiServices::getInstance()->getMainConfig(); diff --git a/includes/upload/exception/UploadChunkVerificationException.php b/includes/upload/exception/UploadChunkVerificationException.php index c1e5001b10e..8fb9f8d4c79 100644 --- a/includes/upload/exception/UploadChunkVerificationException.php +++ b/includes/upload/exception/UploadChunkVerificationException.php @@ -27,6 +27,10 @@ class UploadChunkVerificationException extends MWException { public $msg; + /** + * @param array $res + * @phan-param non-empty-array $res + */ public function __construct( array $res ) { $this->msg = wfMessage( ...$res ); parent::__construct( wfMessage( ...$res )