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

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


Add phpcs and make pass

Change-Id: I80f669257f2daa12d7b0a9de88b146e5027a2343
---
M InputBox.classes.php
M InputBox.hooks.php
M composer.json
A phpcs.xml
4 files changed, 99 insertions(+), 87 deletions(-)

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



diff --git a/InputBox.classes.php b/InputBox.classes.php
index b03ccd4..e5a4290 100644
--- a/InputBox.classes.php
+++ b/InputBox.classes.php
@@ -15,7 +15,7 @@
        private $mType = '';
        private $mWidth = 50;
        private $mPreload = '';
-       private $mPreloadparams = array();
+       private $mPreloadparams = [];
        private $mEditIntro = '';
        private $mUseVE = '';
        private $mSummary = '';
@@ -46,11 +46,11 @@
                // Split caches by language, to make sure visitors do not see a 
cached
                // version in a random language (since labels are in the user 
language)
                $this->mParser->getOptions()->getUserLangObj();
-               $this->mParser->getOutput()->addModuleStyles( array(
+               $this->mParser->getOutput()->addModuleStyles( [
                        'ext.inputBox.styles',
                        'mediawiki.ui.input',
                        'mediawiki.ui.checkbox',
-               ) );
+               ] );
        }
 
        public function render() {
@@ -65,20 +65,18 @@
                        case 'commenttitle':
                                return $this->getCommentForm();
                        case 'search':
-                               return $this->getSearchForm('search');
+                               return $this->getSearchForm( 'search' );
                        case 'fulltext':
-                               return $this->getSearchForm('fulltext');
+                               return $this->getSearchForm( 'fulltext' );
                        case 'search2':
                                return $this->getSearchForm2();
                        default:
                                return Xml::tags( 'div', null,
                                        Xml::element( 'strong',
-                                               array(
-                                                       'class' => 'error'
-                                               ),
+                                               [ 'class' => 'error' ],
                                                strlen( $this->mType ) > 0
-                                               ? wfMessage( 
'inputbox-error-bad-type', $this->mType )->text()
-                                               : wfMessage( 
'inputbox-error-no-type' )->text()
+                                                       ? wfMessage( 
'inputbox-error-bad-type', $this->mType )->text()
+                                                       : wfMessage( 
'inputbox-error-no-type' )->text()
                                        )
                                );
                }
@@ -93,16 +91,16 @@
         */
        private function getEditActionArgs() {
                // default is wikitext editor
-               $args = array(
+               $args = [
                        'name' => 'action',
                        'value' => 'edit',
-               );
+               ];
                // check, if VE is installed and VE editor is requested
                if ( ExtensionRegistry::getInstance()->isLoaded( 'VisualEditor' 
) && $this->mUseVE ) {
-                       $args = array(
+                       $args = [
                                'name' => 'veaction',
                                'value' => 'edit',
-                       );
+                       ];
                }
                return $args;
        }
@@ -133,9 +131,9 @@
                        $this->mSearchButtonLabel = wfMessage( 
'inputbox-searchfulltext' )->text();
                }
                if ( $this->mID !== '' ) {
-                       $idArray = array( 'id' => Sanitizer::escapeId( 
$this->mID ) );
+                       $idArray = [ 'id' => Sanitizer::escapeId( $this->mID ) 
];
                } else {
-                       $idArray = array();
+                       $idArray = [];
                }
                // We need a unqiue id to link <label> to checkboxes, but also
                // want multiple <inputbox>'s to not be invalid html
