jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/357839 )
Change subject: Use short array syntax - api / backend ...................................................................... Use short array syntax - api / backend Done by phpcbf over composer fix Change-Id: I9931f60a11cef61fdf82c8226de6ffb6b24ca9f6 --- M api/ApiCodeDiff.php M api/ApiCodeUpdate.php M api/ApiQueryCodeComments.php M api/ApiQueryCodePaths.php M api/ApiQueryCodeRevisions.php M api/ApiQueryCodeTags.php M api/ApiRevisionUpdate.php M backend/CodeComment.php M backend/CodeCommentLinker.php M backend/CodeRepository.php M backend/CodeRevision.php M backend/CodeSignoff.php M backend/DiffHighlighter.php M backend/RepoStats.php M backend/Subversion.php 15 files changed, 380 insertions(+), 380 deletions(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/api/ApiCodeDiff.php b/api/ApiCodeDiff.php index 46a5c42..451db8a 100644 --- a/api/ApiCodeDiff.php +++ b/api/ApiCodeDiff.php @@ -23,7 +23,7 @@ global $wgCodeReviewMaxDiffSize; // Before doing anything at all, let's check permissions - if ( is_callable( array( $this, 'checkUserRightsAny' ) ) ) { + if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) { $this->checkUserRightsAny( 'codereview-use' ); } else { if ( !$this->getUser()->isAllowed( 'codereview-use' ) ) { @@ -34,8 +34,8 @@ $repo = CodeRepository::newFromName( $params['repo'] ); if ( !$repo ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { - $this->dieWithError( array( 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ) ); + if ( is_callable( [ $this, 'dieWithError' ] ) ) { + $this->dieWithError( [ 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ] ); } else { $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); } @@ -44,8 +44,8 @@ $lastStoredRev = $repo->getLastStoredRev(); if ( $params['rev'] > $lastStoredRev ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { - $this->dieWithError( array( 'apierror-nosuchrevid', $params['rev'] ) ); + if ( is_callable( [ $this, 'dieWithError' ] ) ) { + $this->dieWithError( [ 'apierror-nosuchrevid', $params['rev'] ] ); } else { $this->dieUsage( "There is no revision with ID {$params['rev']}", 'nosuchrev' ); } @@ -63,35 +63,35 @@ $html = $hilite->render( $diff ); } - $data = array( + $data = [ 'repo' => $params['repo'], 'id' => $params['rev'], 'diff' => $html - ); + ]; $this->getResult()->addValue( 'code', 'rev', $data ); } public function getAllowedParams() { - return array( - 'repo' => array( + return [ + 'repo' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, - ), - 'rev' => array( + ], + 'rev' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_REQUIRED => true, - ) - ); + ] + ]; } /** * @see ApiBase::getExamplesMessages() */ protected function getExamplesMessages() { - return array( + return [ 'action=codediff&repo=MediaWiki&rev=42080' => 'apihelp-codediff-example-1', - ); + ]; } } diff --git a/api/ApiCodeUpdate.php b/api/ApiCodeUpdate.php index 51500ed..4a6a0a6 100644 --- a/api/ApiCodeUpdate.php +++ b/api/ApiCodeUpdate.php @@ -22,7 +22,7 @@ public function execute() { // Before doing anything at all, let's check permissions - if ( is_callable( array( $this, 'checkUserRightsAny' ) ) ) { + if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) { $this->checkUserRightsAny( 'codereview-use' ); } else { if ( !$this->getUser()->isAllowed( 'codereview-use' ) ) { @@ -33,8 +33,8 @@ $repo = CodeRepository::newFromName( $params['repo'] ); if ( !$repo ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { - $this->dieWithError( array( 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ) ); + if ( is_callable( [ $this, 'dieWithError' ] ) ) { + $this->dieWithError( [ 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ] ); } else { $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); } @@ -46,7 +46,7 @@ if ( $lastStoredRev >= $params['rev'] ) { // Nothing to do, we're up to date. // Return an empty result - $this->getResult()->addValue( null, $this->getModuleName(), array() ); + $this->getResult()->addValue( null, $this->getModuleName(), [] ); return; } @@ -58,17 +58,17 @@ ApiBase::dieDebug( __METHOD__, 'Something awry...' ); } - $result = array(); - $revs = array(); + $result = []; + $revs = []; foreach ( $log as $data ) { $codeRev = CodeRevision::newFromSvn( $repo, $data ); $codeRev->save(); - $result[] = array( + $result[] = [ 'id' => $codeRev->getId(), 'author' => $codeRev->getAuthor(), 'timestamp' => wfTimestamp( TS_ISO_8601, $codeRev->getTimestamp() ), 'message' => $codeRev->getMessage() - ); + ]; $revs[] = $codeRev; } // Cache the diffs if there are a only a few. @@ -92,26 +92,26 @@ } public function getAllowedParams() { - return array( - 'repo' => array( + return [ + 'repo' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, - ), - 'rev' => array( + ], + 'rev' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_REQUIRED => true, - ) - ); + ] + ]; } /** * @see ApiBase::getExamplesMessages() */ protected function getExamplesMessages() { - return array( + return [ 'action=codeupdate&repo=MediaWiki&rev=42080' => 'apihelp-codeupdate-example-1', - ); + ]; } } diff --git a/api/ApiQueryCodeComments.php b/api/ApiQueryCodeComments.php index 900d9ee..858f57e 100644 --- a/api/ApiQueryCodeComments.php +++ b/api/ApiQueryCodeComments.php @@ -30,7 +30,7 @@ public function execute() { // Before doing anything at all, let's check permissions - if ( is_callable( array( $this, 'checkUserRightsAny' ) ) ) { + if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) { $this->checkUserRightsAny( 'codereview-use' ); } else { if ( !$this->getUser()->isAllowed( 'codereview-use' ) ) { @@ -53,8 +53,8 @@ $listview = new CodeCommentsListView( $params['repo'] ); if ( is_null( $listview->getRepo() ) ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { - $this->dieWithError( array( 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ) ); + if ( is_callable( [ $this, 'dieWithError' ] ) ) { + $this->dieWithError( [ 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ] ); } else { $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); } @@ -70,7 +70,7 @@ $pager->doQuery(); $comments = $pager->getResult(); - $data = array(); + $data = []; $count = 0; $lastTimestamp = 0; @@ -93,7 +93,7 @@ } private function formatRow( $row ) { - $item = array(); + $item = []; if ( isset( $this->props['revid'] ) ) { $item['revid'] = $row->cc_rev_id; } @@ -113,45 +113,45 @@ } public function getAllowedParams() { - return array( - 'repo' => array( + return [ + 'repo' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, - ), - 'limit' => array( + ], + 'limit' => [ ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 - ), - 'start' => array( + ], + 'start' => [ ApiBase::PARAM_TYPE => 'timestamp' - ), - 'prop' => array( + ], + 'prop' => [ ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_DFLT => 'timestamp|user|status|revid', - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_TYPE => [ 'timestamp', 'user', 'status', 'text', 'revid', 'revision', - ), - ), - ); + ], + ], + ]; } /** * @see ApiBase::getExamplesMessages() */ protected function getExamplesMessages() { - return array( + return [ 'action=query&list=codecomments&ccrepo=MediaWiki' => 'apihelp-query+codecomments-example-1', 'action=query&list=codecomments&ccrepo=MediaWiki&ccprop=timestamp|user|status|text' => 'apihelp-query+codecomments-example-2', - ); + ]; } } diff --git a/api/ApiQueryCodePaths.php b/api/ApiQueryCodePaths.php index 15a46a9..4d70df5 100644 --- a/api/ApiQueryCodePaths.php +++ b/api/ApiQueryCodePaths.php @@ -26,7 +26,7 @@ public function execute() { // Before doing anything at all, let's check permissions - if ( is_callable( array( $this, 'checkUserRightsAny' ) ) ) { + if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) { $this->checkUserRightsAny( 'codereview-use' ); } else { if ( !$this->getUser()->isAllowed( 'codereview-use' ) ) { @@ -37,8 +37,8 @@ $repo = CodeRepository::newFromName( $params['repo'] ); if ( !$repo instanceof CodeRepository ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { - $this->dieWithError( array( 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ) ); + if ( is_callable( [ $this, 'dieWithError' ] ) ) { + $this->dieWithError( [ 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ] ); } else { $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); } @@ -46,7 +46,7 @@ $this->addTables( 'code_paths' ); $this->addFields( 'DISTINCT cp_path' ); - $this->addWhere( array( 'cp_repo_id' => $repo->getId() ) ); + $this->addWhere( [ 'cp_repo_id' => $repo->getId() ] ); $db = $this->getDB(); $this->addWhere( 'cp_path ' . $db->buildLike( $params['path'], $db->anyString() ) ); @@ -58,10 +58,10 @@ $result = $this->getResult(); - $data = array(); + $data = []; foreach ( $res as $row ) { - $item = array(); + $item = []; ApiResult::setContentValue( $item, 'path', $row->cp_path ); $data[] = $item; } @@ -71,25 +71,25 @@ } public function getAllowedParams() { - return array( - 'repo' => array( + return [ + 'repo' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, - ), - 'path' => array( + ], + 'path' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, - ), - ); + ], + ]; } /** * @see ApiBase::getExamplesMessages() */ protected function getExamplesMessages() { - return array( + return [ 'action=query&list=codepaths&cprepo=MediaWiki&cppath=/trunk/phase3' => 'apihelp-query+codepaths-example-1', - ); + ]; } } diff --git a/api/ApiQueryCodeRevisions.php b/api/ApiQueryCodeRevisions.php index 022c44a..e9d3703 100644 --- a/api/ApiQueryCodeRevisions.php +++ b/api/ApiQueryCodeRevisions.php @@ -31,7 +31,7 @@ public function execute() { $this->getMain()->setCacheMode( 'anon-public-user-private' ); // Before doing anything at all, let's check permissions - if ( is_callable( array( $this, 'checkUserRightsAny' ) ) ) { + if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) { $this->checkUserRightsAny( 'codereview-use' ); } else { if ( !$this->getUser()->isAllowed( 'codereview-use' ) ) { @@ -45,14 +45,14 @@ $repo = CodeRepository::newFromName( $params['repo'] ); if ( !$repo ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { - $this->dieWithError( array( 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ) ); + if ( is_callable( [ $this, 'dieWithError' ] ) ) { + $this->dieWithError( [ 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ] ); } else { $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); } } - $data = array(); + $data = []; $listview = new CodeRevisionListView( $repo ); if ( isset( $params['path'] ) && $params['path'] !== '' ) { @@ -113,7 +113,7 @@ * @return array */ private function formatRow( $row, $repo, $result ) { - $item = array(); + $item = []; if ( isset( $this->props['revid'] ) ) { $item['revid'] = intval( $row->cr_id ); } @@ -164,14 +164,14 @@ * @return array */ protected function addReferenced( $rev ) { - $items = array(); + $items = []; foreach ( $rev->getFollowedUpRevisions() as $ref ) { - $refItem = array( + $refItem = [ 'revid' => $ref->cr_id, 'status' => $ref->cr_status, 'timestamp' => wfTimestamp( TS_ISO_8601, $ref->cr_timestamp ), 'author' => $ref->cr_author , - ); + ]; ApiResult::setContentValue( $refItem, 'message', $ref->cr_message ); $items[] = $refItem; @@ -180,31 +180,31 @@ } public function getAllowedParams() { - return array( - 'repo' => array( + return [ + 'repo' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, - ), - 'limit' => array( + ], + 'limit' => [ ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 - ), + ], 'path' => null, - 'start' => array( + 'start' => [ ApiBase::PARAM_TYPE => 'integer' - ), - 'revs' => array( + ], + 'revs' => [ ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_MIN => 1, - ), - 'prop' => array( + ], + 'prop' => [ ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_DFLT => 'revid|status|author|timestamp', - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_TYPE => [ 'revid', 'status', 'commentcount', @@ -215,20 +215,20 @@ 'timestamp', 'followups', 'followedup', - ), - ), - ); + ], + ], + ]; } /** * @see ApiBase::getExamplesMessages() */ protected function getExamplesMessages() { - return array( + return [ 'action=query&list=coderevisions&crrepo=MediaWiki' => 'apihelp-query+coderevisions-example-1', 'action=query&list=coderevisions&crrepo=MediaWiki&crprop=revid|author|status|timestamp|tags' => 'apihelp-query+coderevisions-example-2', - ); + ]; } } diff --git a/api/ApiQueryCodeTags.php b/api/ApiQueryCodeTags.php index a86dd00..16eebeb 100644 --- a/api/ApiQueryCodeTags.php +++ b/api/ApiQueryCodeTags.php @@ -26,7 +26,7 @@ public function execute() { // Before doing anything at all, let's check permissions - if ( is_callable( array( $this, 'checkUserRightsAny' ) ) ) { + if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) { $this->checkUserRightsAny( 'codereview-use' ); } else { if ( !$this->getUser()->isAllowed( 'codereview-use' ) ) { @@ -37,19 +37,19 @@ $repo = CodeRepository::newFromName( $params['repo'] ); if ( !$repo instanceof CodeRepository ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { - $this->dieWithError( array( 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ) ); + if ( is_callable( [ $this, 'dieWithError' ] ) ) { + $this->dieWithError( [ 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ] ); } else { $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); } } - $data = array(); + $data = []; foreach ( $repo->getTagList( true ) as $tag => $count ) { - $data[] = array( + $data[] = [ 'name' => $tag, 'revcount' => $count, - ); + ]; } $result = $this->getResult(); @@ -58,21 +58,21 @@ } public function getAllowedParams() { - return array( - 'repo' => array( + return [ + 'repo' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, - ), - ); + ], + ]; } /** * @see ApiBase::getExamplesMessages() */ protected function getExamplesMessages() { - return array( + return [ 'action=query&list=codetags&ctrepo=MediaWiki' => 'apihelp-query+codetags-example-1', - ); + ]; } } diff --git a/api/ApiRevisionUpdate.php b/api/ApiRevisionUpdate.php index b868ce1..b4e9c12 100644 --- a/api/ApiRevisionUpdate.php +++ b/api/ApiRevisionUpdate.php @@ -26,7 +26,7 @@ public function execute() { $user = $this->getUser(); // Before doing anything at all, let's check permissions - if ( is_callable( array( $this, 'checkUserRightsAny' ) ) ) { + if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) { $this->checkUserRightsAny( 'codereview-use' ); } else { if ( !$user->isAllowed( 'codereview-use' ) ) { @@ -37,7 +37,7 @@ $params = $this->extractRequestParams(); if ( $params['comment'] ) { - if ( is_callable( array( $this, 'checkUserRightsAny' ) ) ) { + if ( is_callable( [ $this, 'checkUserRightsAny' ] ) ) { $this->checkUserRightsAny( 'codereview-post-comment' ); } else { if ( !$user->isAllowed( 'codereview-post-comment' ) ) { @@ -53,7 +53,7 @@ && isset( $params['patchline'] ) ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { + if ( is_callable( [ $this, 'dieWithError' ] ) ) { $this->dieWithError( 'apierror-codereview-inlinecommentingdisabled', 'inlinecommentingdisabled' ); } else { @@ -67,9 +67,9 @@ $repo = CodeRepository::newFromName( $params['repo'] ); if ( !$repo ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { + if ( is_callable( [ $this, 'dieWithError' ] ) ) { $this->dieWithError( - array( 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ) ); + [ 'apierror-invalidrepo', wfEscapeWikiText( $params['repo'] ) ] ); } else { $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); } @@ -78,8 +78,8 @@ $rev = $repo->getRevision( $params['rev'] ); if ( !$rev ) { - if ( is_callable( array( $this, 'dieWithError' ) ) ) { - $this->dieWithError( array( 'apierror-nosuchrevid', $params['rev'] ) ); + if ( is_callable( [ $this, 'dieWithError' ] ) ) { + $this->dieWithError( [ 'apierror-nosuchrevid', $params['rev'] ] ); } else { $this->dieUsage( "There is no revision with ID {$params['rev']}", 'nosuchrev' ); } @@ -102,7 +102,7 @@ ); // Forge a response object - $r = array( 'result' => 'Success' ); + $r = [ 'result' => 'Success' ]; if ( $commentID !== 0 ) { // id inserted @@ -130,65 +130,65 @@ public function getAllowedParams() { $flags = CodeRevision::getPossibleFlags(); - return array( - 'repo' => array( + return [ + 'repo' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, - ), - 'rev' => array( + ], + 'rev' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_REQUIRED => true, - ), + ], 'comment' => null, - 'status' => array( + 'status' => [ ApiBase::PARAM_TYPE => CodeRevision::getPossibleStates() - ), - 'addtags' => array( + ], + 'addtags' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_ISMULTI => true, - ), - 'removetags' => array( + ], + 'removetags' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_ISMULTI => true, - ), - 'addflags' => array( + ], + 'addflags' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => $flags - ), - 'removeflags' => array( + ], + 'removeflags' => [ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => $flags - ), - 'addreferences' => array( + ], + 'addreferences' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_ISMULTI => true, - ), - 'removereferences' => array( + ], + 'removereferences' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_ISMULTI => true, - ), - 'addreferenced' => array( + ], + 'addreferenced' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_ISMULTI => true, - ), - 'removereferenced' => array( + ], + 'removereferenced' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_ISMULTI => true, - ), + ], 'token' => null, - ); + ]; } /** * @see ApiBase::getExamplesMessages() */ protected function getExamplesMessages() { - return array( + return [ 'action=coderevisionupdate&repo=MediaWiki&rev=1&status=fixme' => 'apihelp-coderevisionupdate-example-1', - ); + ]; } } diff --git a/backend/CodeComment.php b/backend/CodeComment.php index eb2aaf9..5517e44 100644 --- a/backend/CodeComment.php +++ b/backend/CodeComment.php @@ -38,7 +38,7 @@ $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'code_comment', - array( + [ # fields needed to build a CodeRevision 'cc_rev_id', 'cc_repo_id', @@ -51,8 +51,8 @@ 'cc_patch_line', 'cc_timestamp', 'cc_sortkey' - ), - array( 'cc_id' => (int) $cc_id ), + ], + [ 'cc_id' => (int) $cc_id ], __METHOD__ ); return self::newFromRow( $rev, $row ); diff --git a/backend/CodeCommentLinker.php b/backend/CodeCommentLinker.php index 8909355..a33d3d0 100644 --- a/backend/CodeCommentLinker.php +++ b/backend/CodeCommentLinker.php @@ -24,11 +24,11 @@ $text = preg_replace_callback( '/(^|[^\w[])(' . wfUrlProtocolsWithoutProtRel() . ')(' . $EXT_LINK_URL_CLASS . '+)/', - array( $this, 'generalLink' ), $text ); + [ $this, 'generalLink' ], $text ); $text = preg_replace_callback( '/\br(\d+)\b/', - array( $this, 'messageRevLink' ), $text ); + [ $this, 'messageRevLink' ], $text ); $text = preg_replace_callback( CodeRevision::BugReference, - array( $this, 'messageBugLink' ), $text ); + [ $this, 'messageBugLink' ], $text ); return $text; } diff --git a/backend/CodeRepository.php b/backend/CodeRepository.php index d0d20d8..567c6b7 100644 --- a/backend/CodeRepository.php +++ b/backend/CodeRepository.php @@ -14,13 +14,13 @@ * Local cache of Wiki user -> SVN user mappings * @var array */ - private static $userLinks = array(); + private static $userLinks = []; /** * Sort of the same, but looking it up for the other direction * @var array */ - private static $authorLinks = array(); + private static $authorLinks = []; /** * Various data about the repo @@ -51,14 +51,14 @@ $dbw = wfGetDB( DB_SLAVE ); $row = $dbw->selectRow( 'code_repo', - array( + [ 'repo_id', 'repo_name', 'repo_path', 'repo_viewvc', 'repo_bugzilla' - ), - array( 'repo_name' => $name ), + ], + [ 'repo_name' => $name ], __METHOD__ ); if ( $row ) { @@ -76,13 +76,13 @@ $dbw = wfGetDB( DB_SLAVE ); $row = $dbw->selectRow( 'code_repo', - array( + [ 'repo_id', 'repo_name', 'repo_path', 'repo_viewvc', - 'repo_bugzilla' ), - array( 'repo_id' => intval( $id ) ), + 'repo_bugzilla' ], + [ 'repo_id' => intval( $id ) ], __METHOD__ ); if ( $row ) { @@ -111,9 +111,9 @@ */ static function getRepoList() { $dbr = wfGetDB( DB_SLAVE ); - $options = array( 'ORDER BY' => 'repo_name' ); - $res = $dbr->select( 'code_repo', '*', array(), __METHOD__, $options ); - $repos = array(); + $options = [ 'ORDER BY' => 'repo_name' ]; + $res = $dbr->select( 'code_repo', '*', [], __METHOD__, $options ); + $repos = []; foreach ( $res as $row ) { $repos[] = self::newFromRow( $row ); } @@ -177,7 +177,7 @@ $row = $dbr->selectField( 'code_rev', 'MAX(cr_id)', - array( 'cr_repo_id' => $this->getId() ), + [ 'cr_repo_id' => $this->getId() ], __METHOD__ ); return intval( $row ); @@ -196,22 +196,22 @@ $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'code_rev', - array( 'cr_author', 'MAX(cr_timestamp) AS time' ), - array( 'cr_repo_id' => $this->getId() ), + [ 'cr_author', 'MAX(cr_timestamp) AS time' ], + [ 'cr_repo_id' => $this->getId() ], __METHOD__, - array( + [ 'GROUP BY' => 'cr_author', 'ORDER BY' => 'cr_author', 'LIMIT' => 500 - ) + ] ); - $authors = array(); + $authors = []; foreach ( $res as $row ) { if ( $row->cr_author !== null ) { - $authors[] = array( + $authors[] = [ 'author' => $row->cr_author, 'lastcommit' => $row->time - ); + ]; } } $wgMemc->set( $key, $authors, 3600 * 24 ); @@ -240,16 +240,16 @@ $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'code_tags', - array( 'ct_tag', 'COUNT(*) AS revs' ), - array( 'ct_repo_id' => $this->getId() ), + [ 'ct_tag', 'COUNT(*) AS revs' ], + [ 'ct_repo_id' => $this->getId() ], __METHOD__, - array( + [ 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'revs DESC', 'LIMIT' => 500 - ) + ] ); - $tags = array(); + $tags = []; foreach ( $res as $row ) { $tags[$row->ct_tag] = $row->revs; } @@ -271,10 +271,10 @@ $row = $dbr->selectRow( 'code_rev', '*', - array( + [ 'cr_id' => $id, 'cr_repo_id' => $this->getId(), - ), + ], __METHOD__ ); if ( !$row ) { @@ -371,8 +371,8 @@ $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'code_rev', - array( 'cr_diff', 'cr_flags' ), - array( 'cr_repo_id' => $this->id, 'cr_id' => $rev, 'cr_diff IS NOT NULL' ), + [ 'cr_diff', 'cr_flags' ], + [ 'cr_repo_id' => $this->id, 'cr_id' => $rev, 'cr_diff IS NOT NULL' ], __METHOD__ ); if ( $row ) { @@ -418,8 +418,8 @@ $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'code_rev', - array( 'cr_diff' => $storedData, 'cr_flags' => $flags ), - array( 'cr_repo_id' => $this->id, 'cr_id' => $rev ), + [ 'cr_diff' => $storedData, 'cr_flags' => $flags ], + [ 'cr_repo_id' => $this->id, 'cr_id' => $rev ], __METHOD__ ); } @@ -450,8 +450,8 @@ $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'code_rev', - array( 'cr_diff' => $storedData, 'cr_flags' => $flags ), - array( 'cr_repo_id' => $this->id, 'cr_id' => $codeRev->getId() ), + [ 'cr_diff' => $storedData, 'cr_flags' => $flags ], + [ 'cr_repo_id' => $this->id, 'cr_id' => $codeRev->getId() ], __METHOD__ ); } @@ -483,27 +483,27 @@ // Skip existing rows. $dbw->insert( 'code_authors', - array( + [ 'ca_repo_id' => $this->getId(), 'ca_author' => $author, 'ca_user' => $userId, 'ca_user_text' => $user->getName() - ), + ], __METHOD__, - array( 'IGNORE' ) + [ 'IGNORE' ] ); // If the last query already found a row, then update it. if ( !$dbw->affectedRows() ) { $dbw->update( 'code_authors', - array( + [ 'ca_user' => $userId, 'ca_user_text' => $user->getName() - ), - array( + ], + [ 'ca_repo_id' => $this->getId(), 'ca_author' => $author, - ), + ], __METHOD__ ); } @@ -520,10 +520,10 @@ $dbw = wfGetDB( DB_MASTER ); $dbw->delete( 'code_authors', - array( + [ 'ca_repo_id' => $this->getId(), 'ca_author' => $author, - ), + ], __METHOD__ ); self::$userLinks[$author] = false; @@ -546,10 +546,10 @@ $wikiUser = $dbr->selectField( 'code_authors', 'ca_user_text', - array( + [ 'ca_repo_id' => $this->getId(), 'ca_author' => $author, - ), + ], __METHOD__ ); $user = null; @@ -580,10 +580,10 @@ $res = $dbr->selectField( 'code_authors', 'ca_author', - array( + [ 'ca_repo_id' => $this->getId(), 'ca_user_text' => $name, - ), + ], __METHOD__ ); return self::$authorLinks[$name] = $res; diff --git a/backend/CodeRevision.php b/backend/CodeRevision.php index 6947069..1424c0d 100644 --- a/backend/CodeRevision.php +++ b/backend/CodeRevision.php @@ -47,10 +47,10 @@ // make sure $common is the shortest path if ( count( $compare ) < count( $common ) ) { - list( $compare, $common ) = array( $common, $compare ); + list( $compare, $common ) = [ $common, $compare ]; } - $tmp = array(); + $tmp = []; foreach ( $common as $k => $v ) { if ( $v == $compare[$k] ) { $tmp[] = $v; @@ -84,7 +84,7 @@ if ( isset( $wgCodeReviewAutoTagPath[$repo->getName()] ) ) { foreach ( $wgCodeReviewAutoTagPath[$repo->getName()] as $path => $tags ) { if ( preg_match( $path, $rev->commonPath ) ) { - $rev->changeTags( $tags, array() ); + $rev->changeTags( $tags, [] ); break; } } @@ -97,8 +97,8 @@ * @param array $paths * @return array */ - public static function getPathFragments( $paths = array() ) { - $allPaths = array(); + public static function getPathFragments( $paths = [] ) { + $allPaths = []; foreach ( $paths as $path ) { $currentPath = '/'; @@ -115,10 +115,10 @@ $action = 'N'; } - $allPaths[] = array( + $allPaths[] = [ 'path' => $currentPath, 'action' => $action - ); + ]; } } @@ -272,7 +272,7 @@ * @return array */ public static function getPossibleStateMessageKeys() { - return array_map( array( 'self', 'makeStateMessageKey' ), self::getPossibleStates() ); + return array_map( [ 'self', 'makeStateMessageKey' ], self::getPossibleStates() ); } /** @@ -339,7 +339,7 @@ $this->oldStatus = $dbw->selectField( 'code_rev', 'cr_status', - array( 'cr_repo_id' => $this->repoId, 'cr_id' => $this->id ), + [ 'cr_repo_id' => $this->repoId, 'cr_id' => $this->id ], __METHOD__ ); if ( $this->oldStatus === $status ) { @@ -349,18 +349,18 @@ $this->status = $status; $dbw->update( 'code_rev', - array( 'cr_status' => $status ), - array( + [ 'cr_status' => $status ], + [ 'cr_repo_id' => $this->repoId, 'cr_id' => $this->id - ), + ], __METHOD__ ); // Log this change if ( $user && $user->getId() ) { $dbw->insert( 'code_prop_changes', - array( + [ 'cpc_repo_id' => $this->getRepoId(), 'cpc_rev_id' => $this->getId(), 'cpc_attrib' => 'status', @@ -369,7 +369,7 @@ 'cpc_timestamp' => $dbw->timestamp(), 'cpc_user' => $user->getId(), 'cpc_user_text' => $user->getName() - ), + ], __METHOD__ ); } @@ -390,7 +390,7 @@ * @return void */ protected static function insertChunks( - $db, $table, $data, $method = __METHOD__, $options = array() + $db, $table, $data, $method = __METHOD__, $options = [] ) { $chunkSize = 100; for ( $i = 0, $count = count( $data ); $i < $count; $i += $chunkSize ) { @@ -412,7 +412,7 @@ $dbw->insert( 'code_rev', - array( + [ 'cr_repo_id' => $this->repoId, 'cr_id' => $this->id, 'cr_author' => $this->author, @@ -421,9 +421,9 @@ 'cr_status' => $this->status, 'cr_path' => $this->commonPath, 'cr_flags' => '' - ), + ], __METHOD__, - array( 'IGNORE' ) + [ 'IGNORE' ] ); // Already exists? Update the row! @@ -431,16 +431,16 @@ if ( !$newRevision ) { $dbw->update( 'code_rev', - array( + [ 'cr_author' => $this->author, 'cr_timestamp' => $dbw->timestamp( $this->timestamp ), 'cr_message' => $this->message, 'cr_path' => $this->commonPath - ), - array( + ], + [ 'cr_repo_id' => $this->repoId, 'cr_id' => $this->id - ), + ], __METHOD__ ); } @@ -475,7 +475,7 @@ // Get the authors of these revisions $res = $dbw->select( 'code_rev', - array( + [ 'cr_repo_id', 'cr_id', 'cr_author', @@ -483,16 +483,16 @@ 'cr_message', 'cr_status', 'cr_path', - ), - array( + ], + [ 'cr_repo_id' => $this->repoId, 'cr_id' => $affectedRevs, 'cr_id < ' . intval( $this->id ), # just in case // No sense in notifying if it's the same person 'cr_author != ' . $dbw->addQuotes( $this->author ) - ), + ], __METHOD__, - array( 'USE INDEX' => 'PRIMARY' ) + [ 'USE INDEX' => 'PRIMARY' ] ); // Get repo and build comment title (for url) @@ -553,16 +553,16 @@ * @param int $revId */ public static function insertPaths( $dbw, $paths, $repoId, $revId ) { - $data = array(); + $data = []; foreach ( $paths as $path ) { - $data[] = array( + $data[] = [ 'cp_repo_id' => $repoId, 'cp_rev_id' => $revId, 'cp_path' => $path['path'], 'cp_action' => $path['action'] - ); + ]; } - self::insertChunks( $dbw, 'code_paths', $data, __METHOD__, array( 'IGNORE' ) ); + self::insertChunks( $dbw, 'code_paths', $data, __METHOD__, [ 'IGNORE' ] ); } /** @@ -580,8 +580,8 @@ * @return array */ public function getAffectedRevs() { - $affectedRevs = array(); - $m = array(); + $affectedRevs = []; + $m = []; if ( preg_match_all( '/\br(\d{2,})\b/', $this->message, $m ) ) { foreach ( $m[1] as $rev ) { $affectedRev = intval( $rev ); @@ -603,34 +603,34 @@ $dbw = wfGetDB( DB_MASTER ); // Update bug references table... - $affectedBugs = array(); - $m = array(); + $affectedBugs = []; + $m = []; if ( preg_match_all( self::BugReference, $this->message, $m ) ) { - $data = array(); + $data = []; foreach ( $m[1] as $bug ) { - $data[] = array( + $data[] = [ 'cb_repo_id' => $this->repoId, 'cb_from' => $this->id, 'cb_bug' => $bug - ); + ]; $affectedBugs[] = intval( $bug ); } - $dbw->insert( 'code_bugs', $data, __METHOD__, array( 'IGNORE' ) ); + $dbw->insert( 'code_bugs', $data, __METHOD__, [ 'IGNORE' ] ); } // Also, get previous revisions that have bugs in common... - $affectedRevs = array(); + $affectedRevs = []; if ( count( $affectedBugs ) ) { $res = $dbw->select( 'code_bugs', - array( 'cb_from' ), - array( + [ 'cb_from' ], + [ 'cb_repo_id' => $this->repoId, 'cb_bug' => $affectedBugs, 'cb_from < ' . intval( $this->id ), # just in case - ), + ], __METHOD__, - array( 'USE INDEX' => 'cb_repo_id' ) + [ 'USE INDEX' => 'cb_repo_id' ] ); foreach ( $res as $row ) { $affectedRevs[] = intval( $row->cb_from ); @@ -647,8 +647,8 @@ $dbr = wfGetDB( DB_SLAVE ); return $dbr->select( 'code_paths', - array( 'cp_path', 'cp_action' ), - array( 'cp_repo_id' => $this->repoId, 'cp_rev_id' => $this->id ), + [ 'cp_path', 'cp_action' ], + [ 'cp_repo_id' => $this->repoId, 'cp_rev_id' => $this->id ], __METHOD__ ); } @@ -765,7 +765,7 @@ $dbw = wfGetDB( DB_MASTER ); $ts = wfTimestamp( TS_MW ); $sortkey = $this->threadedSortkey( $parent, $ts ); - return array( + return [ 'cc_repo_id' => $this->repoId, 'cc_rev_id' => $this->id, 'cc_text' => $text, @@ -774,7 +774,7 @@ 'cc_user_text' => $wgUser->getName(), 'cc_timestamp' => $dbw->timestamp( $ts ), 'cc_sortkey' => $sortkey - ); + ]; } /** @@ -791,7 +791,7 @@ $parentKey = $dbw->selectField( 'code_comment', 'cc_sortkey', - array( 'cc_id' => $parent ), + [ 'cc_id' => $parent ], __METHOD__ ); if ( $parentKey ) { @@ -812,21 +812,21 @@ $dbr = wfGetDB( DB_SLAVE ); $result = $dbr->select( 'code_comment', - array( + [ 'cc_id', 'cc_text', 'cc_user', 'cc_user_text', 'cc_timestamp', - 'cc_sortkey' ), - array( + 'cc_sortkey' ], + [ 'cc_repo_id' => $this->repoId, 'cc_rev_id' => $this->id - ), + ], __METHOD__, - array( 'ORDER BY' => 'cc_sortkey' ) + [ 'ORDER BY' => 'cc_sortkey' ] ); - $comments = array(); + $comments = []; foreach ( $result as $row ) { $comments[] = CodeComment::newFromRow( $this, $row ); } @@ -839,10 +839,10 @@ public function getCommentCount() { $dbr = wfGetDB( DB_SLAVE ); $result = $dbr->select( 'code_comment', - array( 'cc_id' ), - array( + [ 'cc_id' ], + [ 'cc_repo_id' => $this->repoId, - 'cc_rev_id' => $this->id ), + 'cc_rev_id' => $this->id ], __METHOD__ ); @@ -859,8 +859,8 @@ public function getPropChanges() { $dbr = wfGetDB( DB_SLAVE ); $result = $dbr->select( - array( 'code_prop_changes', 'user' ), - array( + [ 'code_prop_changes', 'user' ], + [ 'cpc_attrib', 'cpc_removed', 'cpc_added', @@ -868,15 +868,15 @@ 'cpc_user', 'cpc_user_text', 'user_name' - ), array( + ], [ 'cpc_repo_id' => $this->repoId, 'cpc_rev_id' => $this->id, - ), + ], __METHOD__, - array( 'ORDER BY' => 'cpc_timestamp DESC' ), - array( 'user' => array( 'LEFT JOIN', 'cpc_user = user_id' ) ) + [ 'ORDER BY' => 'cpc_timestamp DESC' ], + [ 'user' => [ 'LEFT JOIN', 'cpc_user = user_id' ] ] ); - $changes = array(); + $changes = []; foreach ( $result as $row ) { $changes[] = CodePropChange::newFromRow( $this, $row ); } @@ -891,13 +891,13 @@ $result = $dbr->select( 'code_prop_changes', 'DISTINCT(cpc_user)', - array( + [ 'cpc_repo_id' => $this->repoId, 'cpc_rev_id' => $this->id, - ), + ], __METHOD__ ); - $users = array(); + $users = []; foreach ( $result as $row ) { $users[$row->cpc_user] = User::newFromId( $row->cpc_user ); } @@ -921,14 +921,14 @@ $res = $dbr->select( 'code_comment', 'DISTINCT(cc_user)', - array( + [ 'cc_repo_id' => $this->repoId, 'cc_rev_id' => $this->id, 'cc_user != 0' // users only - ), + ], __METHOD__ ); - $users = array(); + $users = []; foreach ( $res as $row ) { $users[$row->cc_user] = User::newFromId( $row->cc_user ); } @@ -944,17 +944,17 @@ * @return array of code_rev database row objects */ public function getFollowupRevisions() { - $refs = array(); + $refs = []; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( - array( 'code_relations', 'code_rev' ), - array( 'cr_id', 'cr_status', 'cr_timestamp', 'cr_author', 'cr_message' ), - array( + [ 'code_relations', 'code_rev' ], + [ 'cr_id', 'cr_status', 'cr_timestamp', 'cr_author', 'cr_message' ], + [ 'cf_repo_id' => $this->repoId, 'cf_to' => $this->id, 'cr_repo_id = cf_repo_id', 'cr_id = cf_from' - ), + ], __METHOD__ ); foreach ( $res as $row ) { @@ -971,17 +971,17 @@ * @return array of code_rev database row objects */ public function getFollowedUpRevisions() { - $refs = array(); + $refs = []; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( - array( 'code_relations', 'code_rev' ), - array( 'cr_id', 'cr_status', 'cr_timestamp', 'cr_author', 'cr_message' ), - array( + [ 'code_relations', 'code_rev' ], + [ 'cr_id', 'cr_status', 'cr_timestamp', 'cr_author', 'cr_message' ], + [ 'cf_repo_id' => $this->repoId, 'cf_from' => $this->id, 'cr_repo_id = cf_repo_id', 'cr_id = cf_to' - ), + ], __METHOD__ ); foreach ( $res as $row ) { @@ -1001,14 +1001,14 @@ * @param $revs array of revision IDs */ public function addReferencesFrom( $revs ) { - $data = array(); + $data = []; foreach ( array_unique( (array)$revs ) as $rev ) { if ( $rev > $this->getId() ) { - $data[] = array( + $data[] = [ 'cf_repo_id' => $this->getRepoId(), 'cf_from' => $rev, 'cf_to' => $this->getId() - ); + ]; } } $this->addReferences( $data ); @@ -1020,7 +1020,7 @@ */ private function addReferences( $data ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->insert( 'code_relations', $data, __METHOD__, array( 'IGNORE' ) ); + $dbw->insert( 'code_relations', $data, __METHOD__, [ 'IGNORE' ] ); } /** @@ -1029,14 +1029,14 @@ * @param $revs array of revision IDs */ public function addReferencesTo( $revs ) { - $data = array(); + $data = []; foreach ( array_unique( (array)$revs ) as $rev ) { if ( $rev < $this->getId() ) { - $data[] = array( + $data[] = [ 'cf_repo_id' => $this->getRepoId(), 'cf_from' => $this->getId(), 'cf_to' => $rev, - ); + ]; } } $this->addReferences( $data ); @@ -1049,11 +1049,11 @@ */ public function removeReferencesFrom( $revs ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->delete( 'code_relations', array( + $dbw->delete( 'code_relations', [ 'cf_repo_id' => $this->getRepoId(), 'cf_from' => $revs, 'cf_to' => $this->getId() - ), __METHOD__ + ], __METHOD__ ); } @@ -1064,11 +1064,11 @@ */ public function removeReferencesTo( $revs ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->delete( 'code_relations', array( + $dbw->delete( 'code_relations', [ 'cf_repo_id' => $this->getRepoId(), 'cf_from' => $this->getId(), 'cf_to' => $revs - ), __METHOD__ + ], __METHOD__ ); } @@ -1081,16 +1081,16 @@ $db = wfGetDB( $from ); $result = $db->select( 'code_signoffs', - array( 'cs_user', 'cs_user_text', 'cs_flag', 'cs_timestamp', 'cs_timestamp_struck' ), - array( + [ 'cs_user', 'cs_user_text', 'cs_flag', 'cs_timestamp', 'cs_timestamp_struck' ], + [ 'cs_repo_id' => $this->repoId, 'cs_rev_id' => $this->id, - ), + ], __METHOD__, - array( 'ORDER BY' => 'cs_timestamp' ) + [ 'ORDER BY' => 'cs_timestamp' ] ); - $signoffs = array(); + $signoffs = []; foreach ( $result as $row ) { $signoffs[] = CodeSignoff::newFromRow( $this, $row ); } @@ -1105,9 +1105,9 @@ */ public function addSignoff( $user, $flags ) { $dbw = wfGetDB( DB_MASTER ); - $rows = array(); + $rows = []; foreach ( (array)$flags as $flag ) { - $rows[] = array( + $rows[] = [ 'cs_repo_id' => $this->repoId, 'cs_rev_id' => $this->id, 'cs_user' => $user->getID(), @@ -1115,9 +1115,9 @@ 'cs_flag' => $flag, 'cs_timestamp' => $dbw->timestamp(), 'cs_timestamp_struck' => wfGetDB( DB_SLAVE )->getInfinity() - ); + ]; } - $dbw->insert( 'code_signoffs', $rows, __METHOD__, array( 'IGNORE' ) ); + $dbw->insert( 'code_signoffs', $rows, __METHOD__, [ 'IGNORE' ] ); } /** @@ -1145,15 +1145,15 @@ $db = wfGetDB( $from ); $result = $db->select( 'code_tags', - array( 'ct_tag' ), - array( + [ 'ct_tag' ], + [ 'ct_repo_id' => $this->repoId, 'ct_rev_id' => $this->id - ), + ], __METHOD__ ); - $tags = array(); + $tags = []; foreach ( $result as $row ) { $tags[] = $row->ct_tag; } @@ -1180,23 +1180,23 @@ 'code_tags', $this->tagData( $addTags ), __METHOD__, - array( 'IGNORE' ) + [ 'IGNORE' ] ); } if ( $removeTags ) { $dbw->delete( 'code_tags', - array( + [ 'ct_repo_id' => $this->repoId, 'ct_rev_id' => $this->id, - 'ct_tag' => $removeTags ), + 'ct_tag' => $removeTags ], __METHOD__ ); } // Log this change if ( ( $removeTags || $addTags ) && $user && $user->getId() ) { $dbw->insert( 'code_prop_changes', - array( + [ 'cpc_repo_id' => $this->getRepoId(), 'cpc_rev_id' => $this->getId(), 'cpc_attrib' => 'tags', @@ -1205,7 +1205,7 @@ 'cpc_timestamp' => $dbw->timestamp(), 'cpc_user' => $user->getId(), 'cpc_user_text' => $user->getName() - ), + ], __METHOD__ ); } @@ -1216,7 +1216,7 @@ * @return array */ protected function normalizeTags( $tags ) { - $out = array(); + $out = []; foreach ( $tags as $tag ) { $out[] = $this->normalizeTag( $tag ); } @@ -1228,15 +1228,15 @@ * @return array */ protected function tagData( $tags ) { - $data = array(); + $data = []; foreach ( $tags as $tag ) { if ( $tag == '' ) { continue; } - $data[] = array( + $data[] = [ 'ct_repo_id' => $this->repoId, 'ct_rev_id' => $this->id, - 'ct_tag' => $this->normalizeTag( $tag ) ); + 'ct_tag' => $this->normalizeTag( $tag ) ]; } return $data; } @@ -1270,13 +1270,13 @@ public function getPrevious( $path = '' ) { $dbr = wfGetDB( DB_SLAVE ); $encId = $dbr->addQuotes( $this->id ); - $tables = array( 'code_rev' ); + $tables = [ 'code_rev' ]; if ( $path != '' ) { $conds = $this->getPathConds( $path ); $order = 'cp_rev_id DESC'; $tables[] = 'code_paths'; } else { - $conds = array( 'cr_repo_id' => $this->repoId ); + $conds = [ 'cr_repo_id' => $this->repoId ]; $order = 'cr_id DESC'; } $conds[] = "cr_id < $encId"; @@ -1285,7 +1285,7 @@ 'cr_id', $conds, __METHOD__, - array( 'ORDER BY' => $order ) + [ 'ORDER BY' => $order ] ); if ( $row ) { return intval( $row->cr_id ); @@ -1301,13 +1301,13 @@ public function getNext( $path = '' ) { $dbr = wfGetDB( DB_SLAVE ); $encId = $dbr->addQuotes( $this->id ); - $tables = array( 'code_rev' ); + $tables = [ 'code_rev' ]; if ( $path != '' ) { $conds = $this->getPathConds( $path ); $order = 'cp_rev_id ASC'; $tables[] = 'code_paths'; } else { - $conds = array( 'cr_repo_id' => $this->repoId ); + $conds = [ 'cr_repo_id' => $this->repoId ]; $order = 'cr_id ASC'; } $conds[] = "cr_id > $encId"; @@ -1316,7 +1316,7 @@ 'cr_id', $conds, __METHOD__, - array( 'ORDER BY' => $order ) + [ 'ORDER BY' => $order ] ); if ( $row ) { return intval( $row->cr_id ); @@ -1330,13 +1330,13 @@ * @return array */ protected function getPathConds( $path ) { - return array( + return [ 'cp_repo_id' => $this->repoId, 'cp_path' => $path, // join conds 'cr_repo_id = cp_repo_id', 'cr_id = cp_rev_id' - ); + ]; } /** @@ -1346,23 +1346,23 @@ public function getNextUnresolved( $path = '' ) { $dbr = wfGetDB( DB_SLAVE ); $encId = $dbr->addQuotes( $this->id ); - $tables = array( 'code_rev' ); + $tables = [ 'code_rev' ]; if ( $path != '' ) { $conds = $this->getPathConds( $path ); $order = 'cp_rev_id ASC'; $tables[] = 'code_paths'; } else { - $conds = array( 'cr_repo_id' => $this->repoId ); + $conds = [ 'cr_repo_id' => $this->repoId ]; $order = 'cr_id ASC'; } $conds[] = "cr_id > $encId"; - $conds['cr_status'] = array( 'new', 'fixme' ); + $conds['cr_status'] = [ 'new', 'fixme' ]; $row = $dbr->selectRow( $tables, 'cr_id', $conds, __METHOD__, - array( 'ORDER BY' => $order ) + [ 'ORDER BY' => $order ] ); if ( $row ) { return intval( $row->cr_id ); diff --git a/backend/CodeSignoff.php b/backend/CodeSignoff.php index 7210e50..97730d9 100644 --- a/backend/CodeSignoff.php +++ b/backend/CodeSignoff.php @@ -66,14 +66,14 @@ $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'code_signoffs', - array( 'cs_timestamp_struck' => $dbw->timestamp() ), - array( + [ 'cs_timestamp_struck' => $dbw->timestamp() ], + [ 'cs_repo_id' => $this->rev->getRepoId(), 'cs_rev_id' => $this->rev->getId(), 'cs_flag' => $this->flag, 'cs_user_text' => $this->userText, 'cs_timestamp_struck' => $this->timestampStruck - ), + ], __METHOD__ ); } @@ -87,7 +87,7 @@ * @return string ID */ public function getID() { - return implode( '|', array( $this->flag, $this->timestampStruck, $this->userText ) ); + return implode( '|', [ $this->flag, $this->timestampStruck, $this->userText ] ); } /** @@ -126,17 +126,17 @@ $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'code_signoffs', - array( + [ 'cs_user', 'cs_user_text', 'cs_flag', 'cs_timestamp', 'cs_timestamp_struck' - ), - array( + ], + [ 'cs_repo_id' => $rev->getRepoId(), 'cs_rev_id' => $rev->getId(), 'cs_flag' => $parts[0], 'cs_timestamp_struck' => $parts[1], 'cs_user_text' => $parts[2] - ), __METHOD__ + ], __METHOD__ ); if ( !$row ) { return null; diff --git a/backend/DiffHighlighter.php b/backend/DiffHighlighter.php index e8da720..380e8b4 100644 --- a/backend/DiffHighlighter.php +++ b/backend/DiffHighlighter.php @@ -35,7 +35,7 @@ */ function splitLines( $text ) { return implode( "\n", - array_map( array( $this, 'parseLine' ), + array_map( [ $this, 'parseLine' ], explode( "\n", $text ) ) ); } @@ -95,9 +95,9 @@ function formatLine( $content, $class = null ) { if ( $class === null ) { return Html::rawElement( 'tr', $this->getLineIdAttr(), - Html::element( 'td', array( 'class' => 'linenumbers' ), $this->left ) - . Html::element( 'td', array( 'class' => 'linenumbers' ), $this->right ) - . Html::rawElement( 'td', array(), Html::element( 'span', array(), $content ) ) + Html::element( 'td', [ 'class' => 'linenumbers' ], $this->left ) + . Html::element( 'td', [ 'class' => 'linenumbers' ], $this->right ) + . Html::rawElement( 'td', [], Html::element( 'span', [], $content ) ) ); } @@ -126,11 +126,11 @@ # Rely on $left, $right initialization above } - $classAttr = is_null( $class ) ? array() : array( 'class' => $class ); + $classAttr = is_null( $class ) ? [] : [ 'class' => $class ]; return Html::rawElement( 'tr', $this->getLineIdAttr(), - Html::element( 'td', array( 'class' => 'linenumbers' ), $left ) - . Html::element( 'td', array( 'class' => 'linenumbers' ), $right ) - . Html::rawElement( 'td', $classAttr, Html::element( $inlineWrapEl, array(), $content ) ) + Html::element( 'td', [ 'class' => 'linenumbers' ], $left ) + . Html::element( 'td', [ 'class' => 'linenumbers' ], $right ) + . Html::rawElement( 'td', $classAttr, Html::element( $inlineWrapEl, [], $content ) ) ); } @@ -167,14 +167,14 @@ function handleLineFile( $line ) { $this->chunk = 0; return Html::rawElement( 'tr', - array_merge( $this->getLineIdAttr(), array( 'class' => 'patchedfile' ) ), - Html::Element( 'td', array( 'colspan' => 3 ), $line ) + array_merge( $this->getLineIdAttr(), [ 'class' => 'patchedfile' ] ), + Html::Element( 'td', [ 'colspan' => 3 ], $line ) ); } #### END OF LINES HANDLERS ######################################### function getLineIdAttr() { - return array( 'id' => $this->lineNumber ); + return [ 'id' => $this->lineNumber ]; } /** @@ -197,13 +197,13 @@ * @return array */ function tagForLine( $line ) { - static $default = array( 'td', array() ); - static $tags = array( - '-' => array( 'td', array( 'class' => 'del' ) ), - '+' => array( 'td', array( 'class' => 'ins' ) ), - '@' => array( 'td', array( 'class' => 'meta' ) ), - ' ' => array( 'td', array() ), - ); + static $default = [ 'td', [] ]; + static $tags = [ + '-' => [ 'td', [ 'class' => 'del' ] ], + '+' => [ 'td', [ 'class' => 'ins' ] ], + '@' => [ 'td', [ 'class' => 'meta' ] ], + ' ' => [ 'td', [] ], + ]; $first = substr( $line, 0, 1 ); if ( isset( $tags[$first] ) ) { return $tags[$first]; @@ -254,17 +254,17 @@ $matches = preg_match( "/^@@ -$n$s \+$n @@$/", $chunkHeader, $m ); if ( $matches === 1 ) { - return array( $m[1], $m[2], $m[3], $s_default_value ); + return [ $m[1], $m[2], $m[3], $s_default_value ]; } $matches = preg_match( "/^@@ -$n \+$n$s @@$/", $chunkHeader, $m ); if ( $matches === 1 ) { - return array( $m[1], $s_default_value, $m[2], $m[3] ); + return [ $m[1], $s_default_value, $m[2], $m[3] ]; } $matches = preg_match( "/^@@ -$n \+$n @@$/", $chunkHeader, $m ); if ( $matches === 1 ) { - return array( $m[1], $s_default_value, $m[2], $s_default_value ); + return [ $m[1], $s_default_value, $m[2], $s_default_value ]; } # We really really should have matched something! diff --git a/backend/RepoStats.php b/backend/RepoStats.php index 5e7d7f1..baa23f5 100644 --- a/backend/RepoStats.php +++ b/backend/RepoStats.php @@ -52,22 +52,22 @@ $this->revisions = $dbr->selectField( 'code_rev', 'COUNT(*)', - array( 'cr_repo_id' => $this->repo->getId() ), + [ 'cr_repo_id' => $this->repo->getId() ], __METHOD__ ); $this->authors = $dbr->selectField( 'code_rev', 'COUNT(DISTINCT cr_author)', - array( 'cr_repo_id' => $this->repo->getId() ), + [ 'cr_repo_id' => $this->repo->getId() ], __METHOD__ ); - $this->states = array(); + $this->states = []; $res = $dbr->select( 'code_rev', - array( 'cr_status', 'COUNT(*) AS revs' ), - array( 'cr_repo_id' => $this->repo->getId() ), + [ 'cr_status', 'COUNT(*) AS revs' ], + [ 'cr_repo_id' => $this->repo->getId() ], __METHOD__, - array( 'GROUP BY' => 'cr_status' ) + [ 'GROUP BY' => 'cr_status' ] ); foreach ( $res as $row ) { $this->states[$row->cr_status] = $row->revs; @@ -78,7 +78,7 @@ $this->fixmes = $this->getAuthorStatusCounts( 'fixme' ); $this->new = $this->getAuthorStatusCounts( 'new' ); - $this->fixmesPerPath = array(); + $this->fixmesPerPath = []; global $wgCodeReviewFixmePerPath; if ( isset( $wgCodeReviewFixmePerPath[$repoName] ) ) { foreach ( $wgCodeReviewFixmePerPath[$repoName] as $path ) { @@ -86,7 +86,7 @@ } } - $this->newPerPath = array(); + $this->newPerPath = []; global $wgCodeReviewNewPerPath; if ( isset( $wgCodeReviewNewPerPath[$repoName] ) ) { foreach ( $wgCodeReviewNewPerPath[$repoName] as $path ) { @@ -101,17 +101,17 @@ * @return array */ private function getAuthorStatusCounts( $status ) { - $array = array(); + $array = []; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'code_rev', - array( 'COUNT(*) AS revs', 'cr_author' ), - array( 'cr_repo_id' => $this->repo->getId(), 'cr_status' => $status ), + [ 'COUNT(*) AS revs', 'cr_author' ], + [ 'cr_repo_id' => $this->repo->getId(), 'cr_status' => $status ], __METHOD__, - array( + [ 'GROUP BY' => 'cr_author', 'ORDER BY' => 'revs DESC', 'LIMIT' => 500, - ) + ] ); foreach ( $res as $row ) { $array[$row->cr_author] = $row->revs; @@ -141,25 +141,25 @@ * @return array */ private function getStatusPath( $path, $status ) { - $array = array(); + $array = []; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( - array( 'code_paths', 'code_rev' ), - array( 'COUNT(*) AS revs', 'cr_author' ), - array( + [ 'code_paths', 'code_rev' ], + [ 'COUNT(*) AS revs', 'cr_author' ], + [ 'cr_repo_id' => $this->repo->getId(), 'cp_path' => $path, 'cr_status' => $status, - ), + ], __METHOD__, - array( + [ 'GROUP BY' => 'cr_author', 'ORDER BY' => 'revs DESC', 'LIMIT' => 500, - ), - array( - 'code_rev' => array( 'INNER JOIN', 'cr_repo_id = cp_repo_id AND cr_id = cp_rev_id' ) - ) + ], + [ + 'code_rev' => [ 'INNER JOIN', 'cr_repo_id = cp_repo_id AND cr_id = cp_rev_id' ] + ] ); foreach ( $res as $row ) { $array[$row->cr_author] = $row->revs; diff --git a/backend/Subversion.php b/backend/Subversion.php index c199e9c..3721275 100644 --- a/backend/Subversion.php +++ b/backend/Subversion.php @@ -197,15 +197,15 @@ wfEscapeShellArg( $this->mRepoPath . $path ) ); $lines = explode( "\n", wfShellExec( $command ) ); - $out = array(); + $out = []; $divider = str_repeat( '-', 72 ); - $formats = array( + $formats = [ 'rev' => '/^r(\d+)$/', 'author' => '/^(.*)$/', 'date' => '/^(?:(.*?) )?\(.*\)$/', // account for '(no date)' 'lines' => '/^(\d+) lines?$/', - ); + ]; $state = "start"; foreach ( $lines as $line ) { $line = rtrim( $line ); @@ -224,12 +224,12 @@ $state = 'done'; break; } - $data = array(); + $data = []; $bits = explode( ' | ', $line ); $i = 0; foreach ( $formats as $key => $regex ) { $text = $bits[$i++]; - $matches = array(); + $matches = []; if ( preg_match( $regex, $text, $matches ) ) { $data[$key] = $matches[1]; } else { @@ -238,7 +238,7 @@ } } $data['msg'] = ''; - $data['paths'] = array(); + $data['paths'] = []; $state = 'changedpaths'; break; case 'changedpaths': @@ -257,12 +257,12 @@ // Out of paths. Move on to the message... $state = 'msg'; } else { - $matches = array(); + $matches = []; if ( preg_match( '/^ (.) (.*)$/', $line, $matches ) ) { - $data['paths'][] = array( + $data['paths'][] = [ 'action' => $matches[1], 'path' => $matches[2] - ); + ]; } } break; @@ -303,9 +303,9 @@ } $entries = $document->getElementsByTagName( 'entry' ); - $result = array(); + $result = []; foreach ( $entries as $entry ) { - $item = array(); + $item = []; $item['type'] = $entry->getAttribute( 'kind' ); foreach ( $entry->childNodes as $child ) { switch ( $child->nodeName ) { @@ -369,32 +369,32 @@ } function getDiff( $path, $rev1, $rev2 ) { - return $this->_proxy( array( + return $this->_proxy( [ 'action' => 'diff', 'base' => $this->mRepoPath, 'path' => $path, 'rev1' => $rev1, 'rev2' => $rev2 - ) ); + ] ); } function getLog( $path, $startRev = null, $endRev = null ) { - return $this->_proxy( array( + return $this->_proxy( [ 'action' => 'log', 'base' => $this->mRepoPath, 'path' => $path, 'start' => $startRev, 'end' => $endRev - ) ); + ] ); } function getDirList( $path, $rev = null ) { - return $this->_proxy( array( + return $this->_proxy( [ 'action' => 'list', 'base' => $this->mRepoPath, 'path' => $path, 'rev' => $rev - ) ); + ] ); } protected function _proxy( $params ) { -- To view, visit https://gerrit.wikimedia.org/r/357839 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9931f60a11cef61fdf82c8226de6ffb6b24ca9f6 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/CodeReview Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits