Add explicit casts between scalar types
* Some functions accept only string, cast ints and floats to string * After preg_matches or explode() casts numbers to int to do maths * Cast unix timestamps to int to do maths * Cast return values from timestamp format function to int * Cast bitwise operator to bool when needed as bool * php internal functions like floor/round/ceil documented to return float, most cases the result is used as int, added casts Found by phan strict checks Change-Id: Icb2de32107f43817acc45fe296fb77acf65c1786
This commit is contained in:
parent
b042d65776
commit
9efd9ca45e
49 changed files with 76 additions and 76 deletions
|
|
@ -440,7 +440,7 @@ class CommentParser {
|
|||
*/
|
||||
private function addLinkMarker( $callback ) {
|
||||
$nextId = count( $this->links );
|
||||
if ( strlen( $nextId ) > self::MAX_ID_SIZE ) {
|
||||
if ( strlen( (string)$nextId ) > self::MAX_ID_SIZE ) {
|
||||
throw new \RuntimeException( 'Too many links in comment batch' );
|
||||
}
|
||||
$this->links[] = $callback;
|
||||
|
|
|
|||
|
|
@ -2356,7 +2356,7 @@ function wfMemoryLimit( $newLimit ) {
|
|||
$oldLimit = wfShorthandToInteger( ini_get( 'memory_limit' ) );
|
||||
// If the INI config is already unlimited, there is nothing larger
|
||||
if ( $oldLimit != -1 ) {
|
||||
$newLimit = wfShorthandToInteger( $newLimit );
|
||||
$newLimit = wfShorthandToInteger( (string)$newLimit );
|
||||
if ( $newLimit == -1 ) {
|
||||
wfDebug( "Removing PHP's memory limit" );
|
||||
AtEase::suppressWarnings();
|
||||
|
|
|
|||
|
|
@ -2637,7 +2637,7 @@ class OutputPage extends ContextSource {
|
|||
if ( $this->getHookRunner()->onBeforePageRedirect( $this, $redirect, $code ) ) {
|
||||
if ( $code == '301' || $code == '303' ) {
|
||||
if ( !$config->get( 'DebugRedirects' ) ) {
|
||||
$response->statusHeader( $code );
|
||||
$response->statusHeader( (int)$code );
|
||||
}
|
||||
$this->mLastModified = wfTimestamp( TS_RFC2822 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class ConditionalHeaderUtil {
|
|||
if ( $lastModified === null ) {
|
||||
$this->lastModified = null;
|
||||
} else {
|
||||
$this->lastModified = ConvertibleTimestamp::convert( TS_UNIX, $lastModified );
|
||||
$this->lastModified = (int)ConvertibleTimestamp::convert( TS_UNIX, $lastModified );
|
||||
}
|
||||
if ( $hasRepresentation === null ) {
|
||||
$hasRepresentation = $eTag !== null;
|
||||
|
|
|
|||
|
|
@ -881,7 +881,7 @@ class PageUpdater {
|
|||
// Deprecated since 1.35.
|
||||
$allowedByHook = $this->hookRunner->onPageContentSave(
|
||||
$this->getWikiPage(), $legacyUser, $mainContent, $summary,
|
||||
$this->flags & EDIT_MINOR, null, null, $this->flags, $hookStatus
|
||||
(bool)( $this->flags & EDIT_MINOR ), null, null, $this->flags, $hookStatus
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,8 +117,8 @@ class HistoryAction extends FormlessAction {
|
|||
$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
|
||||
|
||||
// Left pad the months and days
|
||||
$month = str_pad( $month, 2, "0", STR_PAD_LEFT );
|
||||
$day = str_pad( $day, 2, "0", STR_PAD_LEFT );
|
||||
$month = str_pad( (string)$month, 2, "0", STR_PAD_LEFT );
|
||||
$day = str_pad( (string)$day, 2, "0", STR_PAD_LEFT );
|
||||
}
|
||||
|
||||
$before = $request->getVal( 'date-range-to' );
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class NumericUppercaseCollation extends UppercaseCollation {
|
|||
$len = strlen( $number );
|
||||
// This allows sequences of up to 65536 numeric characters to be handled correctly. One byte
|
||||
// would allow only for 256, which doesn't feel future-proof.
|
||||
$prefix = chr( floor( $len / 256 ) ) . chr( $len % 256 );
|
||||
$prefix = chr( (int)floor( $len / 256 ) ) . chr( $len % 256 );
|
||||
return '0' . $prefix . $number;
|
||||
}, $sortkey );
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Dump7ZipOutput extends DumpPipeOutput {
|
|||
*/
|
||||
private function setup7zCommand( $file ) {
|
||||
$command = "7za a -bd -si -mx=";
|
||||
$command .= Shell::escape( $this->compressionLevel ) . ' ';
|
||||
$command .= Shell::escape( (string)$this->compressionLevel ) . ' ';
|
||||
$command .= Shell::escape( $file );
|
||||
// Suppress annoying useless crap from p7zip
|
||||
// Unfortunately this could suppress real error messages too
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class ExternalStoreMwstore extends ExternalStoreMedium {
|
|||
public function store( $backend, $data ) {
|
||||
$be = $this->fbGroup->get( $backend );
|
||||
// Get three random base 36 characters to act as shard directories
|
||||
$rand = Wikimedia\base_convert( mt_rand( 0, 46655 ), 10, 36, 3 );
|
||||
$rand = Wikimedia\base_convert( (string)mt_rand( 0, 46655 ), 10, 36, 3 );
|
||||
// Make sure ID is roughly lexicographically increasing for performance
|
||||
$id = str_pad( UIDGenerator::newTimestampedUID128( 32 ), 26, '0', STR_PAD_LEFT );
|
||||
// Segregate items by DB domain ID for the sake of bookkeeping
|
||||
|
|
|
|||
|
|
@ -591,7 +591,7 @@ class JobRunner implements LoggerAwareInterface {
|
|||
if ( preg_match( '!^(\d+)(k|m|g|)$!i', ini_get( 'memory_limit' ), $m ) ) {
|
||||
list( , $num, $unit ) = $m;
|
||||
$conv = [ 'g' => 1073741824, 'm' => 1048576, 'k' => 1024, '' => 1 ];
|
||||
$maxBytes = $num * $conv[strtolower( $unit )];
|
||||
$maxBytes = (int)$num * $conv[strtolower( $unit )];
|
||||
} else {
|
||||
$maxBytes = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -288,8 +288,8 @@ class FileBackendMultiWrite extends FileBackend {
|
|||
} elseif (
|
||||
( $this->syncChecks & self::CHECK_TIME ) &&
|
||||
abs(
|
||||
ConvertibleTimestamp::convert( TS_UNIX, $masterStat['mtime'] ) -
|
||||
ConvertibleTimestamp::convert( TS_UNIX, $cloneStat['mtime'] )
|
||||
(int)ConvertibleTimestamp::convert( TS_UNIX, $masterStat['mtime'] ) -
|
||||
(int)ConvertibleTimestamp::convert( TS_UNIX, $cloneStat['mtime'] )
|
||||
) > 30
|
||||
) {
|
||||
// File in the clone backend is significantly newer or older
|
||||
|
|
|
|||
|
|
@ -1738,7 +1738,7 @@ abstract class FileBackendStore extends FileBackend {
|
|||
if ( $digits > 0 ) {
|
||||
$numShards = $base ** $digits;
|
||||
for ( $index = 0; $index < $numShards; $index++ ) {
|
||||
$shards[] = '.' . Wikimedia\base_convert( $index, 10, $base, $digits );
|
||||
$shards[] = '.' . Wikimedia\base_convert( (string)$index, 10, $base, $digits );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -231,11 +231,11 @@ class HTTPFileStreamer {
|
|||
if ( $start === '' && $end === '' ) {
|
||||
$absRange = [ 0, $size - 1 ];
|
||||
} elseif ( $start === '' ) {
|
||||
$absRange = [ $size - $end, $size - 1 ];
|
||||
$absRange = [ $size - (int)$end, $size - 1 ];
|
||||
} elseif ( $end === '' ) {
|
||||
$absRange = [ $start, $size - 1 ];
|
||||
$absRange = [ (int)$start, $size - 1 ];
|
||||
} else {
|
||||
$absRange = [ $start, $end ];
|
||||
$absRange = [ (int)$start, (int)$end ];
|
||||
}
|
||||
if ( $absRange[0] >= 0 && $absRange[1] >= $absRange[0] ) {
|
||||
if ( $absRange[0] < $size ) {
|
||||
|
|
|
|||
|
|
@ -1768,7 +1768,7 @@ class SwiftFileBackend extends FileBackendStore {
|
|||
if ( isset( $creds['auth_token'] ) && isset( $creds['storage_url'] ) ) {
|
||||
$this->authCreds = $creds;
|
||||
// Skew the timestamp for worst case to avoid using stale credentials
|
||||
$this->authSessionTimestamp = time() - ceil( $this->authTTL / 2 );
|
||||
$this->authSessionTimestamp = time() - (int)ceil( $this->authTTL / 2 );
|
||||
} else { // cache miss
|
||||
list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->http->run( [
|
||||
'method' => 'GET',
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ class RedisBagOStuff extends MediumSpecificBagOStuff {
|
|||
$conn->multi( Redis::PIPELINE );
|
||||
$conn->set(
|
||||
$key,
|
||||
$init - $step,
|
||||
(string)( $init - $step ),
|
||||
$ttl ? [ 'nx', 'ex' => $ttl ] : [ 'nx' ]
|
||||
);
|
||||
$conn->incrBy( $key, $step );
|
||||
|
|
|
|||
|
|
@ -1523,7 +1523,7 @@ class WANObjectCache implements
|
|||
// so that purges to the main key propagate to the variant value.
|
||||
$this->logger->debug( "getWithSetCallback($key): using variant key" );
|
||||
list( $value ) = $this->fetchOrRegenerate(
|
||||
$this->makeGlobalKey( 'WANCache-key-variant', md5( $key ), $version ),
|
||||
$this->makeGlobalKey( 'WANCache-key-variant', md5( $key ), (string)$version ),
|
||||
$ttl,
|
||||
$callback,
|
||||
[ 'version' => null, 'minAsOf' => $curAsOf ] + $opts,
|
||||
|
|
@ -1755,7 +1755,7 @@ class WANObjectCache implements
|
|||
private function yieldStampedeLock( $key, $hasLock ) {
|
||||
if ( $hasLock ) {
|
||||
$checkSisterKey = $this->makeSisterKey( $key, self::TYPE_MUTEX );
|
||||
$this->cache->changeTTL( $checkSisterKey, $this->getCurrentTime() - 60 );
|
||||
$this->cache->changeTTL( $checkSisterKey, (int)$this->getCurrentTime() - 60 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ class GlobalIdGenerator {
|
|||
ftruncate( $handle, 0 );
|
||||
rewind( $handle );
|
||||
// Use fmod() to avoid "division by zero" on 32 bit machines
|
||||
fwrite( $handle, fmod( $counter, 2 ** 48 ) ); // warp-around as needed
|
||||
fwrite( $handle, (string)fmod( $counter, 2 ** 48 ) ); // warp-around as needed
|
||||
fflush( $handle );
|
||||
// Release the UID lock file
|
||||
flock( $handle, LOCK_UN );
|
||||
|
|
@ -589,7 +589,7 @@ class GlobalIdGenerator {
|
|||
': sorry, this function doesn\'t work after the year 144680' );
|
||||
}
|
||||
|
||||
return substr( \Wikimedia\base_convert( $ts, 10, 2, 46 ), -46 );
|
||||
return substr( \Wikimedia\base_convert( (string)$ts, 10, 2, 46 ), -46 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -613,7 +613,7 @@ class GlobalIdGenerator {
|
|||
} elseif ( extension_loaded( 'bcmath' ) ) {
|
||||
$ts = bcadd( bcmul( $sec, 1000 ), $msec ); // ms
|
||||
$ts = bcadd( bcmul( $ts, 10000 ), $offset ); // 100ns intervals
|
||||
$ts = bcadd( $ts, $delta );
|
||||
$ts = bcadd( $ts, (string)$delta );
|
||||
$ts = bcmod( $ts, bcpow( 2, 60 ) ); // wrap around
|
||||
$id_bin = \Wikimedia\base_convert( $ts, 10, 2, 60 );
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -541,7 +541,7 @@ class LogFormatter {
|
|||
}
|
||||
list( $index, $type, ) = explode( ':', $key, 3 );
|
||||
if ( ctype_digit( $index ) ) {
|
||||
$params[$index - 1] = $this->formatParameterValue( $type, $value );
|
||||
$params[(int)$index - 1] = $this->formatParameterValue( $type, $value );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ class BitmapHandler extends TransformationalImageHandler {
|
|||
) {
|
||||
// Hack, since $wgSharpenParameter is written specifically for the command line convert
|
||||
list( $radius, $sigma ) = explode( 'x', $sharpenParameter );
|
||||
$im->sharpenImage( $radius, $sigma );
|
||||
$im->sharpenImage( (float)$radius, (float)$sigma );
|
||||
}
|
||||
$qualityVal = isset( $params['quality'] ) ? (string)$params['quality'] : null;
|
||||
$im->setCompressionQuality( $qualityVal ?: $jpegQuality );
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ class Exif {
|
|||
// functions ran earlier. But multiplying such a string by -1
|
||||
// doesn't work well, so convert.
|
||||
list( $num, $denom ) = explode( '/', $this->mFilteredExifData['GPSAltitude'] );
|
||||
$this->mFilteredExifData['GPSAltitude'] = $num / $denom;
|
||||
$this->mFilteredExifData['GPSAltitude'] = (int)$num / (int)$denom;
|
||||
|
||||
if ( isset( $this->mFilteredExifData['GPSAltitudeRef'] ) ) {
|
||||
switch ( $this->mFilteredExifData['GPSAltitudeRef'] ) {
|
||||
|
|
@ -531,11 +531,11 @@ class Exif {
|
|||
&& ( $dir === 'N' || $dir === 'S' || $dir === 'E' || $dir === 'W' )
|
||||
) {
|
||||
list( $num, $denom ) = explode( '/', $loc[0] );
|
||||
$res = $num / $denom;
|
||||
$res = (int)$num / (int)$denom;
|
||||
list( $num, $denom ) = explode( '/', $loc[1] );
|
||||
$res += ( $num / $denom ) * ( 1 / 60 );
|
||||
$res += ( (int)$num / (int)$denom ) * ( 1 / 60 );
|
||||
list( $num, $denom ) = explode( '/', $loc[2] );
|
||||
$res += ( $num / $denom ) * ( 1 / 3600 );
|
||||
$res += ( (int)$num / (int)$denom ) * ( 1 / 3600 );
|
||||
|
||||
if ( $dir === 'S' || $dir === 'W' ) {
|
||||
$res *= -1; // make negative
|
||||
|
|
|
|||
|
|
@ -160,9 +160,9 @@ class FormatMetadata extends ContextSource {
|
|||
) {
|
||||
continue;
|
||||
}
|
||||
$vals = str_pad( intval( $h[0] / $h[1] ), 2, '0', STR_PAD_LEFT )
|
||||
. ':' . str_pad( intval( $m[0] / $m[1] ), 2, '0', STR_PAD_LEFT )
|
||||
. ':' . str_pad( intval( $s[0] / $s[1] ), 2, '0', STR_PAD_LEFT );
|
||||
$vals = str_pad( (string)( (int)$h[0] / (int)$h[1] ), 2, '0', STR_PAD_LEFT )
|
||||
. ':' . str_pad( (string)( (int)$m[0] / (int)$m[1] ), 2, '0', STR_PAD_LEFT )
|
||||
. ':' . str_pad( (string)( (int)$s[0] / (int)$s[1] ), 2, '0', STR_PAD_LEFT );
|
||||
|
||||
try {
|
||||
$time = wfTimestamp( TS_MW, '1971:01:01 ' . $vals );
|
||||
|
|
@ -861,7 +861,7 @@ class FormatMetadata extends ContextSource {
|
|||
// need to expand this earlier to calculate fNumber
|
||||
list( $n, $d ) = explode( '/', $val );
|
||||
if ( is_numeric( $n ) && is_numeric( $d ) ) {
|
||||
$val = $n / $d;
|
||||
$val = (int)$n / (int)$d;
|
||||
}
|
||||
}
|
||||
if ( is_numeric( $val ) ) {
|
||||
|
|
@ -1372,7 +1372,7 @@ class FormatMetadata extends ContextSource {
|
|||
}
|
||||
if ( preg_match( '/^(-?\d+)\/(\d+)$/', $num, $m ) ) {
|
||||
if ( $m[2] != 0 ) {
|
||||
$newNum = $m[1] / $m[2];
|
||||
$newNum = (int)$m[1] / (int)$m[2];
|
||||
if ( $round !== false ) {
|
||||
$newNum = round( $newNum, $round );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -389,9 +389,9 @@ class IPTC {
|
|||
$tz = -$tz;
|
||||
}
|
||||
|
||||
$finalTimestamp = wfTimestamp( TS_EXIF, $unixTS + $tz );
|
||||
$finalTimestamp = wfTimestamp( TS_EXIF, (int)$unixTS + $tz );
|
||||
if ( $finalTimestamp === false ) {
|
||||
wfDebugLog( 'iptc', "IPTC: can't make final timestamp. Date: " . ( $unixTS + $tz ) );
|
||||
wfDebugLog( 'iptc', "IPTC: can't make final timestamp. Date: " . ( (int)$unixTS + $tz ) );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ class JpegHandler extends ExifBitmapHandler {
|
|||
if ( $jpegTran && is_executable( $jpegTran ) ) {
|
||||
$command = Shell::command( $jpegTran,
|
||||
'-rotate',
|
||||
$rotation,
|
||||
(string)$rotation,
|
||||
'-outfile',
|
||||
$params['dstPath'],
|
||||
$params['srcPath']
|
||||
|
|
|
|||
|
|
@ -863,7 +863,7 @@ abstract class MediaHandler {
|
|||
$idealWidth = $boxWidth * $maxHeight / $boxHeight;
|
||||
$roundedUp = ceil( $idealWidth );
|
||||
if ( round( $roundedUp * $boxHeight / $boxWidth ) > $maxHeight ) {
|
||||
return floor( $idealWidth );
|
||||
return (int)floor( $idealWidth );
|
||||
} else {
|
||||
return $roundedUp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ class ThumbnailImage extends MediaTransformOutput {
|
|||
# These should be integers when they get here.
|
||||
# If not, there's a bug somewhere. But let's at
|
||||
# least produce valid HTML code regardless.
|
||||
$this->width = round( $actualParams['width'] );
|
||||
$this->height = round( $actualParams['height'] );
|
||||
$this->width = (int)round( $actualParams['width'] );
|
||||
$this->height = (int)round( $actualParams['height'] );
|
||||
|
||||
$this->page = $actualParams['page'];
|
||||
$this->lang = $actualParams['lang'];
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
|
|||
*/
|
||||
private function getTableNameByShard( $index ) {
|
||||
if ( $index !== null && $this->numTableShards > 1 ) {
|
||||
$decimals = strlen( $this->numTableShards - 1 );
|
||||
$decimals = strlen( (string)( $this->numTableShards - 1 ) );
|
||||
|
||||
return $this->tableName . sprintf( "%0{$decimals}d", $index );
|
||||
}
|
||||
|
|
@ -1103,7 +1103,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
|
|||
// 67 bit integral portion of UNIX timestamp, qualified
|
||||
\Wikimedia\base_convert(
|
||||
// 35 bit integral seconds portion of UNIX timestamp
|
||||
str_pad( base_convert( $seconds, 10, 2 ), 35, '0', STR_PAD_LEFT ) .
|
||||
str_pad( base_convert( (string)$seconds, 10, 2 ), 35, '0', STR_PAD_LEFT ) .
|
||||
// 32 bit ID of the primary database server handling the write
|
||||
str_pad( base_convert( $id, 10, 2 ), 32, '0', STR_PAD_LEFT ),
|
||||
2,
|
||||
|
|
@ -1484,7 +1484,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
|
|||
if ( $res->numRows() ) {
|
||||
$row = $res->current();
|
||||
if ( $minExpUnix === null ) {
|
||||
$minExpUnix = ConvertibleTimestamp::convert( TS_UNIX, $row->exptime );
|
||||
$minExpUnix = (int)ConvertibleTimestamp::convert( TS_UNIX, $row->exptime );
|
||||
$totalSeconds = max( $cutoffUnix - $minExpUnix, 1 );
|
||||
}
|
||||
|
||||
|
|
@ -1507,7 +1507,7 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
|
|||
|
||||
if ( $progress && is_callable( $progress['fn'] ) ) {
|
||||
if ( $totalSeconds ) {
|
||||
$maxExpUnix = ConvertibleTimestamp::convert( TS_UNIX, $maxExp );
|
||||
$maxExpUnix = (int)ConvertibleTimestamp::convert( TS_UNIX, $maxExp );
|
||||
$remainingSeconds = $cutoffUnix - $maxExpUnix;
|
||||
$processedSeconds = max( $totalSeconds - $remainingSeconds, 0 );
|
||||
// For example, if we've done 1.5 table shard, and are thus half-way on the
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ class ImagePage extends Article {
|
|||
];
|
||||
$options = [];
|
||||
for ( $i = 1; $i <= $count; $i++ ) {
|
||||
$options[] = Xml::option( $lang->formatNum( $i ), $i, $i == $page );
|
||||
$options[] = Xml::option( $lang->formatNum( $i ), (string)$i, $i == $page );
|
||||
}
|
||||
$select = Xml::tags( 'select',
|
||||
[ 'id' => 'pageselector', 'name' => 'page' ],
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ class CoreMagicVariables {
|
|||
case 'namespacee':
|
||||
return wfUrlencode( $parser->getContentLanguage()->getNsText( $title->getNamespace() ) );
|
||||
case 'namespacenumber':
|
||||
return $title->getNamespace();
|
||||
return (string)$title->getNamespace();
|
||||
case 'talkspace':
|
||||
return $title->canHaveTalkPage()
|
||||
? str_replace( '_', ' ', $title->getTalkNsText() )
|
||||
|
|
|
|||
|
|
@ -565,7 +565,7 @@ class CoreParserFunctions {
|
|||
if (
|
||||
$raw !== null && self::matchAgainstMagicword( $magicWordFactory, 'rawsuffix', $raw )
|
||||
) {
|
||||
return $num;
|
||||
return (string)$num;
|
||||
} else {
|
||||
return $language->formatNum( $num );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4195,7 +4195,7 @@ class Parser {
|
|||
$numbering = '';
|
||||
$markerMatches = [];
|
||||
if ( preg_match( "/^$markerRegex/", $headline, $markerMatches ) ) {
|
||||
$serial = $markerMatches[1];
|
||||
$serial = (int)$markerMatches[1];
|
||||
list( $titleText, $sectionIndex ) = $this->mHeadings[$serial];
|
||||
$isTemplate = ( $titleText != $baseTitleText );
|
||||
$headline = preg_replace( "/^$markerRegex\\s*/", "", $headline );
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class PoolCounterRedis extends PoolCounter {
|
|||
|
||||
$this->keySha1 = sha1( $this->key );
|
||||
$met = ini_get( 'max_execution_time' ); // usually 0 in CLI mode
|
||||
$this->lockTTL = $met ? 2 * $met : 3600;
|
||||
$this->lockTTL = $met ? 2 * (int)$met : 3600;
|
||||
|
||||
if ( self::$active === null ) {
|
||||
self::$active = [];
|
||||
|
|
@ -282,7 +282,7 @@ LUA;
|
|||
|
||||
if ( $slot !== 'w' ) {
|
||||
$this->slot = $slot;
|
||||
$this->slotTime = $slotTime;
|
||||
$this->slotTime = (int)$slotTime;
|
||||
$this->onRelease = $doWakeup;
|
||||
self::$active[$this->session] = $this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1019,7 +1019,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
|
|||
}
|
||||
}
|
||||
if ( count( $tz ) > 1 && $tz[0] == 'Offset' ) {
|
||||
$minDiff = $tz[1];
|
||||
$minDiff = (int)$tz[1];
|
||||
$tzSetting = sprintf( '%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) % 60 );
|
||||
}
|
||||
|
||||
|
|
@ -1808,7 +1808,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
|
|||
|
||||
$timestamp = MWTimestamp::getLocalInstance();
|
||||
// Check that the LocalTZoffset is the same as the local time zone offset
|
||||
if ( $localTZoffset === $timestamp->format( 'Z' ) / 60 ) {
|
||||
if ( $localTZoffset === (int)$timestamp->format( 'Z' ) / 60 ) {
|
||||
$timezoneName = $timestamp->getTimezone()->getName();
|
||||
// Localize timezone
|
||||
if ( isset( $timeZoneList[$timezoneName] ) ) {
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ class CookieSessionProvider extends SessionProvider {
|
|||
if ( $loggedOut + 86400 > time() &&
|
||||
$loggedOut !== (int)$this->getCookie( $request, 'LoggedOut', $this->cookieOptions['prefix'] )
|
||||
) {
|
||||
$request->response()->setCookie( 'LoggedOut', $loggedOut, $loggedOut + 86400,
|
||||
$request->response()->setCookie( 'LoggedOut', (string)$loggedOut, $loggedOut + 86400,
|
||||
$this->cookieOptions );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1060,7 +1060,7 @@ class SessionManager implements SessionManagerInterface {
|
|||
return;
|
||||
}
|
||||
$mwuser = $session->getRequest()->getCookie( 'mwuser-sessionId' );
|
||||
$now = \MWTimestamp::now( TS_UNIX );
|
||||
$now = (int)\MWTimestamp::now( TS_UNIX );
|
||||
|
||||
// Record (and possibly log) that the IP is using the current session.
|
||||
// Don't touch the stored data unless we are changing the IP or re-adding an expired one.
|
||||
|
|
|
|||
|
|
@ -855,7 +855,7 @@ class SpecialBlock extends FormSpecialPage {
|
|||
}
|
||||
if ( isset( $data['NamespaceRestrictions'] ) && $data['NamespaceRestrictions'] !== '' ) {
|
||||
$namespaceRestrictions = array_map( static function ( $id ) {
|
||||
return new NamespaceRestriction( 0, $id );
|
||||
return new NamespaceRestriction( 0, (int)$id );
|
||||
}, explode( "\n", $data['NamespaceRestrictions'] ) );
|
||||
}
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -87,9 +87,9 @@ class SpecialBookSources extends SpecialPage {
|
|||
if ( $isbn[$i] === 'X' ) {
|
||||
return false;
|
||||
} elseif ( $i % 2 == 0 ) {
|
||||
$sum += $isbn[$i];
|
||||
$sum += (int)$isbn[$i];
|
||||
} else {
|
||||
$sum += 3 * $isbn[$i];
|
||||
$sum += 3 * (int)$isbn[$i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ class SpecialBookSources extends SpecialPage {
|
|||
if ( $isbn[$i] === 'X' ) {
|
||||
return false;
|
||||
}
|
||||
$sum += $isbn[$i] * ( $i + 1 );
|
||||
$sum += (int)$isbn[$i] * ( $i + 1 );
|
||||
}
|
||||
|
||||
$check = $sum % 11;
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ class SpecialComparePages extends SpecialPage {
|
|||
if ( $value === '' || $value === null ) {
|
||||
return true;
|
||||
}
|
||||
$revisionRecord = $this->revisionLookup->getRevisionById( $value );
|
||||
$revisionRecord = $this->revisionLookup->getRevisionById( (int)$value );
|
||||
if ( $revisionRecord === null ) {
|
||||
return $this->msg( 'compare-revision-not-exists' )->parseAsBlock();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -677,7 +677,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
|
|||
|
||||
foreach ( $fields as $data ) {
|
||||
# strip out the 'ns' prefix from the section name:
|
||||
$ns = substr( $data['section'], 2 );
|
||||
$ns = (int)substr( $data['section'], 2 );
|
||||
|
||||
$nsText = ( $ns == NS_MAIN )
|
||||
? $this->msg( 'blanknamespace' )->escaped()
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class SpecialExport extends SpecialPage {
|
|||
/**
|
||||
* Same implementation as above, so same @todo
|
||||
*/
|
||||
$nspages = $this->getPagesFromNamespace( $nsindex );
|
||||
$nspages = $this->getPagesFromNamespace( (int)$nsindex );
|
||||
if ( $nspages ) {
|
||||
$page .= "\n" . implode( "\n", $nspages );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
|
|||
$this->msg( $message )->text(),
|
||||
$name,
|
||||
$name,
|
||||
$bitfield & $field
|
||||
(bool)( $bitfield & $field )
|
||||
);
|
||||
|
||||
if ( $field == RevisionRecord::DELETED_RESTRICTED ) {
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ class SpecialVersion extends SpecialPage {
|
|||
|
||||
$gitHeadCommitDate = $gitInfo->getHeadCommitDate();
|
||||
if ( $gitHeadCommitDate ) {
|
||||
$shortSHA1 .= Html::element( 'br' ) . $wgLang->timeanddate( $gitHeadCommitDate, true );
|
||||
$shortSHA1 .= Html::element( 'br' ) . $wgLang->timeanddate( (string)$gitHeadCommitDate, true );
|
||||
}
|
||||
|
||||
return self::getMWVersionLinked() . " $shortSHA1";
|
||||
|
|
|
|||
|
|
@ -905,7 +905,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
|
|||
'span',
|
||||
$attribs,
|
||||
// not using Html::checkLabel because that would escape the contents
|
||||
Html::check( $name, (int)$value, [ 'id' => $name ] ) . "\n" . Html::rawElement(
|
||||
Html::check( $name, (bool)$value, [ 'id' => $name ] ) . "\n" . Html::rawElement(
|
||||
'label',
|
||||
$attribs + [ 'for' => $name ],
|
||||
// <nowiki/> at beginning to avoid messages with "$1 ..." being parsed as pre tags
|
||||
|
|
@ -923,7 +923,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
|
|||
*/
|
||||
protected function countItems() {
|
||||
$count = $this->watchedItemStore->countWatchedItems( $this->getUser() );
|
||||
return floor( $count / 2 );
|
||||
return (int)floor( $count / 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
class EditWatchlistNormalHTMLForm extends OOUIHTMLForm {
|
||||
public function getLegend( $namespace ) {
|
||||
$namespace = substr( $namespace, 2 );
|
||||
$namespace = (int)substr( $namespace, 2 );
|
||||
|
||||
return $namespace == NS_MAIN
|
||||
? $this->msg( 'blanknamespace' )->text()
|
||||
|
|
|
|||
|
|
@ -252,8 +252,8 @@ class BlockListPager extends TablePager {
|
|||
break;
|
||||
|
||||
case 'ipb_by':
|
||||
$formatted = Linker::userLink( $value, $row->ipb_by_text );
|
||||
$formatted .= Linker::userToolLinks( $value, $row->ipb_by_text );
|
||||
$formatted = Linker::userLink( (int)$value, $row->ipb_by_text );
|
||||
$formatted .= Linker::userToolLinks( (int)$value, $row->ipb_by_text );
|
||||
break;
|
||||
|
||||
case 'ipb_reason':
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ class ContribsPager extends RangeChronologicalPager {
|
|||
// If the query results are in descending order, the indexes must also be in descending order
|
||||
$index = $order === self::QUERY_ASCENDING ? $i : $limit - 1 - $i;
|
||||
// Left-pad with zeroes, because these values will be sorted as strings
|
||||
$index = str_pad( $index, strlen( $limit ), '0', STR_PAD_LEFT );
|
||||
$index = str_pad( (string)$index, strlen( (string)$limit ), '0', STR_PAD_LEFT );
|
||||
// use index column as key, allowing us to easily sort in PHP
|
||||
$result[$row->{$this->getIndexField()} . "-$index"] = $row;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ class ImageListPager extends TablePager {
|
|||
|
||||
return $link;
|
||||
case 'img_size':
|
||||
return htmlspecialchars( $this->getLanguage()->formatSize( $value ) );
|
||||
return htmlspecialchars( $this->getLanguage()->formatSize( (int)$value ) );
|
||||
case 'img_description':
|
||||
$field = $this->mCurrentRow->description_field;
|
||||
$value = $this->commentStore->getComment( $field, $this->mCurrentRow )->text;
|
||||
|
|
|
|||
|
|
@ -233,8 +233,8 @@ class ProtectedPagesPager extends TablePager {
|
|||
LogPage::DELETED_USER,
|
||||
$this->getUser()
|
||||
) ) {
|
||||
$formatted = Linker::userLink( $value, $username )
|
||||
. Linker::userToolLinks( $value, $username );
|
||||
$formatted = Linker::userLink( (int)$value, $username )
|
||||
. Linker::userToolLinks( (int)$value, $username );
|
||||
} else {
|
||||
$formatted = $this->msg( 'rev-deleted-user' )->escaped();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ class UploadStash {
|
|||
list( $usec, $sec ) = explode( ' ', microtime() );
|
||||
$usec = substr( $usec, 2 );
|
||||
$key = Wikimedia\base_convert( $sec . $usec, 10, 36 ) . '.' .
|
||||
Wikimedia\base_convert( mt_rand(), 10, 36 ) . '.' .
|
||||
Wikimedia\base_convert( (string)mt_rand(), 10, 36 ) . '.' .
|
||||
$this->user->getId() . '.' .
|
||||
$extension;
|
||||
|
||||
|
|
|
|||
|
|
@ -532,8 +532,8 @@ class ZipDirectoryReader {
|
|||
$this->error( 'zip-bad', "getBlock() requested end position $end, " .
|
||||
"file length is $fileLength" );
|
||||
}
|
||||
$startSeg = floor( $start / self::SEGSIZE );
|
||||
$endSeg = ceil( $end / self::SEGSIZE );
|
||||
$startSeg = (int)floor( $start / self::SEGSIZE );
|
||||
$endSeg = (int)ceil( $end / self::SEGSIZE );
|
||||
|
||||
$block = '';
|
||||
for ( $segIndex = $startSeg; $segIndex <= $endSeg; $segIndex++ ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue