/**
* HTTP response code
- * @var string $mResponseCode
+ * @var int|string $mResponseCode
*/
private $mResponseCode;
/**
* Set the HTTP response code
- * @param string $code
+ * @param int|string $code
*/
function setResponseCode( $code ) {
$this->mResponseCode = $code;
}
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 );
/**
* @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
*/
*/
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%";
}
/**
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 );
* 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.
*/
* @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,
/** @var array */
protected $mLinktags = [];
- /** @var bool */
+ /** @var string|bool */
protected $mCanonicalUrl = false;
/**
}
/**
- * 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
$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 );
/**
* Return a Link: header. Based on the values of $mLinkHeader.
*
- * @return string
+ * @return string|false
*/
public function getLinkHeader() {
if ( !$this->mLinkHeader ) {
* 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
*/
$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.
/**
* 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
*/
private $temporaryUserRights = [];
- /** @var string[] Cached rights for isEveryoneAllowed */
+ /** @var bool[] Cached rights for isEveryoneAllowed, [ right => allowed ] */
private $cachedRights = [];
/**
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;
/**
* @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!).
*
* The default implementation always returns false.
*
- * @return string
+ * @return bool
*/
public function supportsArticleCount() {
return false;
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.
return false;
}
- $age = time() - wfTimestamp( TS_UNIX, $editInfo->output->getCacheTime() );
+ $age = time() - (int)wfTimestamp( TS_UNIX, $editInfo->output->getCacheTime() );
$context['age'] = $age;
$isCacheUsable = true;
) {
// 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' ) ) {
/**
* 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
/**
* 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
*
* @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.
*