From: Reedy Date: Mon, 25 Feb 2019 00:38:33 +0000 (+0000) Subject: Use (int) rather than intval() X-Git-Tag: 1.34.0-rc.0~2730 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=4691389fa46f79cbeaf2daffda407cf7daa66fd4 Use (int) rather than intval() Bug: T216969 Change-Id: I4c06716c83b69d128f26fa7f68736808aa2d3d64 --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index dfaff8b76e..4898385cfc 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -1282,7 +1282,7 @@ abstract class ApiBase extends ContextSource { } } } else { - $value = intval( $value ); + $value = (int)$value; if ( !is_null( $min ) || !is_null( $max ) ) { $this->validateLimit( $paramName, $value, $min, $max, null, $enforceLimits ); } @@ -1311,7 +1311,7 @@ abstract class ApiBase extends ContextSource { : $paramSettings[self::PARAM_MAX]; $this->getResult()->addParsedLimit( $this->getModuleName(), $value ); } else { - $value = intval( $value ); + $value = (int)$value; $this->validateLimit( $paramName, $value, diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 8131ea550e..d0a0523bf7 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -427,15 +427,15 @@ class ApiEditPage extends ApiBase { case EditPage::AS_SUCCESS_UPDATE: $r['result'] = 'Success'; - $r['pageid'] = intval( $titleObj->getArticleID() ); + $r['pageid'] = (int)$titleObj->getArticleID(); $r['title'] = $titleObj->getPrefixedText(); $r['contentmodel'] = $articleObject->getContentModel(); $newRevId = $articleObject->getLatest(); if ( $newRevId == $oldRevId ) { $r['nochange'] = true; } else { - $r['oldrevid'] = intval( $oldRevId ); - $r['newrevid'] = intval( $newRevId ); + $r['oldrevid'] = (int)$oldRevId; + $r['newrevid'] = (int)$newRevId; $r['newtimestamp'] = wfTimestamp( TS_ISO_8601, $pageObj->getTimestamp() ); } diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index 2492db2070..ed3b7b8268 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -137,7 +137,7 @@ class ApiFeedContributions extends ApiBase { } // Hook completed and did not return a valid feed item - $title = Title::makeTitle( intval( $row->page_namespace ), $row->page_title ); + $title = Title::makeTitle( (int)$row->page_namespace, $row->page_title ); if ( $title && $title->userCan( 'read', $this->getUser() ) ) { $date = $row->rev_timestamp; $comments = $title->getTalkPage()->getFullURL(); diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index 8c0b42df21..935bb096ab 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -61,7 +61,7 @@ class ApiFeedWatchlist extends ApiBase { } // limit to the number of hours going from now back - $endTime = wfTimestamp( TS_MW, time() - intval( $params['hours'] * 60 * 60 ) ); + $endTime = wfTimestamp( TS_MW, time() - (int)$params['hours'] * 60 * 60 ); // Prepare parameters for nested request $fauxReqArr = [ diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php index 822711aa02..596ab75e48 100644 --- a/includes/api/ApiImport.php +++ b/includes/api/ApiImport.php @@ -207,7 +207,7 @@ class ApiImportReporter extends ImportReporter { $r['invalid'] = true; } else { ApiQueryBase::addTitleInfo( $r, $title ); - $r['revisions'] = intval( $successCount ); + $r['revisions'] = (int)$successCount; } $this->mResultArr[] = $r; diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php index 8f2e759276..133f0ce556 100644 --- a/includes/api/ApiLogin.php +++ b/includes/api/ApiLogin.php @@ -197,7 +197,7 @@ class ApiLogin extends ApiBase { $injected_html = ''; Hooks::run( 'UserLoginComplete', [ &$user, &$injected_html, true ] ); - $result['lguserid'] = intval( $user->getId() ); + $result['lguserid'] = (int)$user->getId(); $result['lgusername'] = $user->getName(); break; diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 3cc34070e2..634ebd167d 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -1277,8 +1277,8 @@ class ApiMain extends ApiBase { if ( $lagInfo['lag'] > $maxLag ) { $response = $this->getRequest()->response(); - $response->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) ); - $response->header( 'X-Database-Lag: ' . intval( $lagInfo['lag'] ) ); + $response->header( 'Retry-After: ' . max( (int)$maxLag, 5 ) ); + $response->header( 'X-Database-Lag: ' . (int)$lagInfo['lag'] ); if ( $this->getConfig()->get( 'ShowHostnames' ) ) { $this->dieWithError( diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index 4ffe873ccf..450ebb6911 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -760,7 +760,7 @@ class ApiPageSet extends ApiBase { $linkCache = MediaWikiServices::getInstance()->getLinkCache(); $linkCache->addGoodLinkObjFromRow( $title, $row ); - $pageId = intval( $row->page_id ); + $pageId = (int)$row->page_id; $this->mAllPages[$row->page_namespace][$row->page_title] = $pageId; $this->mTitles[] = $title; @@ -869,7 +869,7 @@ class ApiPageSet extends ApiBase { $usernames = []; if ( $res ) { foreach ( $res as $row ) { - $pageId = intval( $row->page_id ); + $pageId = (int)$row->page_id; // Remove found page from the list of remaining items if ( isset( $remaining ) ) { @@ -953,8 +953,8 @@ class ApiPageSet extends ApiBase { // Get pageIDs data from the `page` table $res = $db->select( $tables, $fields, $where, __METHOD__ ); foreach ( $res as $row ) { - $revid = intval( $row->rev_id ); - $pageid = intval( $row->rev_page ); + $revid = (int)$row->rev_id; + $pageid = (int)$row->rev_page; $this->mGoodRevIDs[$revid] = $pageid; $this->mLiveRevIDs[$revid] = $pageid; $pageids[$pageid] = ''; @@ -977,7 +977,7 @@ class ApiPageSet extends ApiBase { $res = $db->select( $tables, $fields, $where, __METHOD__ ); $titles = []; foreach ( $res as $row ) { - $revid = intval( $row->ar_rev_id ); + $revid = (int)$row->ar_rev_id; $titles[$revid] = Title::makeTitle( $row->ar_namespace, $row->ar_title ); unset( $remaining[$revid] ); } @@ -1068,7 +1068,7 @@ class ApiPageSet extends ApiBase { __METHOD__ ); foreach ( $res as $row ) { - $rdfrom = intval( $row->rd_from ); + $rdfrom = (int)$row->rd_from; $from = $this->mPendingRedirectIDs[$rdfrom]->getPrefixedText(); $to = Title::makeTitle( $row->rd_namespace, diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index c81cf7ee13..f1967354ff 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -361,7 +361,7 @@ class ApiParamInfo extends ApiBase { break; case 'integer': case 'limit': - $item['default'] = intval( $settings[ApiBase::PARAM_DFLT] ); + $item['default'] = (int)$settings[ApiBase::PARAM_DFLT]; break; case 'timestamp': $item['default'] = wfTimestamp( TS_ISO_8601, $settings[ApiBase::PARAM_DFLT] ); diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 9f561b7513..855b73d2e1 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -330,7 +330,7 @@ class ApiParse extends ApiBase { } if ( !is_null( $oldid ) ) { - $result_array['revid'] = intval( $oldid ); + $result_array['revid'] = (int)$oldid; } if ( $params['redirects'] && !is_null( $redirValues ) ) { diff --git a/includes/api/ApiPatrol.php b/includes/api/ApiPatrol.php index 2b65f95128..d1212f39b1 100644 --- a/includes/api/ApiPatrol.php +++ b/includes/api/ApiPatrol.php @@ -71,7 +71,7 @@ class ApiPatrol extends ApiBase { $this->dieStatus( $this->errorArrayToStatus( $retval, $user ) ); } - $result = [ 'rcid' => intval( $rc->getAttribute( 'rc_id' ) ) ]; + $result = [ 'rcid' => (int)$rc->getAttribute( 'rc_id' ) ]; ApiQueryBase::addTitleInfo( $result, $rc->getTitle() ); $this->getResult()->addValue( null, $this->getModuleName(), $result ); } diff --git a/includes/api/ApiQueryAllCategories.php b/includes/api/ApiQueryAllCategories.php index 4f833e0ce5..37fbe869e8 100644 --- a/includes/api/ApiQueryAllCategories.php +++ b/includes/api/ApiQueryAllCategories.php @@ -126,10 +126,10 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase { $item = []; ApiResult::setContentValue( $item, 'category', $titleObj->getText() ); if ( isset( $prop['size'] ) ) { - $item['size'] = intval( $row->cat_pages ); + $item['size'] = (int)$row->cat_pages; $item['pages'] = $row->cat_pages - $row->cat_subcats - $row->cat_files; - $item['files'] = intval( $row->cat_files ); - $item['subcats'] = intval( $row->cat_subcats ); + $item['files'] = (int)$row->cat_files; + $item['subcats'] = (int)$row->cat_subcats; } if ( isset( $prop['hidden'] ) ) { $item['hidden'] = (bool)$row->cat_hidden; diff --git a/includes/api/ApiQueryAllDeletedRevisions.php b/includes/api/ApiQueryAllDeletedRevisions.php index 7a1c461000..8855615755 100644 --- a/includes/api/ApiQueryAllDeletedRevisions.php +++ b/includes/api/ApiQueryAllDeletedRevisions.php @@ -258,14 +258,14 @@ class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase { $op = ( $dir == 'newer' ? '>' : '<' ); if ( $optimizeGenerateTitles ) { $this->dieContinueUsageIf( count( $cont ) != 2 ); - $ns = intval( $cont[0] ); + $ns = (int)$cont[0]; $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] ); $title = $db->addQuotes( $cont[1] ); $this->addWhere( "ar_namespace $op $ns OR " . "(ar_namespace = $ns AND ar_title $op= $title)" ); } elseif ( $mode == 'all' ) { $this->dieContinueUsageIf( count( $cont ) != 4 ); - $ns = intval( $cont[0] ); + $ns = (int)$cont[0]; $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] ); $title = $db->addQuotes( $cont[1] ); $ts = $db->addQuotes( $db->timestamp( $cont[2] ) ); diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index c7a0cbc3c2..acd11fd28c 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -217,11 +217,11 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase { // Filters not depending on sort if ( isset( $params['minsize'] ) ) { - $this->addWhere( 'img_size>=' . intval( $params['minsize'] ) ); + $this->addWhere( 'img_size>=' . (int)$params['minsize'] ); } if ( isset( $params['maxsize'] ) ) { - $this->addWhere( 'img_size<=' . intval( $params['maxsize'] ) ); + $this->addWhere( 'img_size<=' . (int)$params['maxsize'] ); } $sha1 = false; diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index 8377e7426f..fc23caa4d5 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -140,7 +140,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { } else { $this->dieContinueUsageIf( count( $continueArr ) != 2 ); $continueTitle = $db->addQuotes( $continueArr[0] ); - $continueFrom = intval( $continueArr[1] ); + $continueFrom = (int)$continueArr[1]; $this->addWhere( "{$pfx}{$fieldTitle} $op $continueTitle OR " . "({$pfx}{$fieldTitle} = $continueTitle AND " . @@ -204,7 +204,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase { ApiResult::META_TYPE => 'assoc', ]; if ( $fld_ids ) { - $vals['fromid'] = intval( $row->pl_from ); + $vals['fromid'] = (int)$row->pl_from; } if ( $fld_title ) { $title = Title::makeTitle( $namespace, $row->pl_title ); diff --git a/includes/api/ApiQueryAllPages.php b/includes/api/ApiQueryAllPages.php index 40909a49ce..1940600e5e 100644 --- a/includes/api/ApiQueryAllPages.php +++ b/includes/api/ApiQueryAllPages.php @@ -122,12 +122,12 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { $this->addFields( $selectFields ); $forceNameTitleIndex = true; if ( isset( $params['minsize'] ) ) { - $this->addWhere( 'page_len>=' . intval( $params['minsize'] ) ); + $this->addWhere( 'page_len>=' . (int)$params['minsize'] ); $forceNameTitleIndex = false; } if ( isset( $params['maxsize'] ) ) { - $this->addWhere( 'page_len<=' . intval( $params['maxsize'] ) ); + $this->addWhere( 'page_len<=' . (int)$params['maxsize'] ); $forceNameTitleIndex = false; } @@ -238,8 +238,8 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase { if ( is_null( $resultPageSet ) ) { $title = Title::makeTitle( $row->page_namespace, $row->page_title ); $vals = [ - 'pageid' => intval( $row->page_id ), - 'ns' => intval( $title->getNamespace() ), + 'pageid' => (int)$row->page_id, + 'ns' => (int)$title->getNamespace(), 'title' => $title->getPrefixedText() ]; $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $vals ); diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index 7b5df5047d..a54066153d 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -281,10 +281,10 @@ class ApiQueryAllUsers extends ApiQueryBase { $data['hidden'] = true; } if ( $fld_editcount ) { - $data['editcount'] = intval( $row->user_editcount ); + $data['editcount'] = (int)$row->user_editcount; } if ( $params['activeusers'] ) { - $data['recentactions'] = intval( $row->recentactions ); + $data['recentactions'] = (int)$row->recentactions; // @todo 'recenteditcount' is set for BC, remove in 1.25 $data['recenteditcount'] = $data['recentactions']; } diff --git a/includes/api/ApiQueryBacklinks.php b/includes/api/ApiQueryBacklinks.php index f4e7463e22..f82a559f1e 100644 --- a/includes/api/ApiQueryBacklinks.php +++ b/includes/api/ApiQueryBacklinks.php @@ -187,7 +187,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { } if ( is_null( $resultPageSet ) ) { - $a = [ 'pageid' => intval( $row->page_id ) ]; + $a = [ 'pageid' => (int)$row->page_id ]; ApiQueryBase::addTitleInfo( $a, $t ); if ( $row->page_is_redirect ) { $a['redirect'] = true; @@ -306,7 +306,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { } if ( is_null( $resultPageSet ) ) { - $a['pageid'] = intval( $row->page_id ); + $a['pageid'] = (int)$row->page_id; ApiQueryBase::addTitleInfo( $a, Title::makeTitle( $row->page_namespace, $row->page_title ) ); if ( $row->page_is_redirect ) { $a['redirect'] = true; @@ -336,7 +336,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase { $this->params['limit'] = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; $result->addParsedLimit( $this->getModuleName(), $this->params['limit'] ); } else { - $this->params['limit'] = intval( $this->params['limit'] ); + $this->params['limit'] = (int)$this->params['limit']; $this->validateLimit( 'limit', $this->params['limit'], 1, $userMax, $botMax ); } diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index c92f037c9c..307066573c 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -510,7 +510,7 @@ abstract class ApiQueryBase extends ApiBase { * @param string $prefix Module prefix */ public static function addTitleInfo( &$arr, $title, $prefix = '' ) { - $arr[$prefix . 'ns'] = intval( $title->getNamespace() ); + $arr[$prefix . 'ns'] = (int)$title->getNamespace(); $arr[$prefix . 'title'] = $title->getPrefixedText(); } @@ -524,7 +524,7 @@ abstract class ApiQueryBase extends ApiBase { $result = $this->getResult(); ApiResult::setIndexedTagName( $data, $this->getModulePrefix() ); - return $result->addValue( [ 'query', 'pages', intval( $pageId ) ], + return $result->addValue( [ 'query', 'pages', (int)$pageId ], $this->getModuleName(), $data ); } diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index 7b447cb942..547a4e89db 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -86,7 +86,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 2 ); $op = $params['dir'] == 'descending' ? '<' : '>'; - $clfrom = intval( $cont[0] ); + $clfrom = (int)$cont[0]; $clto = $this->getDB()->addQuotes( $cont[1] ); $this->addWhere( "cl_from $op $clfrom OR " . diff --git a/includes/api/ApiQueryCategoryInfo.php b/includes/api/ApiQueryCategoryInfo.php index 02361a2708..bb48290e8b 100644 --- a/includes/api/ApiQueryCategoryInfo.php +++ b/includes/api/ApiQueryCategoryInfo.php @@ -78,10 +78,10 @@ class ApiQueryCategoryInfo extends ApiQueryBase { $catids = array_flip( $cattitles ); foreach ( $res as $row ) { $vals = []; - $vals['size'] = intval( $row->cat_pages ); + $vals['size'] = (int)$row->cat_pages; $vals['pages'] = $row->cat_pages - $row->cat_subcats - $row->cat_files; - $vals['files'] = intval( $row->cat_files ); - $vals['subcats'] = intval( $row->cat_subcats ); + $vals['files'] = (int)$row->cat_files; + $vals['subcats'] = (int)$row->cat_subcats; $vals['hidden'] = (bool)$row->cat_hidden; $fit = $this->addPageSubItems( $catids[$row->cat_title], $vals ); if ( !$fit ) { diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 37d078873e..01524344a6 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -135,7 +135,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { // Add a WHERE clause for sortkey and from $this->dieContinueUsageIf( !$this->validateHexSortkey( $cont[1] ) ); $escSortkey = $this->getDB()->addQuotes( hex2bin( $cont[1] ) ); - $from = intval( $cont[2] ); + $from = (int)$cont[2]; $op = $dir == 'newer' ? '>' : '<'; // $contWhere is used further down $contWhere = "cl_sortkey $op $escSortkey OR " . @@ -245,7 +245,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { ApiResult::META_TYPE => 'assoc', ]; if ( $fld_ids ) { - $vals['pageid'] = intval( $row->page_id ); + $vals['pageid'] = (int)$row->page_id; } if ( $fld_title ) { $title = Title::makeTitle( $row->page_namespace, $row->page_title ); diff --git a/includes/api/ApiQueryDeletedRevisions.php b/includes/api/ApiQueryDeletedRevisions.php index 9275a7c727..c15634153d 100644 --- a/includes/api/ApiQueryDeletedRevisions.php +++ b/includes/api/ApiQueryDeletedRevisions.php @@ -155,7 +155,7 @@ class ApiQueryDeletedRevisions extends ApiQueryRevisionsBase { $op = ( $dir == 'newer' ? '>' : '<' ); if ( $revCount !== 0 ) { $this->dieContinueUsageIf( count( $cont ) != 2 ); - $rev = intval( $cont[0] ); + $rev = (int)$cont[0]; $this->dieContinueUsageIf( strval( $rev ) !== $cont[0] ); $ar_id = (int)$cont[1]; $this->dieContinueUsageIf( strval( $ar_id ) !== $cont[1] ); @@ -164,7 +164,7 @@ class ApiQueryDeletedRevisions extends ApiQueryRevisionsBase { "ar_id $op= $ar_id)" ); } else { $this->dieContinueUsageIf( count( $cont ) != 4 ); - $ns = intval( $cont[0] ); + $ns = (int)$cont[0]; $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] ); $title = $db->addQuotes( $cont[1] ); $ts = $db->addQuotes( $db->timestamp( $cont[2] ) ); diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 8540190f1e..3ee75f503c 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -238,7 +238,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $op = ( $dir == 'newer' ? '>' : '<' ); if ( $mode == 'all' || $mode == 'revs' ) { $this->dieContinueUsageIf( count( $cont ) != 4 ); - $ns = intval( $cont[0] ); + $ns = (int)$cont[0]; $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] ); $title = $db->addQuotes( $cont[1] ); $ts = $db->addQuotes( $db->timestamp( $cont[2] ) ); @@ -307,10 +307,10 @@ class ApiQueryDeletedrevs extends ApiQueryBase { $rev['timestamp'] = wfTimestamp( TS_ISO_8601, $row->ar_timestamp ); if ( $fld_revid ) { - $rev['revid'] = intval( $row->ar_rev_id ); + $rev['revid'] = (int)$row->ar_rev_id; } if ( $fld_parentid && !is_null( $row->ar_parent_id ) ) { - $rev['parentid'] = intval( $row->ar_parent_id ); + $rev['parentid'] = (int)$row->ar_parent_id; } if ( $fld_user || $fld_userid ) { if ( $row->ar_deleted & Revision::DELETED_USER ) { diff --git a/includes/api/ApiQueryExtLinksUsage.php b/includes/api/ApiQueryExtLinksUsage.php index d508c55fec..4294f0ad8c 100644 --- a/includes/api/ApiQueryExtLinksUsage.php +++ b/includes/api/ApiQueryExtLinksUsage.php @@ -155,7 +155,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase { ApiResult::META_TYPE => 'assoc', ]; if ( $fld_ids ) { - $vals['pageid'] = intval( $row->page_id ); + $vals['pageid'] = (int)$row->page_id; } if ( $fld_title ) { $title = Title::makeTitle( $row->page_namespace, $row->page_title ); diff --git a/includes/api/ApiQueryIWBacklinks.php b/includes/api/ApiQueryIWBacklinks.php index 3037a7239f..b0152236ef 100644 --- a/includes/api/ApiQueryIWBacklinks.php +++ b/includes/api/ApiQueryIWBacklinks.php @@ -67,7 +67,7 @@ class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { $op = $params['dir'] == 'descending' ? '<' : '>'; $prefix = $db->addQuotes( $cont[0] ); $title = $db->addQuotes( $cont[1] ); - $from = intval( $cont[2] ); + $from = (int)$cont[2]; $this->addWhere( "iwl_prefix $op $prefix OR " . "(iwl_prefix = $prefix AND " . diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index 08c8abf163..e841788623 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -73,7 +73,7 @@ class ApiQueryIWLinks extends ApiQueryBase { $this->dieContinueUsageIf( count( $cont ) != 3 ); $op = $params['dir'] == 'descending' ? '<' : '>'; $db = $this->getDB(); - $iwlfrom = intval( $cont[0] ); + $iwlfrom = (int)$cont[0]; $iwlprefix = $db->addQuotes( $cont[1] ); $iwltitle = $db->addQuotes( $cont[2] ); $this->addWhere( diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 37a7ff33a7..333b7693b4 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -115,7 +115,7 @@ class ApiQueryImageInfo extends ApiQueryBase { $info['imagerepository'] = ''; } else { $result->addValue( - [ 'query', 'pages', intval( $pageId ) ], + [ 'query', 'pages', (int)$pageId ], 'imagerepository', '' ); // The above can't fail because it doesn't increase the result size @@ -146,7 +146,7 @@ class ApiQueryImageInfo extends ApiQueryBase { $info['badfile'] = (bool)wfIsBadImage( $title, $badFileContextTitle ); } - $fit = $result->addValue( [ 'query', 'pages' ], intval( $pageId ), $info ); + $fit = $result->addValue( [ 'query', 'pages' ], (int)$pageId, $info ); if ( !$fit ) { if ( count( $pageIds[NS_FILE] ) == 1 ) { // The user is screwed. imageinfo can't be solely @@ -312,7 +312,7 @@ class ApiQueryImageInfo extends ApiQueryBase { } if ( isset( $paramList['width'] ) && isset( $thumbParams['width'] ) ) { - if ( intval( $paramList['width'] ) != intval( $thumbParams['width'] ) ) { + if ( (int)$paramList['width'] != (int)$thumbParams['width'] ) { $this->addWarning( [ 'apiwarn-urlparamwidth', $p, $paramList['width'], $thumbParams['width'] ] ); @@ -429,9 +429,9 @@ class ApiQueryImageInfo extends ApiQueryBase { // This is shown even if the file is revdelete'd in interface // so do same here. if ( isset( $prop['size'] ) || isset( $prop['dimensions'] ) ) { - $vals['size'] = intval( $file->getSize() ); - $vals['width'] = intval( $file->getWidth() ); - $vals['height'] = intval( $file->getHeight() ); + $vals['size'] = (int)$file->getSize(); + $vals['width'] = (int)$file->getWidth(); + $vals['height'] = (int)$file->getHeight(); $pageCount = $file->pageCount(); if ( $pageCount !== false ) { @@ -510,11 +510,11 @@ class ApiQueryImageInfo extends ApiQueryBase { // T25834 - If the URLs are the same, we haven't resized it, so shouldn't give the wanted // thumbnail sizes for the thumbnail actual size if ( $mto->getUrl() !== $file->getUrl() ) { - $vals['thumbwidth'] = intval( $mto->getWidth() ); - $vals['thumbheight'] = intval( $mto->getHeight() ); + $vals['thumbwidth'] = (int)$mto->getWidth(); + $vals['thumbheight'] = (int)$mto->getHeight(); } else { - $vals['thumbwidth'] = intval( $file->getWidth() ); - $vals['thumbheight'] = intval( $file->getHeight() ); + $vals['thumbwidth'] = (int)$file->getWidth(); + $vals['thumbheight'] = (int)$file->getHeight(); } if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) { diff --git a/includes/api/ApiQueryImages.php b/includes/api/ApiQueryImages.php index 06a3ba08f0..153d1a4547 100644 --- a/includes/api/ApiQueryImages.php +++ b/includes/api/ApiQueryImages.php @@ -60,7 +60,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase { $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 2 ); $op = $params['dir'] == 'descending' ? '<' : '>'; - $ilfrom = intval( $cont[0] ); + $ilfrom = (int)$cont[0]; $ilto = $this->getDB()->addQuotes( $cont[1] ); $this->addWhere( "il_from $op $ilfrom OR " . diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 33d971b90f..3d358b96a0 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -411,8 +411,8 @@ class ApiQueryInfo extends ApiQueryBase { if ( $titleExists ) { $pageInfo['touched'] = wfTimestamp( TS_ISO_8601, $this->pageTouched[$pageid] ); - $pageInfo['lastrevid'] = intval( $this->pageLatest[$pageid] ); - $pageInfo['length'] = intval( $this->pageLength[$pageid] ); + $pageInfo['lastrevid'] = (int)$this->pageLatest[$pageid]; + $pageInfo['length'] = (int)$this->pageLength[$pageid]; if ( isset( $this->pageIsRedir[$pageid] ) && $this->pageIsRedir[$pageid] ) { $pageInfo['redirect'] = true; @@ -738,10 +738,10 @@ class ApiQueryInfo extends ApiQueryBase { foreach ( $res as $row ) { if ( MWNamespace::isTalk( $row->page_namespace ) ) { $this->talkids[MWNamespace::getSubject( $row->page_namespace )][$row->page_title] = - intval( $row->page_id ); + (int)$row->page_id; } else { $this->subjectids[MWNamespace::getTalk( $row->page_namespace )][$row->page_title] = - intval( $row->page_id ); + (int)$row->page_id; } } } diff --git a/includes/api/ApiQueryLangBacklinks.php b/includes/api/ApiQueryLangBacklinks.php index 7145d4da80..818a3f7033 100644 --- a/includes/api/ApiQueryLangBacklinks.php +++ b/includes/api/ApiQueryLangBacklinks.php @@ -67,7 +67,7 @@ class ApiQueryLangBacklinks extends ApiQueryGeneratorBase { $op = $params['dir'] == 'descending' ? '<' : '>'; $prefix = $db->addQuotes( $cont[0] ); $title = $db->addQuotes( $cont[1] ); - $from = intval( $cont[2] ); + $from = (int)$cont[2]; $this->addWhere( "ll_lang $op $prefix OR " . "(ll_lang = $prefix AND " . diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index f33a67fe96..b8c30acbef 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -70,7 +70,7 @@ class ApiQueryLangLinks extends ApiQueryBase { $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 2 ); $op = $params['dir'] == 'descending' ? '<' : '>'; - $llfrom = intval( $cont[0] ); + $llfrom = (int)$cont[0]; $lllang = $this->getDB()->addQuotes( $cont[1] ); $this->addWhere( "ll_from $op $llfrom OR " . diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index 144c7582b0..200fda8864 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -117,8 +117,8 @@ class ApiQueryLinks extends ApiQueryGeneratorBase { $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 3 ); $op = $params['dir'] == 'descending' ? '<' : '>'; - $plfrom = intval( $cont[0] ); - $plns = intval( $cont[1] ); + $plfrom = (int)$cont[0]; + $plns = (int)$cont[1]; $pltitle = $this->getDB()->addQuotes( $cont[2] ); $this->addWhere( "{$this->prefix}_from $op $plfrom OR " . diff --git a/includes/api/ApiQueryLogEvents.php b/includes/api/ApiQueryLogEvents.php index edf7002280..0934ab391d 100644 --- a/includes/api/ApiQueryLogEvents.php +++ b/includes/api/ApiQueryLogEvents.php @@ -264,7 +264,7 @@ class ApiQueryLogEvents extends ApiQueryBase { $user = $this->getUser(); if ( $this->fld_ids ) { - $vals['logid'] = intval( $row->log_id ); + $vals['logid'] = (int)$row->log_id; } if ( $this->fld_title || $this->fld_parsedcomment ) { @@ -281,8 +281,8 @@ class ApiQueryLogEvents extends ApiQueryBase { ApiQueryBase::addTitleInfo( $vals, $title ); } if ( $this->fld_ids ) { - $vals['pageid'] = intval( $row->page_id ); - $vals['logpage'] = intval( $row->log_page ); + $vals['pageid'] = (int)$row->page_id; + $vals['logpage'] = (int)$row->log_page; } if ( $this->fld_details ) { $vals['params'] = LogFormatter::newFromEntry( $logEntry )->formatParametersForApi(); @@ -305,7 +305,7 @@ class ApiQueryLogEvents extends ApiQueryBase { $vals['user'] = $row->user_name ?? $row->log_user_text; } if ( $this->fld_userid ) { - $vals['userid'] = intval( $row->log_user ); + $vals['userid'] = (int)$row->log_user; } if ( !$row->log_user ) { diff --git a/includes/api/ApiQueryPageProps.php b/includes/api/ApiQueryPageProps.php index 3258004280..61d8a9410f 100644 --- a/includes/api/ApiQueryPageProps.php +++ b/includes/api/ApiQueryPageProps.php @@ -39,7 +39,7 @@ class ApiQueryPageProps extends ApiQueryBase { $this->params = $this->extractRequestParams(); if ( $this->params['continue'] ) { - $continueValue = intval( $this->params['continue'] ); + $continueValue = (int)$this->params['continue']; $this->dieContinueUsageIf( strval( $continueValue ) !== $this->params['continue'] ); $filteredPages = []; foreach ( $pages as $id => $page ) { diff --git a/includes/api/ApiQueryPrefixSearch.php b/includes/api/ApiQueryPrefixSearch.php index 04d3f2c9fc..e5f611fa3a 100644 --- a/includes/api/ApiQueryPrefixSearch.php +++ b/includes/api/ApiQueryPrefixSearch.php @@ -74,13 +74,13 @@ class ApiQueryPrefixSearch extends ApiQueryGeneratorBase { $count = 0; foreach ( $titles as $title ) { $vals = [ - 'ns' => intval( $title->getNamespace() ), + 'ns' => (int)$title->getNamespace(), 'title' => $title->getPrefixedText(), ]; if ( $title->isSpecialPage() ) { $vals['special'] = true; } else { - $vals['pageid'] = intval( $title->getArticleID() ); + $vals['pageid'] = (int)$title->getArticleID(); } $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $vals ); ++$count; diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 779d601370..2d5c9870f2 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -159,7 +159,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $this->dieContinueUsageIf( count( $cont ) != 2 ); $db = $this->getDB(); $timestamp = $db->addQuotes( $db->timestamp( $cont[0] ) ); - $id = intval( $cont[1] ); + $id = (int)$cont[1]; $this->dieContinueUsageIf( $id != $cont[1] ); $op = $params['dir'] === 'older' ? '<' : '>'; $this->addWhere( @@ -483,7 +483,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { /* Our output data. */ $vals = []; - $type = intval( $row->rc_type ); + $type = (int)$row->rc_type; $vals['type'] = RecentChange::parseFromRCType( $type ); $anyHidden = false; @@ -501,15 +501,15 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { ApiQueryBase::addTitleInfo( $vals, $title ); } if ( $this->fld_ids ) { - $vals['pageid'] = intval( $row->rc_cur_id ); - $vals['revid'] = intval( $row->rc_this_oldid ); - $vals['old_revid'] = intval( $row->rc_last_oldid ); + $vals['pageid'] = (int)$row->rc_cur_id; + $vals['revid'] = (int)$row->rc_this_oldid; + $vals['old_revid'] = (int)$row->rc_last_oldid; } } } if ( $this->fld_ids ) { - $vals['rcid'] = intval( $row->rc_id ); + $vals['rcid'] = (int)$row->rc_id; } /* Add user data and 'anon' flag, if user is anonymous. */ @@ -542,8 +542,8 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { /* Add sizes of each revision. (Only available on 1.10+) */ if ( $this->fld_sizes ) { - $vals['oldlen'] = intval( $row->rc_old_len ); - $vals['newlen'] = intval( $row->rc_new_len ); + $vals['oldlen'] = (int)$row->rc_old_len; + $vals['newlen'] = (int)$row->rc_new_len; } /* Add the timestamp. */ @@ -588,7 +588,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { $anyHidden = true; } if ( LogEventsList::userCanBitfield( $row->rc_deleted, LogPage::DELETED_ACTION, $user ) ) { - $vals['logid'] = intval( $row->rc_logid ); + $vals['logid'] = (int)$row->rc_logid; $vals['logtype'] = $row->rc_log_type; $vals['logaction'] = $row->rc_log_action; $vals['logparams'] = LogFormatter::newFromRow( $row )->formatParametersForApi(); diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index cb2f6168ae..9301f81e9e 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -292,7 +292,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase { $ts = $db->addQuotes( $db->timestampOrNull( $params['start'] ) ); if ( $params['startid'] !== null ) { $this->addWhere( "$tsField $op $ts OR " - . "$tsField = $ts AND $idField $op= " . intval( $params['startid'] ) ); + . "$tsField = $ts AND $idField $op= " . (int)$params['startid'] ); } else { $this->addWhere( "$tsField $op= $ts" ); } @@ -302,7 +302,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase { $ts = $db->addQuotes( $db->timestampOrNull( $params['end'] ) ); if ( $params['endid'] !== null ) { $this->addWhere( "$tsField $op $ts OR " - . "$tsField = $ts AND $idField $op= " . intval( $params['endid'] ) ); + . "$tsField = $ts AND $idField $op= " . (int)$params['endid'] ); } else { $this->addWhere( "$tsField $op= $ts" ); } @@ -354,7 +354,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase { $this->addWhereFld( 'rev_id', array_keys( $revs ) ); if ( $params['continue'] !== null ) { - $this->addWhere( 'rev_id >= ' . intval( $params['continue'] ) ); + $this->addWhere( 'rev_id >= ' . (int)$params['continue'] ); } $this->addOption( 'ORDER BY', 'rev_id' ); } elseif ( $pageCount > 0 ) { @@ -374,8 +374,8 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase { if ( $params['continue'] !== null ) { $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 2 ); - $pageid = intval( $cont[0] ); - $revid = intval( $cont[1] ); + $pageid = (int)$cont[0]; + $revid = (int)$cont[1]; $this->addWhere( "rev_page > $pageid OR " . "(rev_page = $pageid AND " . @@ -403,12 +403,12 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase { // additional pages to be had. Stop here... if ( $enumRevMode ) { $this->setContinueEnumParameter( 'continue', - $row->rev_timestamp . '|' . intval( $row->rev_id ) ); + $row->rev_timestamp . '|' . (int)$row->rev_id ); } elseif ( $revCount > 0 ) { - $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) ); + $this->setContinueEnumParameter( 'continue', (int)$row->rev_id ); } else { - $this->setContinueEnumParameter( 'continue', intval( $row->rev_page ) . - '|' . intval( $row->rev_id ) ); + $this->setContinueEnumParameter( 'continue', (int)$row->rev_page . + '|' . (int)$row->rev_id ); } break; } @@ -438,12 +438,12 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase { if ( !$fit ) { if ( $enumRevMode ) { $this->setContinueEnumParameter( 'continue', - $row->rev_timestamp . '|' . intval( $row->rev_id ) ); + $row->rev_timestamp . '|' . (int)$row->rev_id ); } elseif ( $revCount > 0 ) { - $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) ); + $this->setContinueEnumParameter( 'continue', (int)$row->rev_id ); } else { - $this->setContinueEnumParameter( 'continue', intval( $row->rev_page ) . - '|' . intval( $row->rev_id ) ); + $this->setContinueEnumParameter( 'continue', (int)$row->rev_page . + '|' . (int)$row->rev_id ); } break; } diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php index 0d2aeab199..51f4d41299 100644 --- a/includes/api/ApiQueryRevisionsBase.php +++ b/includes/api/ApiQueryRevisionsBase.php @@ -229,9 +229,9 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { $anyHidden = false; if ( $this->fld_ids ) { - $vals['revid'] = intval( $revision->getId() ); + $vals['revid'] = (int)$revision->getId(); if ( !is_null( $revision->getParentId() ) ) { - $vals['parentid'] = intval( $revision->getParentId() ); + $vals['parentid'] = (int)$revision->getParentId(); } } @@ -267,7 +267,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { if ( $this->fld_size ) { try { - $vals['size'] = intval( $revision->getSize() ); + $vals['size'] = (int)$revision->getSize(); } catch ( RevisionAccessException $e ) { // Back compat: If there's no size, return 0. // @todo: Gergő says to mention T198099 as a "todo" here. @@ -410,7 +410,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { ApiResult::setArrayType( $vals, 'assoc' ); if ( $this->fld_slotsize ) { - $vals['size'] = intval( $slot->getSize() ); + $vals['size'] = (int)$slot->getSize(); } if ( $this->fld_slotsha1 ) { diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index d134edae78..96fa8a1380 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -228,7 +228,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $tz = $config->get( 'Localtimezone' ); $offset = $config->get( 'LocalTZoffset' ); $data['timezone'] = $tz; - $data['timeoffset'] = intval( $offset ); + $data['timeoffset'] = (int)$offset; $data['articlepath'] = $config->get( 'ArticlePath' ); $data['scriptpath'] = $config->get( 'ScriptPath' ); $data['script'] = $config->get( 'Script' ); @@ -287,7 +287,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { as $ns => $title ) { $data[$ns] = [ - 'id' => intval( $ns ), + 'id' => (int)$ns, 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive', ]; ApiResult::setContentValue( $data[$ns], 'name', $title ); @@ -326,7 +326,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { continue; } $item = [ - 'id' => intval( $ns ) + 'id' => (int)$ns ]; ApiResult::setContentValue( $item, 'alias', strtr( $title, '_', ' ' ) ); $data[] = $item; @@ -472,14 +472,14 @@ class ApiQuerySiteinfo extends ApiQueryBase { protected function appendStatistics( $property ) { $data = []; - $data['pages'] = intval( SiteStats::pages() ); - $data['articles'] = intval( SiteStats::articles() ); - $data['edits'] = intval( SiteStats::edits() ); - $data['images'] = intval( SiteStats::images() ); - $data['users'] = intval( SiteStats::users() ); - $data['activeusers'] = intval( SiteStats::activeUsers() ); - $data['admins'] = intval( SiteStats::numberingroup( 'sysop' ) ); - $data['jobs'] = intval( SiteStats::jobs() ); + $data['pages'] = (int)SiteStats::pages(); + $data['articles'] = (int)SiteStats::articles(); + $data['edits'] = (int)SiteStats::edits(); + $data['images'] = (int)SiteStats::images(); + $data['users'] = (int)SiteStats::users(); + $data['activeusers'] = (int)SiteStats::activeUsers(); + $data['admins'] = (int)SiteStats::numberingroup( 'sysop' ); + $data['jobs'] = (int)SiteStats::jobs(); Hooks::run( 'APIQuerySiteInfoStatisticsInfo', [ &$data ] ); diff --git a/includes/api/ApiQueryTags.php b/includes/api/ApiQueryTags.php index ed5fe8a5c3..f104383ae4 100644 --- a/includes/api/ApiQueryTags.php +++ b/includes/api/ApiQueryTags.php @@ -85,7 +85,7 @@ class ApiQueryTags extends ApiQueryBase { } if ( $fld_hitcount ) { - $tag['hitcount'] = intval( $tagHitcounts[$tagName] ); + $tag['hitcount'] = (int)$tagHitcounts[$tagName]; } $isSoftware = isset( $softwareDefinedTags[$tagName] ); diff --git a/includes/api/ApiQueryUserContribs.php b/includes/api/ApiQueryUserContribs.php index ae1be0d4ef..0ca0b20a2e 100644 --- a/includes/api/ApiQueryUserContribs.php +++ b/includes/api/ApiQueryUserContribs.php @@ -523,12 +523,12 @@ class ApiQueryUserContribs extends ApiQueryBase { $anyHidden = true; } if ( $this->fld_ids ) { - $vals['pageid'] = intval( $row->rev_page ); - $vals['revid'] = intval( $row->rev_id ); - // $vals['textid'] = intval( $row->rev_text_id ); // todo: Should this field be exposed? + $vals['pageid'] = (int)$row->rev_page; + $vals['revid'] = (int)$row->rev_id; + // $vals['textid'] = (int)$row->rev_text_id; // todo: Should this field be exposed? if ( !is_null( $row->rev_parent_id ) ) { - $vals['parentid'] = intval( $row->rev_parent_id ); + $vals['parentid'] = (int)$row->rev_parent_id; } } @@ -577,7 +577,7 @@ class ApiQueryUserContribs extends ApiQueryBase { } if ( $this->fld_size && !is_null( $row->rev_len ) ) { - $vals['size'] = intval( $row->rev_len ); + $vals['size'] = (int)$row->rev_len; } if ( $this->fld_sizediff @@ -585,7 +585,7 @@ class ApiQueryUserContribs extends ApiQueryBase { && !is_null( $row->rev_parent_id ) ) { $parentLen = $this->parentLens[$row->rev_parent_id] ?? 0; - $vals['sizediff'] = intval( $row->rev_len - $parentLen ); + $vals['sizediff'] = (int)$row->rev_len - $parentLen; } if ( $this->fld_tags ) { diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index 44e2703a8d..a38d877d99 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -119,7 +119,7 @@ class ApiQueryUserInfo extends ApiQueryBase { protected function getCurrentUserInfo() { $user = $this->getUser(); $vals = []; - $vals['id'] = intval( $user->getId() ); + $vals['id'] = (int)$user->getId(); $vals['name'] = $user->getName(); if ( $user->isAnon() ) { @@ -189,7 +189,7 @@ class ApiQueryUserInfo extends ApiQueryBase { if ( isset( $this->prop['editcount'] ) ) { // use intval to prevent null if a non-logged-in user calls // api.php?format=jsonfm&action=query&meta=userinfo&uiprop=editcount - $vals['editcount'] = intval( $user->getEditCount() ); + $vals['editcount'] = (int)$user->getEditCount(); } if ( isset( $this->prop['ratelimits'] ) ) { @@ -284,8 +284,8 @@ class ApiQueryUserInfo extends ApiQueryBase { foreach ( $this->getConfig()->get( 'RateLimits' ) as $action => $limits ) { foreach ( $categories as $cat ) { if ( isset( $limits[$cat] ) && !is_null( $limits[$cat] ) ) { - $retval[$action][$cat]['hits'] = intval( $limits[$cat][0] ); - $retval[$action][$cat]['seconds'] = intval( $limits[$cat][1] ); + $retval[$action][$cat]['hits'] = (int)$limits[$cat][0]; + $retval[$action][$cat]['seconds'] = (int)$limits[$cat][1]; } } } diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index 95fbd3de6c..236f6e0908 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -195,9 +195,9 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { } } else { if ( $params['allrev'] ) { - $ids[] = intval( $recentChangeInfo['rc_this_oldid'] ); + $ids[] = (int)$recentChangeInfo['rc_this_oldid']; } else { - $ids[] = intval( $recentChangeInfo['rc_cur_id'] ); + $ids[] = (int)$recentChangeInfo['rc_cur_id']; } } } @@ -272,7 +272,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { /* Our output data. */ $vals = []; - $type = intval( $recentChangeInfo['rc_type'] ); + $type = (int)$recentChangeInfo['rc_type']; $vals['type'] = RecentChange::parseFromRCType( $type ); $anyHidden = false; @@ -294,9 +294,9 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { ApiQueryBase::addTitleInfo( $vals, $title ); } if ( $this->fld_ids ) { - $vals['pageid'] = intval( $recentChangeInfo['rc_cur_id'] ); - $vals['revid'] = intval( $recentChangeInfo['rc_this_oldid'] ); - $vals['old_revid'] = intval( $recentChangeInfo['rc_last_oldid'] ); + $vals['pageid'] = (int)$recentChangeInfo['rc_cur_id']; + $vals['revid'] = (int)$recentChangeInfo['rc_this_oldid']; + $vals['old_revid'] = (int)$recentChangeInfo['rc_last_oldid']; } } } @@ -337,8 +337,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { /* Add sizes of each revision. (Only available on 1.10+) */ if ( $this->fld_sizes ) { - $vals['oldlen'] = intval( $recentChangeInfo['rc_old_len'] ); - $vals['newlen'] = intval( $recentChangeInfo['rc_new_len'] ); + $vals['oldlen'] = (int)$recentChangeInfo['rc_old_len']; + $vals['newlen'] = (int)$recentChangeInfo['rc_new_len']; } /* Add the timestamp. */ @@ -391,7 +391,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { LogPage::DELETED_ACTION, $user ) ) { - $vals['logid'] = intval( $recentChangeInfo['rc_logid'] ); + $vals['logid'] = (int)$recentChangeInfo['rc_logid']; $vals['logtype'] = $recentChangeInfo['rc_log_type']; $vals['logaction'] = $recentChangeInfo['rc_log_action']; $vals['logparams'] = LogFormatter::newFromRow( $recentChangeInfo )->formatParametersForApi(); diff --git a/includes/api/ApiQueryWatchlistRaw.php b/includes/api/ApiQueryWatchlistRaw.php index 0adbfdbfd3..743e974bd0 100644 --- a/includes/api/ApiQueryWatchlistRaw.php +++ b/includes/api/ApiQueryWatchlistRaw.php @@ -73,7 +73,7 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { if ( isset( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 2 ); - $ns = intval( $cont[0] ); + $ns = (int)$cont[0]; $this->dieContinueUsageIf( strval( $ns ) !== $cont[0] ); $title = $cont[1]; $options['startFrom'] = new TitleValue( $ns, $title ); diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php index 18aa6daa66..7c313d5cb7 100644 --- a/includes/api/ApiRollback.php +++ b/includes/api/ApiRollback.php @@ -85,13 +85,13 @@ class ApiRollback extends ApiBase { $info = [ 'title' => $titleObj->getPrefixedText(), - 'pageid' => intval( $details['current']->getPage() ), + 'pageid' => (int)$details['current']->getPage(), 'summary' => $details['summary'], - 'revid' => intval( $details['newid'] ), + 'revid' => (int)$details['newid'], // The revision being reverted (previously the current revision of the page) - 'old_revid' => intval( $details['current']->getID() ), + 'old_revid' => (int)$details['current']->getID(), // The revision being restored (the last revision before revision(s) by the reverted user) - 'last_revid' => intval( $details['target']->getID() ) + 'last_revid' => (int)$details['target']->getID() ]; $this->getResult()->addValue( null, $this->getModuleName(), $info ); diff --git a/includes/api/ApiSetNotificationTimestamp.php b/includes/api/ApiSetNotificationTimestamp.php index 41c207bd9a..c9ebfa88cc 100644 --- a/includes/api/ApiSetNotificationTimestamp.php +++ b/includes/api/ApiSetNotificationTimestamp.php @@ -161,7 +161,7 @@ class ApiSetNotificationTimestamp extends ApiBase { $ns = $title->getNamespace(); $dbkey = $title->getDBkey(); $r = [ - 'ns' => intval( $ns ), + 'ns' => (int)$ns, 'title' => $title->getPrefixedText(), ]; if ( !$title->exists() ) { diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index 840ef1bc83..07a6aae9eb 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -84,8 +84,8 @@ class ApiUndelete extends ApiBase { $this->setWatch( $params['watchlist'], $titleObj ); $info['title'] = $titleObj->getPrefixedText(); - $info['revisions'] = intval( $retval[0] ); - $info['fileversions'] = intval( $retval[1] ); + $info['revisions'] = (int)$retval[0]; + $info['fileversions'] = (int)$retval[1]; $info['reason'] = $retval[2]; $this->getResult()->addValue( null, $this->getModuleName(), $info ); }