From dd3b9a3343857be352bdd889541b477fd4392609 Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Thu, 30 Jun 2016 17:08:44 -0700 Subject: [PATCH] Fix a few incorrect annotations Found by applying etsy/phan to the mediawiki codebase, in preparation for getting it running more regularly via CI. Has no effect on how the code runs, simply does a better job of documenting the code. Change-Id: I4c844a51df3ffe4fbb96cac25f3eff2f7a9faca2 --- includes/api/ApiMain.php | 4 +++- includes/content/AbstractContent.php | 2 +- includes/db/DatabaseOracle.php | 16 ++++++++++++++-- includes/db/DatabasePostgres.php | 5 +++++ includes/filerepo/FileRepo.php | 5 ++--- includes/jobqueue/jobs/DoubleRedirectJob.php | 3 ++- includes/specialpage/ChangesListSpecialPage.php | 2 +- includes/specials/SpecialRandomInCategory.php | 5 +++++ includes/specials/SpecialRecentchanges.php | 2 +- maintenance/dumpTextPass.php | 3 +++ maintenance/preprocessorFuzzTest.php | 3 +++ 11 files changed, 40 insertions(+), 10 deletions(-) diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index a9541d3f10..278341d76d 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -138,7 +138,9 @@ class ApiMain extends ApiBase { */ private $mPrinter; - private $mModuleMgr, $mResult, $mErrorFormatter, $mContinuationManager; + private $mModuleMgr, $mResult, $mErrorFormatter; + /** @var ApiContinuationManager|null */ + private $mContinuationManager; private $mAction; private $mEnableWrite; private $mInternalMode, $mSquidMaxage; diff --git a/includes/content/AbstractContent.php b/includes/content/AbstractContent.php index e7446550bb..811b241798 100644 --- a/includes/content/AbstractContent.php +++ b/includes/content/AbstractContent.php @@ -281,7 +281,7 @@ abstract class AbstractContent implements Content { * * @since 1.21 * - * @return null + * @return Title|null * * @see Content::getRedirectTarget */ diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php index 9e53653a76..f9ba0507d4 100644 --- a/includes/db/DatabaseOracle.php +++ b/includes/db/DatabaseOracle.php @@ -432,7 +432,7 @@ class DatabaseOracle extends Database { /** * Frees resources associated with the LOB descriptor - * @param ResultWrapper|resource $res + * @param ResultWrapper|ORAResult $res */ function freeResult( $res ) { if ( $res instanceof ResultWrapper ) { @@ -443,7 +443,7 @@ class DatabaseOracle extends Database { } /** - * @param ResultWrapper|stdClass $res + * @param ResultWrapper|ORAResult $res * @return mixed */ function fetchObject( $res ) { @@ -454,6 +454,10 @@ class DatabaseOracle extends Database { return $res->fetchObject(); } + /** + * @param ResultWrapper|ORAResult $res + * @return mixed + */ function fetchRow( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -462,6 +466,10 @@ class DatabaseOracle extends Database { return $res->fetchRow(); } + /** + * @param ResultWrapper|ORAResult $res + * @return int + */ function numRows( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; @@ -470,6 +478,10 @@ class DatabaseOracle extends Database { return $res->numRows(); } + /** + * @param ResultWrapper|ORAResult $res + * @return int + */ function numFields( $res ) { if ( $res instanceof ResultWrapper ) { $res = $res->result; diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 839d6a0ec2..c9127ff599 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -1383,6 +1383,11 @@ SQL; return (bool)$exists; } + /** + * @var string $table + * @var string $field + * @return PostgresField|null + */ function fieldInfo( $table, $field ) { return PostgresField::fromText( $this, $table, $field ); } diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 9ad24283c9..d7559d057b 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -533,11 +533,10 @@ class FileRepo { public function findFileFromKey( $sha1, $options = [] ) { $time = isset( $options['time'] ) ? $options['time'] : false; # First try to find a matching current version of a file... - if ( $this->fileFactoryKey ) { - $img = call_user_func( $this->fileFactoryKey, $sha1, $this, $time ); - } else { + if ( !$this->fileFactoryKey ) { return false; // find-by-sha1 not supported } + $img = call_user_func( $this->fileFactoryKey, $sha1, $this, $time ); if ( $img && $img->exists() ) { return $img; } diff --git a/includes/jobqueue/jobs/DoubleRedirectJob.php b/includes/jobqueue/jobs/DoubleRedirectJob.php index c6d8ec5920..3cd3448f54 100644 --- a/includes/jobqueue/jobs/DoubleRedirectJob.php +++ b/includes/jobqueue/jobs/DoubleRedirectJob.php @@ -179,7 +179,8 @@ class DoubleRedirectJob extends Job { * * @param Title $title * - * @return bool If the specified title is not a redirect, or if it is a circular redirect + * @return Title|bool The final Title after following all redirects, or false if + * the page is not a redirect or the redirect loops. */ public static function getFinalDestination( $title ) { $dbw = wfGetDB( DB_MASTER ); diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 0bd2932bc4..6c061b35e0 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -368,7 +368,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { /** * Build and output the actual changes list. * - * @param array $rows Database rows + * @param ResultWrapper $rows Database rows * @param FormOptions $opts */ abstract public function outputChangesList( $rows, $opts ); diff --git a/includes/specials/SpecialRandomInCategory.php b/includes/specials/SpecialRandomInCategory.php index efb1748913..a5e538f161 100644 --- a/includes/specials/SpecialRandomInCategory.php +++ b/includes/specials/SpecialRandomInCategory.php @@ -47,10 +47,15 @@ * @ingroup SpecialPage */ class SpecialRandomInCategory extends FormSpecialPage { + /** @var string[] */ protected $extra = []; // Extra SQL statements + /** @var Title|false */ protected $category = false; // Title object of category + /** @var int */ protected $maxOffset = 30; // Max amount to fudge randomness by. + /** @var int|null */ private $maxTimestamp = null; + /** @var int|null */ private $minTimestamp = null; public function __construct( $name = 'RandomInCategory' ) { diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 4d6cb7c9d4..d4fb72ca98 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -310,7 +310,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { /** * Build and output the actual changes list. * - * @param array $rows Database rows + * @param ResultWrapper $rows Database rows * @param FormOptions $opts */ public function outputChangesList( $rows, $opts ) { diff --git a/maintenance/dumpTextPass.php b/maintenance/dumpTextPass.php index 6d5a0e9d27..cfb59c6004 100644 --- a/maintenance/dumpTextPass.php +++ b/maintenance/dumpTextPass.php @@ -74,6 +74,9 @@ class TextPassDumper extends BackupDumper { */ protected $spawnErr = false; + /** + * @var bool|XmlDumpWriter + */ protected $xmlwriterobj = false; protected $timeExceeded = false; diff --git a/maintenance/preprocessorFuzzTest.php b/maintenance/preprocessorFuzzTest.php index aa5d69d95d..d102e08c2d 100644 --- a/maintenance/preprocessorFuzzTest.php +++ b/maintenance/preprocessorFuzzTest.php @@ -47,6 +47,9 @@ class PPFuzzTester { public $entryPoints = [ 'testSrvus', 'testPst', 'testPreprocess' ]; public $verbose = false; + /** + * @var bool|PPFuzzTest + */ private static $currentTest = false; function execute() { -- 2.20.1