From b00852c91a3b785ee8548cab657e46476fd47c52 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Thu, 3 Jan 2019 16:15:07 +0100 Subject: [PATCH] Add @var to Pager classes Some are needed to make better results with phan in extensions For example: File CentralNoticeCampaignLogPager.php line 12: Assigning array{0:20,1:50,2:100} to property but \CentralNoticeCampaignLogPager->mLimitsShown is array{0:20,1:50,2:100,3:250,4:500} [PhanTypeMismatchProperty] With "@var int[]" the type is correct Change-Id: Ic68910bf17344852ad11fcc000a47891e4bf0179 --- includes/pager/IndexPager.php | 24 ++++++++++++++++---- includes/pager/RangeChronologicalPager.php | 1 + includes/pager/ReverseChronologicalPager.php | 4 ++++ includes/pager/TablePager.php | 2 ++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/includes/pager/IndexPager.php b/includes/pager/IndexPager.php index ce1d2d076c..b56ae37bdc 100644 --- a/includes/pager/IndexPager.php +++ b/includes/pager/IndexPager.php @@ -81,7 +81,7 @@ abstract class IndexPager extends ContextSource implements Pager { public $mLimitsShown = [ 20, 50, 100, 250, 500 ]; /** @var int The default entry limit choosen for clients */ public $mDefaultLimit = 50; - /** @var string|int The starting point to enumerate entries */ + /** @var mixed The starting point to enumerate entries */ public $mOffset; /** @var int The maximum number of entries to show */ public $mLimit; @@ -89,20 +89,23 @@ abstract class IndexPager extends ContextSource implements Pager { public $mQueryDone = false; /** @var IDatabase */ public $mDb; - /** @var stdClass|null Extra row fetched at the end to see if the end was reached */ + /** @var stdClass|bool|null Extra row fetched at the end to see if the end was reached */ public $mPastTheEndRow; /** * The index to actually be used for ordering. This is a single column, * for one ordering, even if multiple orderings are supported. + * @var string */ protected $mIndexField; /** * An array of secondary columns to order by. These fields are not part of the offset. * This is a column list for one ordering, even if multiple orderings are supported. + * @var string[] */ protected $mExtraSortFields; /** For pages that support multiple types of ordering, which one to use. + * @var string|null */ protected $mOrderType; /** @@ -115,18 +118,31 @@ abstract class IndexPager extends ContextSource implements Pager { * * Like $mIndexField, $mDefaultDirection will be a single value even if the * class supports multiple default directions for different order types. + * @var bool */ public $mDefaultDirection; + /** @var bool */ public $mIsBackwards; - /** True if the current result set is the first one */ + /** @var bool True if the current result set is the first one */ public $mIsFirst; + /** @var bool */ public $mIsLast; - protected $mLastShown, $mFirstShown, $mPastTheEndIndex, $mDefaultQuery, $mNavigationBar; + /** @var mixed */ + protected $mLastShown; + /** @var mixed */ + protected $mFirstShown; + /** @var mixed */ + protected $mPastTheEndIndex; + /** @var array */ + protected $mDefaultQuery; + /** @var string */ + protected $mNavigationBar; /** * Whether to include the offset in the query + * @var bool */ protected $mIncludeOffset = false; diff --git a/includes/pager/RangeChronologicalPager.php b/includes/pager/RangeChronologicalPager.php index bf36983530..7cbcaa91a1 100644 --- a/includes/pager/RangeChronologicalPager.php +++ b/includes/pager/RangeChronologicalPager.php @@ -26,6 +26,7 @@ use Wikimedia\Timestamp\TimestampException; */ abstract class RangeChronologicalPager extends ReverseChronologicalPager { + /** @var string[] */ protected $rangeConds = []; /** diff --git a/includes/pager/ReverseChronologicalPager.php b/includes/pager/ReverseChronologicalPager.php index 51824d2f35..e8f3f408a1 100644 --- a/includes/pager/ReverseChronologicalPager.php +++ b/includes/pager/ReverseChronologicalPager.php @@ -26,9 +26,13 @@ use Wikimedia\Timestamp\TimestampException; * @ingroup Pager */ abstract class ReverseChronologicalPager extends IndexPager { + /** @var bool */ public $mDefaultDirection = IndexPager::DIR_DESCENDING; + /** @var int */ public $mYear; + /** @var int */ public $mMonth; + /** @var int */ public $mDay; public function getNavigationBar() { diff --git a/includes/pager/TablePager.php b/includes/pager/TablePager.php index 8934fc2b79..f6445f5f78 100644 --- a/includes/pager/TablePager.php +++ b/includes/pager/TablePager.php @@ -26,8 +26,10 @@ * @ingroup Pager */ abstract class TablePager extends IndexPager { + /** @var string */ protected $mSort; + /** @var stdClass */ protected $mCurrentRow; public function __construct( IContextSource $context = null ) { -- 2.20.1