docs: Avoid some scalar juggling

Phan can treat scalar types as non-interchangeable with
`scalar_implicit_cast` set to false. This patch fixes some of those
issues (which are in total >1000), namely the ones with alphabetic order
< includes/actions.

Change-Id: Ib1c6573ab899088bc319b9da9ceaffc850da3dbe
This commit is contained in:
Daimona Eaytoy 2019-09-15 16:40:42 +02:00 committed by Umherirrender
parent b138a9b228
commit e5444ea55a
14 changed files with 28 additions and 28 deletions

View file

@ -55,7 +55,7 @@ class AjaxResponse {
/**
* HTTP response code
* @var string $mResponseCode
* @var int|string $mResponseCode
*/
private $mResponseCode;
@ -114,7 +114,7 @@ class AjaxResponse {
/**
* Set the HTTP response code
* @param string $code
* @param int|string $code
*/
function setResponseCode( $code ) {
$this->mResponseCode = $code;

View file

@ -187,10 +187,10 @@ class Autopromote {
}
return $user->getEditCount() >= $reqEditCount;
case APCOND_AGE:
$age = time() - wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
$age = time() - (int)wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
return $age >= $cond[1];
case APCOND_AGE_FROM_EDIT:
$age = time() - wfTimestampOrNull( TS_UNIX, $user->getFirstEditTimestamp() );
$age = time() - (int)wfTimestampOrNull( TS_UNIX, $user->getFirstEditTimestamp() );
return $age >= $cond[1];
case APCOND_INGROUPS:
$groups = array_slice( $cond, 1 );

View file

@ -1188,7 +1188,7 @@ class EditPage {
/**
* @param Content|null $def_content The default value to return
*
* @return Content|null Content on success, $def_content for invalid sections
* @return Content|false|null Content on success, $def_content for invalid sections
*
* @since 1.21
*/

View file

@ -2031,7 +2031,7 @@ function wfRecursiveRemoveDir( $dir ) {
*/
function wfPercent( $nr, $acc = 2, $round = true ) {
$ret = sprintf( "%.${acc}f", $nr );
return $round ? round( $ret, $acc ) . '%' : "$ret%";
return $round ? round( (float)$ret, $acc ) . '%' : "$ret%";
}
/**
@ -2794,7 +2794,7 @@ function wfMemoryLimit( $newLimit ) {
function wfTransactionalTimeLimit() {
global $wgTransactionalTimeLimit;
$timeLimit = ini_get( 'max_execution_time' );
$timeLimit = (int)ini_get( 'max_execution_time' );
// Note that CLI scripts use 0
if ( $timeLimit > 0 && $wgTransactionalTimeLimit > $timeLimit ) {
set_time_limit( $wgTransactionalTimeLimit );

View file

@ -891,7 +891,7 @@ class Linker {
* Make user link (or user contributions for unregistered users)
* @param int $userId User id in database.
* @param string $userName User name in database.
* @param string $altUserName Text to display instead of the user name (optional)
* @param string|false $altUserName Text to display instead of the user name (optional)
* @return string HTML fragment
* @since 1.16.3. $altUserName was added in 1.19.
*/
@ -1912,7 +1912,7 @@ class Linker {
* @since 1.16.3. $context added in 1.20. $editCount added in 1.21
* @param Revision $rev
* @param IContextSource|null $context Context to use or null for the main context.
* @param int $editCount Number of edits that would be reverted
* @param int|false $editCount Number of edits that would be reverted
* @return string HTML fragment
*/
public static function buildRollbackLink( $rev, IContextSource $context = null,

View file

@ -50,7 +50,7 @@ class OutputPage extends ContextSource {
/** @var array */
protected $mLinktags = [];
/** @var bool */
/** @var string|bool */
protected $mCanonicalUrl = false;
/**
@ -2147,7 +2147,7 @@ class OutputPage extends ContextSource {
}
/**
* Get TTL in [$minTTL,$maxTTL] in pass it to lowerCdnMaxage()
* Get TTL in [$minTTL,$maxTTL] and pass it to lowerCdnMaxage()
*
* This sets and returns $minTTL if $mtime is false or null. Otherwise,
* the TTL is higher the older the $mtime timestamp is. Essentially, the
@ -2163,10 +2163,10 @@ class OutputPage extends ContextSource {
$maxTTL = $maxTTL ?: $this->getConfig()->get( 'CdnMaxAge' );
if ( $mtime === null || $mtime === false ) {
return $minTTL; // entity does not exist
return; // entity does not exist
}
$age = MWTimestamp::time() - wfTimestamp( TS_UNIX, $mtime );
$age = MWTimestamp::time() - (int)wfTimestamp( TS_UNIX, $mtime );
$adaptiveTTL = max( 0.9 * $age, $minTTL );
$adaptiveTTL = min( $adaptiveTTL, $maxTTL );
@ -2270,7 +2270,7 @@ class OutputPage extends ContextSource {
/**
* Return a Link: header. Based on the values of $mLinkHeader.
*
* @return string
* @return string|false
*/
public function getLinkHeader() {
if ( !$this->mLinkHeader ) {
@ -2602,7 +2602,7 @@ class OutputPage extends ContextSource {
* and optionally an custom HTML title (content of the "<title>" tag).
*
* @param string|Message $pageTitle Will be passed directly to setPageTitle()
* @param string|Message $htmlTitle Will be passed directly to setHTMLTitle();
* @param string|Message|false $htmlTitle Will be passed directly to setHTMLTitle();
* optional, if not passed the "<title>" attribute will be
* based on $pageTitle
*/
@ -3283,7 +3283,7 @@ class OutputPage extends ContextSource {
$vars['wgUserId'] = $user->getId();
$vars['wgUserEditCount'] = $user->getEditCount();
$userReg = $user->getRegistration();
$vars['wgUserRegistration'] = $userReg ? wfTimestamp( TS_UNIX, $userReg ) * 1000 : null;
$vars['wgUserRegistration'] = $userReg ? (int)wfTimestamp( TS_UNIX, $userReg ) * 1000 : null;
// Get the revision ID of the oldest new message on the user's talk
// page. This can be used for constructing new message alerts on
// the client side.

View file

@ -77,8 +77,8 @@ class PHPVersionCheck {
/**
* Return the version of the installed PHP implementation.
*
* @param string $impl By default, the function returns the info of the currently installed PHP
* implementation. Using this parameter the caller can decide, what version info will be
* @param string|false $impl By default, the function returns the info of the currently installed
* PHP implementation. Using this parameter the caller can decide, what version info will be
* returned. Valid values: HHVM, PHP
* @return array An array of information about the PHP implementation, containing:
* - 'version': The version of the PHP implementation (specific to the implementation, not

View file

@ -97,7 +97,7 @@ class PermissionManager {
*/
private $temporaryUserRights = [];
/** @var string[] Cached rights for isEveryoneAllowed */
/** @var bool[] Cached rights for isEveryoneAllowed, [ right => allowed ] */
private $cachedRights = [];
/**

View file

@ -59,7 +59,7 @@ abstract class RevisionRecord {
const FOR_THIS_USER = 2;
const RAW = 3;
/** @var string Wiki ID; false means the current wiki */
/** @var string|false Wiki ID; false means the current wiki */
protected $mWiki = false;
/** @var int|null */
protected $mId;

View file

@ -151,7 +151,7 @@ class RevisionStoreRecord extends RevisionRecord {
/**
* @throws RevisionAccessException if the size was unknown and could not be calculated.
* @return string The nominal revision size, never null. May be computed on the fly.
* @return int The nominal revision size, never null. May be computed on the fly.
*/
public function getSize() {
// If length is null, calculate and remember it (potentially SLOW!).

View file

@ -150,7 +150,7 @@ class SlotRoleHandler {
*
* The default implementation always returns false.
*
* @return string
* @return bool
*/
public function supportsArticleCount() {
return false;

View file

@ -728,7 +728,7 @@ if ( is_null( $wgLocaltimezone ) ) {
date_default_timezone_set( $wgLocaltimezone );
if ( is_null( $wgLocalTZoffset ) ) {
$wgLocalTZoffset = date( 'Z' ) / 60;
$wgLocalTZoffset = (int)date( 'Z' ) / 60;
}
// The part after the System| is ignored, but rest of MW fills it
// out as the local offset.

View file

@ -231,7 +231,7 @@ class PageEditStash {
return false;
}
$age = time() - wfTimestamp( TS_UNIX, $editInfo->output->getCacheTime() );
$age = time() - (int)wfTimestamp( TS_UNIX, $editInfo->output->getCacheTime() );
$context['age'] = $age;
$isCacheUsable = true;
@ -450,7 +450,7 @@ class PageEditStash {
) {
// If an item is renewed, mind the cache TTL determined by config and parser functions.
// Put an upper limit on the TTL for sanity to avoid extreme template/file staleness.
$age = time() - wfTimestamp( TS_UNIX, $parserOutput->getCacheTime() );
$age = time() - (int)wfTimestamp( TS_UNIX, $parserOutput->getCacheTime() );
$ttl = min( $parserOutput->getCacheExpiry() - $age, self::MAX_CACHE_TTL );
// Avoid extremely stale user signature timestamps (T84843)
if ( $parserOutput->getFlag( 'user-signature' ) ) {

View file

@ -266,7 +266,7 @@ class Xml {
/**
* Convenience function to build an HTML text input field
* @param string $name Value of the name attribute
* @param int $size Value of the size attribute
* @param int|false $size Value of the size attribute
* @param mixed $value Value of the value attribute
* @param array $attribs Other attributes
* @return string HTML
@ -289,7 +289,7 @@ class Xml {
/**
* Convenience function to build an HTML password input field
* @param string $name Value of the name attribute
* @param int $size Value of the size attribute
* @param int|false $size Value of the size attribute
* @param mixed $value Value of the value attribute
* @param array $attribs Other attributes
* @return string HTML
@ -600,7 +600,7 @@ class Xml {
*
* @param string|bool $legend Legend of the fieldset. If evaluates to false,
* legend is not added.
* @param string $content Pre-escaped content for the fieldset. If false,
* @param string|false $content Pre-escaped content for the fieldset. If false,
* only open fieldset is returned.
* @param array $attribs Any attributes to fieldset-element.
*