jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/356272 )

Change subject: Add phpcs and make pass
......................................................................


Add phpcs and make pass

Change-Id: Ia2e962db11f4733a275e648ff378d5254c9e620c
---
M CreateAccountTestWiki.php
M InfoPage.php
M ListUsersTestWiki.php
M SpecialIncubatorFirstSteps.php
M SpecialRandomByTest.php
M SpecialSearchWiki.php
M SpecialViewUserLang.php
M WikimediaIncubator.class.php
M composer.json
A phpcs.xml
10 files changed, 115 insertions(+), 47 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



diff --git a/CreateAccountTestWiki.php b/CreateAccountTestWiki.php
index eafb14b..8ea9b27 100644
--- a/CreateAccountTestWiki.php
+++ b/CreateAccountTestWiki.php
@@ -21,7 +21,9 @@
                global $wgRequest, $wmincProjects;
                $projectvalue = strtolower( $wgRequest->getVal( 
'testwikiproject', '' ) );
                $codevalue = strtolower( $wgRequest->getVal( 'testwikicode', '' 
) );
-               if ( WikimediaIncubator::validateLanguageCode( $codevalue ) && 
isset( $wmincProjects[$projectvalue] ) ) {
+               if ( WikimediaIncubator::validateLanguageCode( $codevalue )
+                       && isset( $wmincProjects[$projectvalue] )
+               ) {
                        $template->set( 'header',
                                Html::hidden( 'testwiki-project', $projectvalue 
) .
                                Html::hidden( 'testwiki-code', $codevalue )
@@ -38,7 +40,9 @@
                global $wgRequest, $wmincProjects, $wmincPref;
                $projectvalue = $wgRequest->getVal( 'testwiki-project' );
                $codevalue = $wgRequest->getVal( 'testwiki-code' );
-               if ( WikimediaIncubator::validateLanguageCode( $codevalue ) && 
isset( $wmincProjects[$projectvalue] ) ) {
+               if ( WikimediaIncubator::validateLanguageCode( $codevalue )
+                       && isset( $wmincProjects[$projectvalue] )
+               ) {
                        $user->setOption( $wmincPref . '-project', 
$projectvalue );
                        $user->setOption( $wmincPref . '-code', $codevalue );
                        $user->saveSettings();
diff --git a/InfoPage.php b/InfoPage.php
index d4474cc..76c95d0 100644
--- a/InfoPage.php
+++ b/InfoPage.php
@@ -7,11 +7,15 @@
  * 'incubator' showIncubatingWiki()
  *    'open': This is a new Incubator wiki that is not yet verified by the 
language committee.
  *    'eligible': This Incubator wiki has been marked as eligible by the 
language committee.
- *    'imported': This Incubator wiki has been imported from 
xyz.wikiproject.org after that wiki was closed.
- *    'approved': This Incubator wiki has been approved by the language 
committee and will soon be created.
+ *    'imported': This Incubator wiki has been imported from 
xyz.wikiproject.org after that wiki
+ *       was closed.
+ *    'approved': This Incubator wiki has been approved by the language 
committee and will soon
+ *       be created.
  * 'existing' showExistingWiki()
- *    'created': This project has been approved by the language committee and 
is now available at xyz.wikiproject.org.
- *    'beforeincubator': This project was created before Wikimedia Incubator 
started and is available at xyz.wikiproject.org.
+ *    'created': This project has been approved by the language committee and 
is now available at
+ *       xyz.wikiproject.org.
+ *    'beforeincubator': This project was created before Wikimedia Incubator 
started and is
+ *       available at xyz.wikiproject.org.
  *
  * @file
  * @ingroup Extensions
@@ -41,11 +45,14 @@
                $name = Language::fetchLanguageName( $this->mLangCode, 
$wgLang->getCode(), 'all' );
                $this->mLangName = $name ? $name :
                        Language::fetchLanguageName( $this->mLangCode, 'en', 
'all' );
-               $titleParam = $this->mLangName ? $this->mLangName : wfMessage( 
'quotation-marks', $this->mLangCode )->text(); # Name, else code
+               $titleParam = $this->mLangName ? $this->mLangName
+                       : wfMessage( 'quotation-marks', $this->mLangCode 
)->text(); # Name, else code
                # Give grep a chance to find the usages:
-               # wminc-infopage-title-p, wminc-infopage-title-b, 
wminc-infopage-title-t, wminc-infopage-title-q,
-               # wminc-infopage-title-n, wminc-infopage-title-s, 
wminc-infopage-title-v, wminc-infopage-title-y
-               $this->mFormatTitle = wfMessage( 'wminc-infopage-title-' . 
$this->mProjectCode, $titleParam )->escaped();
+               # wminc-infopage-title-p, wminc-infopage-title-b, 
wminc-infopage-title-t,
+               # wminc-infopage-title-q, wminc-infopage-title-n, 
wminc-infopage-title-s,
+               # wminc-infopage-title-v, wminc-infopage-title-y
+               $this->mFormatTitle = wfMessage( 'wminc-infopage-title-' . 
$this->mProjectCode,
+                       $titleParam )->escaped();
                if ( !$this->mLangName ) {
                        # Unknown language, add short note to title
                        $this->mFormatTitle .= ' ' . wfMessage( 
'wminc-unknownlang', $this->mLangCode )->escaped();
@@ -63,7 +70,9 @@
         * @param $mul Boolean
         * @return String
         */
-       public function makeLogo( $project, $clickable = true, $params = [], 
$url = null, $lang = null, $mul = false ) {
+       public function makeLogo( $project, $clickable = true, $params = [],
+               $url = null, $lang = null, $mul = false
+       ) {
                $lang = $lang ? $lang : $this->mLangCode;
                if ( !$mul ) { // for non-multilingual wikis
                        $getDbStatus = WikimediaIncubator::getDBState(
@@ -163,7 +172,8 @@
                ) .
                Html::rawElement( 'ul', [ 'class' => 'wminc-infopage-options' ],
                        Html::rawElement( 'li', null,
-                               wfMessage( $this->mIsSister ? 
'wminc-infopage-option-startsister' : 'wminc-infopage-option-startwiki',
+                               wfMessage( $this->mIsSister
+                                       ? 'wminc-infopage-option-startsister' : 
'wminc-infopage-option-startwiki',
                                        $this->mProjectName, $this->mPortal, 
$steps )->parse() ) .
                        Html::rawElement( 'li', null,
                                wfMessage( 
'wminc-infopage-option-languages-existing',
@@ -202,10 +212,13 @@
                $subdomain = WikimediaIncubator::getSubdomain( 
$this->mLangCode, $this->mProjectCode );
                $subdomainLink = WikimediaIncubator::makeExternalLinkText( 
$subdomain, true );
                # Give grep a chance to find the usages:
-               # wminc-infopage-status-open, wminc-infopage-status-imported, 
wminc-infopage-status-closedsister,
-               # wminc-infopage-status-approved, 
wminc-infopage-status-created, wminc-infopage-status-beforeincubator
+               # wminc-infopage-status-open, wminc-infopage-status-imported,
+               # wminc-infopage-status-closedsister, 
wminc-infopage-status-approved,
+               # wminc-infopage-status-created, 
wminc-infopage-status-beforeincubator
                $content = Html::rawElement( 'div', [ 'class' => 
'wminc-infopage-status' ],
-                       wfMessage( 'wminc-infopage-status-' . $substatus 
)->rawParams( $subdomainLink, $portalLink )->parseAsBlock() );
+                       wfMessage( 'wminc-infopage-status-' . $substatus )
+                               ->rawParams( $subdomainLink, $portalLink 
)->parseAsBlock()
+               );
                if ( $this->mSubStatus != 'approved' && 
$this->mThisLangData['type'] != 'invalid' ) {
                        $content .= Html::element( 'div',
                                [ 'class' => 'wminc-infopage-contribute' ],
@@ -220,8 +233,8 @@
                        )->inContentLanguage()->parse()
                );
                $content .= Html::rawElement( 'ul', [ 'class' => 
'wminc-infopage-options' ],
-                       Html::rawElement( 'li', null, wfMessage( 
'wminc-infopage-option-sisterprojects-other' )->parseAsBlock() .
-                       $this->listOtherProjects() ) );
+                       Html::rawElement( 'li', null, wfMessage( 
'wminc-infopage-option-sisterprojects-other' )
+                               ->parseAsBlock() . $this->listOtherProjects() ) 
);
                return $this->StandardInfoPage( '', $gotoMainPage, $content );
        }
 
@@ -240,19 +253,24 @@
                                $wgLang->getArrow() . ' ' . $subdomainLink );
                }
                # Give grep a chance to find the usages:
-               # wminc-infopage-status-open, wminc-infopage-status-imported, 
wminc-infopage-status-closedsister,
-               # wminc-infopage-status-approved, 
wminc-infopage-status-created, wminc-infopage-status-beforeincubator
-               $msgname = 'wminc-infopage-status-' . $this->mSubStatus; // 
wminc-infopage-status-beforeincubator
-               if ( $this->mSubStatus === 'beforeincubator' && isset( 
$wmincSisterProjects[$this->mProjectCode] ) ) {
+               # wminc-infopage-status-open, wminc-infopage-status-imported,
+               # wminc-infopage-status-closedsister, 
wminc-infopage-status-approved,
+               # wminc-infopage-status-created, 
wminc-infopage-status-beforeincubator
+               $msgname = 'wminc-infopage-status-' . $this->mSubStatus;
+               if ( $this->mSubStatus === 'beforeincubator'
+                       && isset( $wmincSisterProjects[$this->mProjectCode] )
+               ) {
                        $msgname = 
'wminc-infopage-status-beforeincubator-sister';
                }
                $content = Html::rawElement( 'div',
                        [ 'class' => 'wminc-infopage-status' ],
                        wfMessage( $msgname )->rawParams( $subdomainLink 
)->parseAsBlock()
                ) . Html::rawElement( 'ul', [ 'class' => 
'wminc-infopage-options' ],
-                       Html::rawElement( 'li', null, wfMessage( 
'wminc-infopage-option-sisterprojects-other' )->parseAsBlock() .
+                       Html::rawElement( 'li', null,
+                               wfMessage( 
'wminc-infopage-option-sisterprojects-other' )->parseAsBlock() .
                                $this->listOtherProjects() ) .
-                       Html::rawElement( 'li', null, wfMessage( 
'wminc-infopage-option-multilingual' )->parseAsBlock() .
+                       Html::rawElement( 'li', null,
+                               wfMessage( 'wminc-infopage-option-multilingual' 
)->parseAsBlock() .
                                $this->listMultilingualProjects() )
                );
                return $this->StandardInfoPage( $this->showWelcome(), 
$gotoSubdomain, $content );
diff --git a/ListUsersTestWiki.php b/ListUsersTestWiki.php
index 4bf8b9b..4dcde35 100644
--- a/ListUsersTestWiki.php
+++ b/ListUsersTestWiki.php
@@ -11,7 +11,9 @@
        static function getProjectInput() {
                global $wmincProjectSite, $wgRequest;
                $input = strtolower( $wgRequest->getVal( 'testwiki' ) );
-               if ( $input == strtolower( $wmincProjectSite['name'] ) || 
$input == strtolower( $wmincProjectSite['short'] ) ) {
+               if ( $input == strtolower( $wmincProjectSite['name'] )
+                       || $input == strtolower( $wmincProjectSite['short'] )
+               ) {
                        return $wmincProjectSite;
                }
                return null;
diff --git a/SpecialIncubatorFirstSteps.php b/SpecialIncubatorFirstSteps.php
index 0dd1a72..ab61da1 100644
--- a/SpecialIncubatorFirstSteps.php
+++ b/SpecialIncubatorFirstSteps.php
@@ -193,7 +193,8 @@
                        $globalUser = new CentralAuthUser( 
$this->getUser()->getName() );
                        if ( !$globalUser->exists() ) {
                                $link = Linker::specialLink( 'mergeaccount' );
-                               $this->getOutput()->addHtml( $this->msg( 
'wminc-fs-globaluser-text' )->rawParams( $link )->escaped() );
+                               $this->getOutput()->addHtml(
+                                       $this->msg( 'wminc-fs-globaluser-text' 
)->rawParams( $link )->escaped() );
                        }
                }
 
@@ -220,7 +221,8 @@
                $prefix = $linkRenderer->makeKnownLink( Title::newFromText( 
$this->wikiprefix['prefix'] ) );
                $link = $linkRenderer->makeLink( $mainpage, 
$mainpage->getText() );
                $this->getOutput()->addHtml( $this->msg( $mainpage->exists() ?
-                       'wminc-fs-startwiki-exists-text' : 
'wminc-fs-startwiki-text' )->rawParams( $prefix, $link )->parse() );
+                       'wminc-fs-startwiki-exists-text' : 
'wminc-fs-startwiki-text' )
+                       ->rawParams( $prefix, $link )->parse() );
 
                return $step_msg;
        }
diff --git a/SpecialRandomByTest.php b/SpecialRandomByTest.php
index b153b1e..52e3867 100644
--- a/SpecialRandomByTest.php
+++ b/SpecialRandomByTest.php
@@ -18,8 +18,11 @@
                if ( WikimediaIncubator::isContentProject() || ( $project && 
$lang ) ) {
                        $dbr = wfGetDB( DB_SLAVE );
                        $this->extra[] = 'page_title' .
-                               $dbr->buildLike( 
WikimediaIncubator::displayPrefix( $project, $lang ) . '/', $dbr->anyString() );
-               } elseif ( $this->getUser()->getOption( $wmincPref . '-project' 
) == $wmincProjectSite['short'] ) {
+                               $dbr->buildLike( 
WikimediaIncubator::displayPrefix( $project, $lang ) .
+                                       '/', $dbr->anyString() );
+               } elseif (
+                       $this->getUser()->getOption( $wmincPref . '-project' ) 
== $wmincProjectSite['short']
+               ) {
                        # project or help namespace
                        $this->extra['page_namespace'] = [ 4, 12 ];
                }
diff --git a/SpecialSearchWiki.php b/SpecialSearchWiki.php
index 0b848e1..6fe8fb4 100644
--- a/SpecialSearchWiki.php
+++ b/SpecialSearchWiki.php
@@ -14,7 +14,7 @@
         * @param $subpage Mixed: parameter passed to the page or null
         */
        public function execute( $subpage ) {
-               global $wmincProjects, $wmincSisterProjects, $wgScript;
+               global $wmincProjects, $wmincSisterProjects;
 
                $this->setHeaders();
 
@@ -25,8 +25,10 @@
                if ( $subpage ) {
                        $subpage = explode( '/', $subpage );
                }
-               $projectQuery = $this->getRequest()->getText( 'searchproject', 
isset( $subpage[0] ) ? $subpage[0] : '' );
-               $languageQuery = $this->getRequest()->getText( 
'searchlanguage', isset( $subpage[1] ) ? $subpage[1] : '' );
+               $projectQuery = $this->getRequest()->getText( 'searchproject',
+                       isset( $subpage[0] ) ? $subpage[0] : '' );
+               $languageQuery = $this->getRequest()->getText( 'searchlanguage',
+                       isset( $subpage[1] ) ? $subpage[1] : '' );
 
                $this->showForm( $projectQuery, $languageQuery );
 
@@ -102,11 +104,14 @@
                if ( isset( $this->mProjects[$projectQuery] ) ) {
                        # searched with a project code (select box)
                        $matchProject = $projectQuery;
-               } elseif ( $projectCode = array_search( $projectQuery, 
$this->mProjects ) ) {
-                       # searched with a project name
-                       $matchProject = $projectCode;
                } else {
-                       return $this->getOutput()->addWikiMsg( 
'wminc-searchwiki-noproject' );
+                       $projectCode = array_search( $projectQuery, 
$this->mProjects );
+                       if ( $projectCode ) {
+                               # searched with a project name
+                               $matchProject = $projectCode;
+                       } else {
+                               return $this->getOutput()->addWikiMsg( 
'wminc-searchwiki-noproject' );
+                       }
                }
 
                $results = [];
@@ -119,13 +124,25 @@
                        $results[$builtinCode] = 'langcode'; # Match language 
code
                }
                $lcLanguageQuery = self::strip( $languageQuery );
-               if ( $codeByEnglishName = array_search( $lcLanguageQuery, 
array_map( 'self::strip', $this->mEnglishNames ) ) ) {
+
+               $codeByEnglishName = array_search(
+                       $lcLanguageQuery, array_map( 'self::strip', 
$this->mEnglishNames )
+               );
+               if ( $codeByEnglishName ) {
                        $results[$codeByEnglishName] = 'englishname'; # Match 
name in English
                }
-               if ( $codeUserLang = array_search( $lcLanguageQuery, array_map( 
'self::strip', $this->mNamesUserLang ) ) ) {
+
+               $codeUserLang = array_search(
+                       $lcLanguageQuery, array_map( 'self::strip', 
$this->mNamesUserLang )
+               );
+               if ( $codeUserLang ) {
                        $results[$codeUserLang] = 'userlangname'; # Match name 
in user language
                }
-               if ( $codeByNativeName = array_search( $lcLanguageQuery, 
array_map( 'self::strip', $this->mNativeNames ) ) ) {
+
+               $codeByNativeName = array_search(
+                       $lcLanguageQuery, array_map( 'self::strip', 
$this->mNativeNames )
+               );
+               if ( $codeByNativeName ) {
                        $results[$codeByNativeName] = 'nativename'; # Match 
native name
                }
 
diff --git a/SpecialViewUserLang.php b/SpecialViewUserLang.php
index a3b4ccb..04afda5 100644
--- a/SpecialViewUserLang.php
+++ b/SpecialViewUserLang.php
@@ -80,7 +80,8 @@
                $langNames = Language::fetchLanguageNames( 
$this->getLanguage()->getCode() );
                if ( $user == null || $id == 0 ) {
                        # show error if a user with that name does not exist
-                       $this->getOutput()->addHTML( Xml::span( $this->msg( 
'wminc-userdoesnotexist', $target )->text(), 'error' ) );
+                       $this->getOutput()->addHTML( Xml::span(
+                               $this->msg( 'wminc-userdoesnotexist', $target 
)->text(), 'error' ) );
                        return;
                }
                $userproject = $user->getOption( $wmincPref . '-project' );
diff --git a/WikimediaIncubator.class.php b/WikimediaIncubator.class.php
index 4d0de2b..cc1e84a 100644
--- a/WikimediaIncubator.class.php
+++ b/WikimediaIncubator.class.php
@@ -186,7 +186,8 @@
                if ( !is_array( $titleparts ) || !isset( $titleparts[1] ) ) {
                        $data['error'] = 'noslash';
                } else {
-                       $data['project'] = ( isset( $titleparts[0][1] ) ? 
$titleparts[0][1] : '' ); # get the x from Wx/...
+                       # get the x from Wx/...
+                       $data['project'] = ( isset( $titleparts[0][1] ) ? 
$titleparts[0][1] : '' );
                        $data['lang'] = $titleparts[1]; # language code
                        $data['prefix'] = 'W' . $data['project'] . '/' . 
$data['lang'];
                        # check language code
@@ -708,7 +709,8 @@
         * @return True
         */
        public static function onEditFormPreloadText( &$text, &$title ) {
-               $prefix = self::analyzePrefix( $title, true /* only info page 
*/, false /* no sister projects */ );
+               $prefix = self::analyzePrefix( $title, true /* only info page 
*/,
+                       false /* no sister projects */ );
                if ( !$prefix['error'] ) {
                        $text = wfMessage( 'wminc-infopage-prefill', 
$prefix['prefix'] )->plain();
                }
@@ -813,7 +815,8 @@
                if ( $prefix['error'] ) {
                        return false;
                }
-               # display the custom logo only if &testwiki=wx/xx or the user's 
pref is set to the current test wiki
+               # display the custom logo only if &testwiki=wx/xx or
+               # the user's pref is set to the current test wiki
                if ( self::displayPrefix() != $prefix['prefix'] ) {
                        return false;
                }
@@ -908,7 +911,8 @@
                        return true;
                }
                $params[] = wfEscapeWikiText( $t->getPrefixedText() );
-               $params[0] = $prefix && $prefix != 'none' ? 
'wminc-search-nocreate-suggest' : 'wminc-search-nocreate-nopref';
+               $params[0] = $prefix && $prefix != 'none'
+                       ? 'wminc-search-nocreate-suggest' : 
'wminc-search-nocreate-nopref';
                return true;
        }
 
@@ -917,8 +921,8 @@
         * @return true
         */
        public static function onSpecialSearchPowerBox( &$showSections, $term, 
$opts ) {
-               $showSections['testwiki'] = Xml::label( wfMessage( 
'wminc-testwiki' )->text(), 'testwiki' ) . ' ' .
-                       Xml::input( 'testwiki', 20, self::displayPrefix(), [ 
'id' => 'testwiki' ] );
+               $showSections['testwiki'] = Xml::label( wfMessage( 
'wminc-testwiki' )->text(), 'testwiki' )
+                       . ' ' . Xml::input( 'testwiki', 20, 
self::displayPrefix(), [ 'id' => 'testwiki' ] );
                return true;
        }
 
diff --git a/composer.json b/composer.json
index 686b65b..b8f68fb 100644
--- a/composer.json
+++ b/composer.json
@@ -1,11 +1,14 @@
 {
        "require-dev": {
                "jakub-onderka/php-parallel-lint": "0.9.2",
-               "jakub-onderka/php-console-highlighter": "0.3.2"
+               "jakub-onderka/php-console-highlighter": "0.3.2",
+               "mediawiki/mediawiki-codesniffer": "0.7.2"
        },
        "scripts": {
+               "fix": "phpcbf",
                "test": [
-                       "parallel-lint . --exclude vendor"
+                       "parallel-lint . --exclude vendor",
+                       "phpcs -p -s"
                ]
        }
 }
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..763ce6b
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset>
+       <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+       <rule ref="MediaWiki.NamingConventions.ValidGlobalName">
+               <properties>
+                       <property name="ignoreList" type="array" 
value="$wmincProjects,$wmincPref,$wmincSisterProjects,$wmincMultilingualProjects,$wmincProjectSite,$wmincTestWikiNamespaces,$wmincExistingWikis,$wmincLangCodeLength,$wmincProjectDatabases,$wmincClosedWikis"
 />
+               </properties>
+       </rule>
+       <file>.</file>
+       <arg name="extensions" value="php,php5,inc"/>
+       <arg name="encoding" value="UTF-8"/>
+       <exclude-pattern>vendor</exclude-pattern>
+       <exclude-pattern>node_modules</exclude-pattern>
+</ruleset>

-- 
To view, visit https://gerrit.wikimedia.org/r/356272
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2e962db11f4733a275e648ff378d5254c9e620c
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/WikimediaIncubator
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to