Umherirrender has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/354242 )

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

Add phpcs and make pass

Change-Id: I2b7c995e60d55e023b87c554274651654fb5d0b7
---
M Poem.class.php
M composer.json
A phpcs.xml
3 files changed, 22 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Poem 
refs/changes/42/354242/1

diff --git a/Poem.class.php b/Poem.class.php
index 586750c..f554fe5 100644
--- a/Poem.class.php
+++ b/Poem.class.php
@@ -10,7 +10,7 @@
         * @return bool true
         */
        public static function init( &$parser ) {
-               $parser->setHook( 'poem', array( 'Poem', 'renderPoem' ) );
+               $parser->setHook( 'poem', [ 'Poem', 'renderPoem' ] );
                return true;
        }
 
@@ -22,7 +22,7 @@
         * @param boolean $frame
         * @return string
         */
-       public static function renderPoem( $in, $param = array(), $parser = 
null, $frame = false ) {
+       public static function renderPoem( $in, $param = [], $parser = null, 
$frame = false ) {
                // using newlines in the text will cause the parser to add <p> 
tags,
                // which may not be desired in some cases
                $newline = isset( $param['compact'] ) ? '' : "\n";
@@ -30,17 +30,17 @@
                $tag = $parser->insertStripItem( "<br />", $parser->mStripState 
);
 
                // replace colons with indented spans
-               $text = preg_replace_callback( '/^(:+)(.+)$/m', array( 'Poem', 
'indentVerse' ), $in );
+               $text = preg_replace_callback( '/^(:+)(.+)$/m', [ 'Poem', 
'indentVerse' ], $in );
 
                // replace newlines with <br /> tags unless they are at the 
beginning or end
                // of the poem
                $text = preg_replace(
-                       array( "/^\n/", "/\n$/D", "/\n/" ),
-                       array( "", "", "$tag\n" ),
+                       [ "/^\n/", "/\n$/D", "/\n/" ],
+                       [ "", "", "$tag\n" ],
                        $text );
 
                // replace spaces at the beginning of a line with non-breaking 
spaces
-               $text = preg_replace_callback( '/^( +)/m', array( 'Poem', 
'replaceSpaces' ), $text );
+               $text = preg_replace_callback( '/^( +)/m', [ 'Poem', 
'replaceSpaces' ], $text );
 
                $text = $parser->recursiveTagParse( $text, $frame );
 
@@ -74,10 +74,10 @@
         * @return string
         */
        protected static function indentVerse( $m ) {
-               $attribs = array(
+               $attribs = [
                        'class' => 'mw-poem-indented',
                        'style' => 'display: inline-block; margin-left: ' . 
strlen( $m[1] ) . 'em;'
-               );
+               ];
                // @todo Should this really be raw?
                return Html::rawElement( 'span', $attribs, $m[2] );
        }
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/354242
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b7c995e60d55e023b87c554274651654fb5d0b7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Poem
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to