@@ -143,20 +141,20 @@
 
                // Build HTML
                $htmlOut = Xml::openElement( 'div',
-                       array(
+                       [
                                'class' => 'mw-inputbox-centered',
                                'style' => $this->bgColorStyle(),
-                       )
+                       ]
                );
                $htmlOut .= Xml::openElement( 'form',
-                       array(
+                       [
                                'name' => 'searchbox',
                                'class' => 'searchbox',
                                'action' => SpecialPage::getTitleFor( 'Search' 
)->getLocalUrl(),
-                       ) + $idArray
+                       ] + $idArray
                );
                $htmlOut .= Xml::element( 'input',
-                       array(
+                       [
                                'class' => $this->getLinebreakClasses() . 
'searchboxInput mw-ui-input mw-ui-input-inline',
                                'name' => 'search',
                                'type' => $this->mHidden ? 'hidden' : 'text',
@@ -164,7 +162,7 @@
                                'placeholder' => $this->mPlaceholderText,
                                'size' => $this->mWidth,
                                'dir' => $this->mDir,
-                       )
+                       ]
                );
 
                if ( $this->mPrefix != '' ) {
@@ -178,13 +176,13 @@
                if ( $this->mNamespaces ) {
                        $namespaces = $wgContLang->getNamespaces();
                        $nsAliases = array_merge( 
$wgContLang->getNamespaceAliases(), $wgNamespaceAliases );
-                       $showNamespaces = array();
-                       $checkedNS = array();
-                       # Check for valid namespaces
+                       $showNamespaces = [];
+                       $checkedNS = [];
+                       // Check for valid namespaces
                        foreach ( $namespacesArray as $userNS ) {
-                               $userNS = trim( $userNS ); # no whitespace
+                               $userNS = trim( $userNS ); // no whitespace
 
-                               # Namespace needs to be checked if flagged with 
"**"
+                               // Namespace needs to be checked if flagged 
with "**"
                                if ( strpos( $userNS, '**' ) ) {
                                        $userNS = str_replace( '**', '', 
$userNS );
                                        $checkedNS[$userNS] = true;
@@ -198,7 +196,7 @@
                                } elseif ( isset( $nsAliases[$userNS] ) ) {
                                        $i = $nsAliases[$userNS];
                                } else {
-                                       continue; # Namespace not recognized, 
skip
+                                       continue; // Namespace not recognized, 
skip
                                }
                                $showNamespaces[$i] = $userNS;
                                if ( isset( $checkedNS[$userNS] ) && 
$checkedNS[$userNS] ) {
@@ -206,34 +204,34 @@
                                }
                        }
 
-                       # Show valid namespaces
+                       // Show valid namespaces
                        foreach ( $showNamespaces as $i => $name ) {
-                               $checked = array();
+                               $checked = [];
                                // Namespace flagged with "**" or if it's the 
only one
                                if ( ( isset( $checkedNS[$i] ) && 
$checkedNS[$i] ) || count( $showNamespaces ) == 1 ) {
-                                       $checked = array( 'checked' => 
'checked' );
+                                       $checked = [ 'checked' => 'checked' ];
                                }
 
                                if ( count( $showNamespaces ) == 1 ) {
                                        // Checkbox
                                        $htmlOut .= Xml::element( 'input',
-                                               array(
+                                               [
                                                        'type' => 'hidden',
                                                        'name' => 'ns' . $i,
                                                        'value' => 1,
                                                        'id' => 
'mw-inputbox-ns' . $i . $idRandStr
-                                               ) + $checked
+                                               ] + $checked
                                        );
                                } else {
                                        // Checkbox
                                        $htmlOut .= ' <div 
class="mw-inputbox-element mw-ui-checkbox">';
                                        $htmlOut .= Xml::element( 'input',
-                                               array(
+                                               [
                                                        'type' => 'checkbox',
                                                        'name' => 'ns' . $i,
                                                        'value' => 1,
                                                        'id' => 
'mw-inputbox-ns' . $i . $idRandStr
-                                               ) + $checked
+                                               ] + $checked
                                        );
                                        // Label
                                        $htmlOut .= Xml::label( $name, 
'mw-inputbox-ns' . $i . $idRandStr );
@@ -246,24 +244,24 @@
                } elseif ( $type == 'search' ) {
                        // Go button
                        $htmlOut .= Xml::element( 'input',
-                               array(
+                               [
                                        'type' => 'submit',
                                        'name' => 'go',
                                        'class' => 'mw-ui-button',
                                        'value' => $this->mButtonLabel
-                               )
+                               ]
                        );
                        $htmlOut .= '&#160;';
                }
 
                // Search button
                $htmlOut .= Xml::element( 'input',
-                       array(
+                       [
                                'type' => 'submit',
                                'name' => 'fulltext',
                                'class' => 'mw-ui-button',
                                'value' => $this->mSearchButtonLabel
-                       )
+                       ]
                );
 
                // Hidden fulltext param for IE (bug 17161)
@@ -299,53 +297,53 @@
                $htmlLabel = '';
                if ( isset( $this->mLabelText ) && strlen( trim( 
$this->mLabelText ) ) ) {
                        $this->mLabelText = $this->mParser->recursiveTagParse( 
$this->mLabelText );
-                       $htmlLabel = Xml::openElement( 'label', array( 'for' => 
'bodySearchInput' . $id ) );
+                       $htmlLabel = Xml::openElement( 'label', [ 'for' => 
'bodySearchInput' . $id ] );
                        $htmlLabel .= $this->mLabelText;
                        $htmlLabel .= Xml::closeElement( 'label' );
                }
                $htmlOut = Xml::openElement( 'form',
-                       array(
+                       [
                                'name' => 'bodySearch' . $id,
                                'id' => 'bodySearch' . $id,
                                'class' => 'bodySearch' . ( $this->mInline ? ' 
mw-inputbox-inline' : '' ),
                                'action' => SpecialPage::getTitleFor( 'Search' 
)->getLocalUrl(),
-                       )
+                       ]
                );
                $htmlOut .= Xml::openElement( 'div',
-                       array(
+                       [
                                'class' => 'bodySearchWrap' . ( $this->mInline 
? ' mw-inputbox-inline' : '' ),
                                'style' => $this->bgColorStyle(),
-                       )
+                       ]
                );
                $htmlOut .= $htmlLabel;
                $htmlOut .= Xml::element( 'input',
-                       array(
+                       [
                                'type' => $this->mHidden ? 'hidden' : 'text',
                                'name' => 'search',
                                'class' => 'mw-ui-input mw-ui-input-inline',
                                'size' => $this->mWidth,
                                'id' => 'bodySearchInput' . $id,
                                'dir' => $this->mDir,
-                       )
+                       ]
                );
                $htmlOut .= '&#160;' . Xml::element( 'input',
-                       array(
+                       [
                                'type' => 'submit',
                                'name' => 'go',
                                'value' => $this->mButtonLabel,
                                'class' => 'mw-ui-button',
-                       )
+                       ]
                );
 
                // Better testing needed here!
                if ( !empty( $this->mFullTextButton ) ) {
                        $htmlOut .= Xml::element( 'input',
-                               array(
+                               [
                                        'type' => 'submit',
                                        'name' => 'fulltext',
                                        'class' => 'mw-ui-button',
                                        'value' => $this->mSearchButtonLabel
-                               )
+                               ]
                        );
                }
 
@@ -373,17 +371,17 @@
                }
 
                $htmlOut = Xml::openElement( 'div',
-                       array(
+                       [
                                'class' => 'mw-inputbox-centered',
                                'style' => $this->bgColorStyle(),
-                       )
+                       ]
                );
-               $createBoxParams = array(
+               $createBoxParams = [
                        'name' => 'createbox',
                        'class' => 'createbox',
                        'action' => $wgScript,
                        'method' => 'get'
-               );
+               ];
                if ( $this->mID !== '' ) {
                        $createBoxParams['id'] = Sanitizer::escapeId( 
$this->mID );
                }
@@ -403,7 +401,7 @@
                        $htmlOut .= Html::hidden( 'section', 'new' );
                }
                $htmlOut .= Xml::openElement( 'input',
-                       array(
+                       [
                                'type' => $this->mHidden ? 'hidden' : 'text',
                                'name' => 'title',
                                'class' => $this->getLinebreakClasses() .
@@ -412,16 +410,16 @@
                                'placeholder' => $this->mPlaceholderText,
                                'size' => $this->mWidth,
                                'dir' => $this->mDir,
-                       )
+                       ]
                );
                $htmlOut .= $this->mBR;
                $htmlOut .= Xml::openElement( 'input',
-                       array(
+                       [
                                'type' => 'submit',
                                'name' => 'create',
                                'class' => 'mw-ui-button mw-ui-progressive 
createboxButton',
                                'value' => $this->mButtonLabel
-                       )
+                       ]
                );
                $htmlOut .= Xml::closeElement( 'form' );
                $htmlOut .= Xml::closeElement( 'div' );
@@ -441,26 +439,27 @@
                }
 
                $htmlOut = Xml::openElement( 'div',
-                       array(
+                       [
                                'class' => 'mw-inputbox-centered',
                                'style' => $this->bgColorStyle(),
-                       )
+                       ]
                );
-               $moveBoxParams = array(
+               $moveBoxParams = [
                        'name' => 'movebox',
                        'class' => 'mw-movebox',
                        'action' => $wgScript,
                        'method' => 'get'
-               );
+               ];
                if ( $this->mID !== '' ) {
                        $moveBoxParams['id'] = Sanitizer::escapeId( $this->mID 
);
                }
                $htmlOut .= Xml::openElement( 'form', $moveBoxParams );
-               $htmlOut .= Html::hidden( 'title', SpecialPage::getTitleFor( 
'Movepage', $this->mPage )->getPrefixedText() );
+               $htmlOut .= Html::hidden( 'title',
+                       SpecialPage::getTitleFor( 'Movepage', $this->mPage 
)->getPrefixedText() );
                $htmlOut .= Html::hidden( 'wpReason', $this->mSummary );
                $htmlOut .= Html::hidden( 'prefix', $this->mPrefix );
                $htmlOut .= Xml::openElement( 'input',
-                       array(
+                       [
                                'type' => $this->mHidden ? 'hidden' : 'text',
                                'name' => 'wpNewTitle',
                                'class' => $this->getLinebreakClasses() . 
'mw-moveboxInput mw-ui-input mw-ui-input-inline',
@@ -468,15 +467,15 @@
                                'placeholder' => $this->mPlaceholderText,
                                'size' => $this->mWidth,
                                'dir' => $this->mDir,
-                       )
+                       ]
                );
                $htmlOut .= $this->mBR;
                $htmlOut .= Xml::openElement( 'input',
-                       array(
+                       [
                                'type' => 'submit',
                                'class' => 'mw-ui-button mw-ui-progressive',
                                'value' => $this->mButtonLabel
-                       )
+                       ]
                );
                $htmlOut .= Xml::closeElement( 'form' );
                $htmlOut .= Xml::closeElement( 'div' );
@@ -496,17 +495,17 @@
                }
 
                $htmlOut = Xml::openElement( 'div',
-                       array(
+                       [
                                'class' => 'mw-inputbox-centered',
                                'style' => $this->bgColorStyle(),
-                       )
+                       ]
                );
-               $commentFormParams = array(
+               $commentFormParams = [
                        'name' => 'commentbox',
                        'class' => 'commentbox',
                        'action' => $wgScript,
                        'method' => 'get'
-               );
+               ];
                if ( $this->mID !== '' ) {
                        $commentFormParams['id'] = Sanitizer::escapeId( 
$this->mID );
                }
@@ -519,7 +518,7 @@
                }
                $htmlOut .= Html::hidden( 'editintro', $this->mEditIntro );
                $htmlOut .= Xml::openElement( 'input',
-                       array(
+                       [
                                'type' => $this->mHidden ? 'hidden' : 'text',
                                'name' => 'preloadtitle',
                                'class' => $this->getLinebreakClasses() . 
'commentboxInput mw-ui-input mw-ui-input-inline',
@@ -527,18 +526,18 @@
                                'placeholder' => $this->mPlaceholderText,
                                'size' => $this->mWidth,
                                'dir' => $this->mDir,
-                       )
+                       ]
                );
                $htmlOut .= Html::hidden( 'section', 'new' );
                $htmlOut .= Html::hidden( 'title', $this->mPage );
                $htmlOut .= $this->mBR;
                $htmlOut .= Xml::openElement( 'input',
-                       array(
+                       [
                                'type' => 'submit',
                                'name' => 'create',
                                'class' => 'mw-ui-button mw-ui-progressive',
                                'value' => $this->mButtonLabel
-                       )
+                       ]
                );
                $htmlOut .= Xml::closeElement( 'form' );
                $htmlOut .= Xml::closeElement( 'div' );
@@ -554,10 +553,11 @@
         */
        public function extractOptions( $text ) {
                // Parse all possible options
-               $values = array();
+               $values = [];
                foreach ( explode( "\n", $text ) as $line ) {
-                       if ( strpos( $line, '=' ) === false )
+                       if ( strpos( $line, '=' ) === false ) {
                                continue;
+                       }
                        list( $name, $value ) = explode( '=', $line, 2 );
                        $name = strtolower( trim( $name ) );
                        $value = Sanitizer::decodeCharReferences( trim( $value 
) );
@@ -570,12 +570,12 @@
                }
 
                // Validate the dir value.
-               if ( isset( $values['dir'] ) && !in_array( $values['dir'], 
array( 'ltr', 'rtl' ) ) ) {
+               if ( isset( $values['dir'] ) && !in_array( $values['dir'], [ 
'ltr', 'rtl' ] ) ) {
                        unset( $values['dir'] );
                }
 
                // Build list of options, with local member names
-               $options = array(
+               $options = [
                        'type' => 'mType',
                        'width' => 'mWidth',
                        'preload' => 'mPreload',
@@ -599,7 +599,7 @@
                        'inline' => 'mInline',
                        'prefix' => 'mPrefix',
                        'dir' => 'mDir',
-               );
+               ];
                foreach ( $options as $name => $var ) {
                        if ( isset( $values[$name] ) ) {
                                $this->$var = $values[$name];
diff --git a/InputBox.hooks.php b/InputBox.hooks.php
index 624d250..9bdae13 100644
--- a/InputBox.hooks.php
+++ b/InputBox.hooks.php
@@ -11,7 +11,7 @@
        // Initialization
        public static function register( Parser &$parser ) {
                // Register the hook with the parser
-               $parser->setHook( 'inputbox', array( 'InputBoxHooks', 'render' 
) );
+               $parser->setHook( 'inputbox', [ 'InputBoxHooks', 'render' ] );
 
                // Continue
                return true;
@@ -61,12 +61,12 @@
                $request,
                $wiki
        ) {
-               if( $wiki->getAction( $request ) !== 'edit' ){
-                       # not our problem
+               if ( $wiki->getAction( $request ) !== 'edit' ){
+                       // not our problem
                        return true;
                }
-               if( $request->getText( 'prefix', '' ) === '' ){
-                       # Fine
+               if ( $request->getText( 'prefix', '' ) === '' ){
+                       // Fine
                        return true;
                }
 
diff --git a/composer.json b/composer.json
index a3aecbe..e4e502f 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 node_modules --exclude 
vendor"
+                       "parallel-lint . --exclude node_modules --exclude 
vendor",
+                       "phpcs -p -s"
                ]
        }
 }
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..ede6c5d
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset>
+       <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+       <file>.</file>
+       <arg name="extensions" value="php,php5,inc"/>
+       <arg name="encoding" value="utf8"/>
+       <exclude-pattern>vendor</exclude-pattern>
+       <exclude-pattern>node_modules</exclude-pattern>
+</ruleset>

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I80f669257f2daa12d7b0a9de88b146e5027a2343
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/InputBox
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

Reply via email to