jenkins-bot has submitted this change and it was merged.

Change subject: Fix formatting and phpcs issues
......................................................................


Fix formatting and phpcs issues

Change-Id: I5e56928e42ebe7d5b5ad020f5385525cb53bd02a
---
M MassAction.alias.php
M MassAction.php
M compat/JsonSerializable.php
M config/default.php
M config/empty.php
M src/DataModel/Action.php
M src/DataModel/Actions.php
M src/DataModel/Matcher.php
M src/DataModel/Matchers.php
M src/DataModel/Target.php
M src/DataModel/TargetLister.php
M src/DataModel/Task.php
M src/Interfaces/JsonDeserializable.php
M src/JobQueue/ChangeSaverJob.php
M src/JobQueue/ChangeSaverSpawnerJob.php
M src/JobQueue/TargetListJob.php
M src/Log/LogFormatter.php
M src/Log/LogPublisher.php
M src/MassActionDb.php
M src/MassActionExt.php
M src/MassActionHooks.php
M src/MassActionSpecialPage.php
M src/Mediawiki/ApiRequestor.php
M src/Targets/File/FileData.php
M src/Targets/WikiPage/Actions/AppendAction.php
M src/Targets/WikiPage/Actions/PrependAction.php
M src/Targets/WikiPage/Actions/RegexRenameAction.php
M src/Targets/WikiPage/Actions/RegexReplaceAction.php
M src/Targets/WikiPage/Matchers/NamespaceMatcher.php
M src/Targets/WikiPage/Matchers/RedirectMatcher.php
M src/Targets/WikiPage/Matchers/TitleRegexMatcher.php
M src/Targets/WikiPage/WikiPageLister.php
M src/Targets/WikiPage/WikiPageTarget.php
M tests/phpunit/DataModel/ActionsTest.php
M tests/phpunit/DataModel/MatchersTest.php
M tests/phpunit/DataModel/TaskTest.php
M tests/phpunit/Log/LogFormatterTest.php
M tests/phpunit/MassActionDbTest.php
M tests/phpunit/MassActionExtTest.php
M tests/phpunit/Targets/WikiPage/Matchers/TitleRegexMatcherTest.php
40 files changed, 602 insertions(+), 366 deletions(-)

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



diff --git a/MassAction.alias.php b/MassAction.alias.php
index 8b94ccf..4457f16 100644
--- a/MassAction.alias.php
+++ b/MassAction.alias.php
@@ -12,4 +12,4 @@
 /** English (English) */
 $specialPageAliases['en'] = array(
        'MassAction' => array( 'MassAction', 'Mass Action' ),
-);
\ No newline at end of file
+);
diff --git a/MassAction.php b/MassAction.php
index 07c8c92..8453952 100644
--- a/MassAction.php
+++ b/MassAction.php
@@ -6,22 +6,24 @@
 }
 
 // Autoload classes
-spl_autoload_register( function ( $class ) {
-       $prefix = 'MassAction\\';
-       $baseDir = __DIR__ . '/src/';
+spl_autoload_register(
+       function ( $class ) {
+               $prefix = 'MassAction\\';
+               $baseDir = __DIR__ . '/src/';
 
-       $len = strlen( $prefix );
-       if ( strncmp( $prefix, $class, $len ) !== 0 ) {
-               return;
+               $len = strlen( $prefix );
+               if ( strncmp( $prefix, $class, $len ) !== 0 ) {
+                       return;
+               }
+
+               $relativeClass = substr( $class, $len );
+               $file = $baseDir . str_replace( '\\', '/', $relativeClass ) . 
'.php';
+
+               if ( file_exists( $file ) ) {
+                       require $file;
+               }
        }
-
-       $relativeClass = substr( $class, $len );
-       $file = $baseDir . str_replace( '\\', '/', $relativeClass ) . '.php';
-
-       if ( file_exists ( $file ) ) {
-               require $file;
-       }
-});
+);
 
 // Load compat files where needed
 if ( !interface_exists( 'JsonSerializable', false ) ) {
@@ -29,65 +31,68 @@
 }
 
 // Setup the extension!
-call_user_func( function() {
-       # If no config is yet loaded load an empty one
-       global $wgMassActionConfig;
-       if( !isset( $wgMassActionConfig ) ) {
-               require_once __DIR__ . '/config/empty.php';
+call_user_func(
+       function () {
+               # If no config is yet loaded load an empty one
+               global $wgMassActionConfig;
+               if ( !isset( $wgMassActionConfig ) ) {
+                       require_once __DIR__ . '/config/empty.php';
+               }
+
+               # Register Special:Version details
+               global $wgExtensionCredits;
+               $wgExtensionCredits['MassAction'][] = array(
+                       'path' => __FILE__,
+                       'name' => 'MassAction',
+                       'author' => 'Adam Shorland',
+               );
+
+               # Register special pages
+               global $wgSpecialPages;
+               $wgSpecialPages['MassAction'] = 
'MassAction\\MassActionSpecialPage';
+
+               #Incluse special page localisation file
+               global $wgExtensionMessagesFiles;
+               $wgExtensionMessagesFiles['MassActionAlias'] = __DIR__ . 
'/MassAction.alias.php';
+
+               # Register api modules
+               global $wgAPIModules;
+               $wgAPIModules['massaction'] = 'MassAction\\Api\\ApiMassAction';
+
+               # Load i18n files
+               global $wgMessagesDirs;
+               $wgMessagesDirs['MassAction'] = __DIR__ . DIRECTORY_SEPARATOR . 
'i18n';
+
+               # Schema updates for update.php
+               global $wgHooks;
+               $wgHooks['LoadExtensionSchemaUpdates'][] =
+                       
'MassAction\\MassActionHooks::onLoadExtensionSchemaUpdates';
+               $wgHooks['UnitTestsList'][] = 
'MassAction\\MassActionHooks::onUnitTestsList';
+
+               # Add own log type
+               global $wgLogTypes;
+               $wgLogTypes[] = 'massaction';
+
+               # Add log type Formatters
+               global $wgLogActionsHandlers;
+               $wgLogActionsHandlers['massaction/*'] = 
'MassAction\\Log\\LogFormatter';
+
+               # Job Queue Stuff
+               global $wgJobClasses;
+               $wgJobClasses['massActionTargetListJob'] = 
'MassAction\\JobQueue\\TargetListJob';
+               $wgJobClasses['massActionChangeSaverJob'] = 
'MassAction\\JobQueue\\ChangeSaverJob';
+               $wgJobClasses['massActionChangeSaverSpawnerJob'] =
+                       'MassAction\\JobQueue\\ChangeSaverSpawnerJob';
+
+               # ResourceLoader Stuff
+               global $wgResourceModules;
+               $wgResourceModules['ext.MassAction.SpecialMassAction.New'] = 
array(
+                       'styles' => array(
+                               'resources/SpecialMassAction.New.css',
+                       ),
+                       'localBasePath' => __DIR__,
+                       'remoteExtPath' => 'MassAction',
+               );
+
        }
-
-       # Register Special:Version details
-       global $wgExtensionCredits;
-       $wgExtensionCredits['MassAction'][] = array(
-               'path' => __FILE__,
-               'name' => 'MassAction',
-               'author' => 'Adam Shorland',
-       );
-
-       # Register special pages
-       global $wgSpecialPages;
-       $wgSpecialPages[ 'MassAction' ] = 'MassAction\\MassActionSpecialPage';
-
-       #Incluse special page localisation file
-       global $wgExtensionMessagesFiles;
-       $wgExtensionMessagesFiles['MassActionAlias'] = __DIR__ . 
'/MassAction.alias.php';
-
-       # Register api modules
-       global $wgAPIModules;
-       $wgAPIModules['massaction'] = 'MassAction\\Api\\ApiMassAction';
-
-       # Load i18n files
-       global $wgMessagesDirs;
-       $wgMessagesDirs['MassAction'] = __DIR__ . DIRECTORY_SEPARATOR . 'i18n';
-
-       # Schema updates for update.php
-       global $wgHooks;
-       $wgHooks['LoadExtensionSchemaUpdates'][] = 
'MassAction\\MassActionHooks::onLoadExtensionSchemaUpdates';
-       $wgHooks['UnitTestsList'][] = 
'MassAction\\MassActionHooks::onUnitTestsList';
-
-       # Add own log type
-       global $wgLogTypes;
-       $wgLogTypes[] = 'massaction';
-
-       # Add log type Formatters
-       global $wgLogActionsHandlers;
-       $wgLogActionsHandlers['massaction/*'] = 'MassAction\\Log\\LogFormatter';
-
-       # Job Queue Stuff
-       global $wgJobClasses;
-       $wgJobClasses['massActionTargetListJob'] = 
'MassAction\\JobQueue\\TargetListJob';
-       $wgJobClasses['massActionChangeSaverJob'] = 
'MassAction\\JobQueue\\ChangeSaverJob';
-       $wgJobClasses['massActionChangeSaverSpawnerJob'] = 
'MassAction\\JobQueue\\ChangeSaverSpawnerJob';
-
-       # ResourceLoader Stuff
-       global $wgResourceModules;
-       $wgResourceModules['ext.MassAction.SpecialMassAction.New'] = array(
-               'styles' => array(
-                       'resources/SpecialMassAction.New.css',
-               ),
-               'localBasePath' => __DIR__,
-               'remoteExtPath' => 'MassAction',
-       );
-
-} );
-
+);
diff --git a/compat/JsonSerializable.php b/compat/JsonSerializable.php
index 2258ef9..06742e6 100644
--- a/compat/JsonSerializable.php
+++ b/compat/JsonSerializable.php
@@ -7,4 +7,4 @@
 
        public function jsonSerialize();
 
-}
\ No newline at end of file
+}
diff --git a/config/default.php b/config/default.php
index 470d1ec..481e29f 100644
--- a/config/default.php
+++ b/config/default.php
@@ -1,30 +1,32 @@
 <?php
 
-call_user_func( function() {
-       global $wgMassActionConfig;
-       $wgMassActionConfig = array(
-               'targets' => array(
-                       'wikipage' => array(
-                               'class' => 
'MassAction\Targets\WikiPage\WikiPageTarget',
-                               'lister' => 
'MassAction\Targets\WikiPage\WikiPageLister',
-                               'actions' => array(
-                                       'prepend' => 
'MassAction\Targets\WikiPage\Actions\PrependAction',
-                                       'append' => 
'MassAction\Targets\WikiPage\Actions\AppendAction',
-                                       'regexreplace' => 
'MassAction\Targets\WikiPage\Actions\RegexReplaceAction',
-                                       'regexrename' => 
'MassAction\Targets\WikiPage\Actions\RegexRenameAction',
+call_user_func(
+       function () {
+               global $wgMassActionConfig;
+               $wgMassActionConfig = array(
+                       'targets' => array(
+                               'wikipage' => array(
+                                       'class' => 
'MassAction\Targets\WikiPage\WikiPageTarget',
+                                       'lister' => 
'MassAction\Targets\WikiPage\WikiPageLister',
+                                       'actions' => array(
+                                               'prepend' => 
'MassAction\Targets\WikiPage\Actions\PrependAction',
+                                               'append' => 
'MassAction\Targets\WikiPage\Actions\AppendAction',
+                                               'regexreplace' => 
'MassAction\Targets\WikiPage\Actions\RegexReplaceAction',
+                                               'regexrename' => 
'MassAction\Targets\WikiPage\Actions\RegexRenameAction',
+                                       ),
+                                       'matchers' => array(
+                                               'namespace' => 
'MassAction\Targets\WikiPage\Matchers\NamespaceMatcher',
+                                               'redirect' => 
'MassAction\Targets\WikiPage\Matchers\RedirectMatcher',
+                                               'titleregex' => 
'MassAction\Targets\WikiPage\Matchers\TitleRegexMatcher',
+                                       ),
                                ),
-                               'matchers' => array(
-                                       'namespace' => 
'MassAction\Targets\WikiPage\Matchers\NamespaceMatcher',
-                                       'redirect' => 
'MassAction\Targets\WikiPage\Matchers\RedirectMatcher',
-                                       'titleregex' => 
'MassAction\Targets\WikiPage\Matchers\TitleRegexMatcher',
+                               'file' => array(
+                                       'class' => 
'MassAction\Targets\File\FileTarget',
+                                       'lister' => 
'MassAction\Targets\File\FileLister',
+                                       'actions' => array(),
+                                       'matchers' => array(),
                                ),
                        ),
-                       'file' => array(
-                               'class' => 'MassAction\Targets\File\FileTarget',
-                               'lister' => 
'MassAction\Targets\File\FileLister',
-                               'actions' => array(),
-                               'matchers' => array(),
-                       )
-               ),
-       );
-} );
\ No newline at end of file
+               );
+       }
+);
diff --git a/config/empty.php b/config/empty.php
index 54c1718..d10d7c2 100644
--- a/config/empty.php
+++ b/config/empty.php
@@ -1,8 +1,10 @@
 <?php
 
-call_user_func( function() {
-       global $wgMassActionConfig;
-       $wgMassActionConfig = array(
-               'targets' => array(),
-       );
-} );
\ No newline at end of file
+call_user_func(
+       function () {
+               global $wgMassActionConfig;
+               $wgMassActionConfig = array(
+                       'targets' => array(),
+               );
+       }
+);
diff --git a/src/DataModel/Action.php b/src/DataModel/Action.php
index c2c32aa..5f3771a 100644
--- a/src/DataModel/Action.php
+++ b/src/DataModel/Action.php
@@ -26,10 +26,12 @@
         * @return Action
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
+
                /** @var JsonDeserializable[] $serialization */
+
                return $serialization['class']::newFromJson( $serialization );
        }
 
diff --git a/src/DataModel/Actions.php b/src/DataModel/Actions.php
index 48a251d..1b7f25f 100644
--- a/src/DataModel/Actions.php
+++ b/src/DataModel/Actions.php
@@ -29,13 +29,15 @@
         * @param Actions|Action[] $actions
         */
        public function addActions( $actions ) {
-               if( $actions instanceof Actions ) {
+               if ( $actions instanceof Actions ) {
                        $actions = $actions->toArray();
                }
-               if( !is_array( $actions ) ) {
-                       throw new InvalidArgumentException( '$actions must 
either be a Actions object or an array of Action objects' );
+               if ( !is_array( $actions ) ) {
+                       throw new InvalidArgumentException(
+                               '$actions must either be a Actions object or an 
array of Action objects'
+                       );
                }
-               foreach( $actions as $action ) {
+               foreach ( $actions as $action ) {
                        $this->addAction( $action );
                }
        }
@@ -57,11 +59,11 @@
         * @return Actions
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
                $actions = new Actions();
-               foreach( $serialization as $actionBlob ) {
+               foreach ( $serialization as $actionBlob ) {
                        /** @var Action $action */
                        $action = Action::newFromJson( $actionBlob );
                        $actions->addAction( $action );
@@ -79,9 +81,10 @@
         */
        public function jsonSerialize() {
                $actionsBlobs = array();
-               foreach( $this->toArray() as $action ) {
+               foreach ( $this->toArray() as $action ) {
                        $actionsBlobs[] = $action->jsonSerialize();
                }
+
                return $actionsBlobs;
        }
 }
diff --git a/src/DataModel/Matcher.php b/src/DataModel/Matcher.php
index 81e2439..bf39a65 100644
--- a/src/DataModel/Matcher.php
+++ b/src/DataModel/Matcher.php
@@ -36,10 +36,12 @@
         * @return Matcher
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
+
                /** @var JsonDeserializable[] $serialization */
+
                return $serialization['class']::newFromJson( $serialization );
        }
 
diff --git a/src/DataModel/Matchers.php b/src/DataModel/Matchers.php
index 4fbf096..84b5c8b 100644
--- a/src/DataModel/Matchers.php
+++ b/src/DataModel/Matchers.php
@@ -29,13 +29,15 @@
         * @param Matchers|Matcher[] $matchers
         */
        public function addMatchers( $matchers ) {
-               if( $matchers instanceof Matchers ) {
+               if ( $matchers instanceof Matchers ) {
                        $matchers = $matchers->toArray();
                }
-               if( !is_array( $matchers ) ) {
-                       throw new InvalidArgumentException( '$matchers must 
either be a Matchers object or an array of Matcher objects' );
+               if ( !is_array( $matchers ) ) {
+                       throw new InvalidArgumentException(
+                               '$matchers must either be a Matchers object or 
an array of Matcher objects'
+                       );
                }
-               foreach( $matchers as $matcher ) {
+               foreach ( $matchers as $matcher ) {
                        $this->addMatcher( $matcher );
                }
        }
@@ -57,11 +59,11 @@
         * @return Matchers
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
                $matchers = new Matchers();
-               foreach( $serialization as $matcherBlob ) {
+               foreach ( $serialization as $matcherBlob ) {
                        /** @var Matcher $matcher */
                        $matcher = Matcher::newFromJson( $matcherBlob );
                        $matchers->addMatcher( $matcher );
@@ -79,9 +81,10 @@
         */
        public function jsonSerialize() {
                $matchersBlobs = array();
-               foreach( $this->toArray() as $matcher ) {
+               foreach ( $this->toArray() as $matcher ) {
                        $matchersBlobs[] = $matcher->jsonSerialize();
                }
+
                return $matchersBlobs;
        }
 }
diff --git a/src/DataModel/Target.php b/src/DataModel/Target.php
index fce00fe..cc7bd1d 100644
--- a/src/DataModel/Target.php
+++ b/src/DataModel/Target.php
@@ -56,7 +56,13 @@
         * @param mixed $targetIdentifier
         * @param int $state a state constant
         */
-       final public function __construct( $id, $taskId, $targetType, 
$targetIdentifier, $state = self::S_NEW ) {
+       final public function __construct(
+               $id,
+               $taskId,
+               $targetType,
+               $targetIdentifier,
+               $state = self::S_NEW
+       ) {
                $this->id = $id;
                $this->taskId = $taskId;
                $this->targetType = $targetType;
@@ -103,7 +109,7 @@
        /**
         * @return int|null
         */
-       public function getId(){
+       public function getId() {
                return $this->id;
        }
 
@@ -138,10 +144,11 @@
        /**
         * @return string
         */
-       public function getStateString(){
-               if( !array_key_exists( $this->state, self::$stateMapping ) ) {
+       public function getStateString() {
+               if ( !array_key_exists( $this->state, self::$stateMapping ) ) {
                        return 'Unknown State';
                }
+
                return self::$stateMapping[$this->state];
        }
 
diff --git a/src/DataModel/TargetLister.php b/src/DataModel/TargetLister.php
index dbb6ab2..56328cf 100644
--- a/src/DataModel/TargetLister.php
+++ b/src/DataModel/TargetLister.php
@@ -2,7 +2,7 @@
 
 namespace MassAction\DataModel;
 
-abstract class TargetLister{
+abstract class TargetLister {
 
        /**
         * Lists targets that match the matchers
diff --git a/src/DataModel/Task.php b/src/DataModel/Task.php
index 67e1713..f3041b0 100644
--- a/src/DataModel/Task.php
+++ b/src/DataModel/Task.php
@@ -75,7 +75,16 @@
         * @param Actions $actions
         * @param int $state a state constant
         */
-       public function __construct( $id, $dateCreated, $userId, $summary, 
$targetType, $matchers, $actions, $state = self::S_NEW ) {
+       public function __construct(
+               $id,
+               $dateCreated,
+               $userId,
+               $summary,
+               $targetType,
+               $matchers,
+               $actions,
+               $state = self::S_NEW
+       ) {
                $this->id = $id;
                $this->dateCreated = $dateCreated;
                $this->userId = $userId;
@@ -145,10 +154,11 @@
        /**
         * @return string
         */
-       public function getStateString(){
-               if( !array_key_exists( $this->state, self::$stateMapping ) ) {
+       public function getStateString() {
+               if ( !array_key_exists( $this->state, self::$stateMapping ) ) {
                        return 'Unknown State';
                }
+
                return self::$stateMapping[$this->state];
        }
 
diff --git a/src/Interfaces/JsonDeserializable.php 
b/src/Interfaces/JsonDeserializable.php
index e056768..9ba99b8 100644
--- a/src/Interfaces/JsonDeserializable.php
+++ b/src/Interfaces/JsonDeserializable.php
@@ -10,8 +10,9 @@
 
        /**
         * @param string|array $serialization
+        *
         * @return object
         */
-       public static function newFromJson ( $serialization );
+       public static function newFromJson( $serialization );
 
 }
diff --git a/src/JobQueue/ChangeSaverJob.php b/src/JobQueue/ChangeSaverJob.php
index e98a500..9fbaa2a 100644
--- a/src/JobQueue/ChangeSaverJob.php
+++ b/src/JobQueue/ChangeSaverJob.php
@@ -34,11 +34,11 @@
         * @throws \InvalidArgumentException
         */
        public function __construct( $title, $params, MassActionDb $db = null ) 
{
-               if( !array_key_exists( 'targetid', $params ) ) {
+               if ( !array_key_exists( 'targetid', $params ) ) {
                        wfDebugLog( 'massaction', 'ChangeSaverJob $params needs 
a targetid' );
                        throw new InvalidArgumentException( 'ChangeSaverJob 
$params needs a targetid' );
                }
-               if( is_null( $db ) ) {
+               if ( is_null( $db ) ) {
                        $db = MassActionExt::getDefaultInstance()->getDb();
                }
                $this->db = $db;
@@ -50,6 +50,7 @@
         */
        private function getTargetId() {
                $params = $this->getParams();
+
                return $params['targetid'];
        }
 
@@ -87,8 +88,10 @@
                        $this->db->updateTargetState( $targetId, 
Target::S_SAVE_FAILED );
                        $logPublisher = new LogPublisher( $this->db );
                        $logPublisher->logJobFailed( $this );
+
                        return false;
                }
+
                return true;
        }
 }
diff --git a/src/JobQueue/ChangeSaverSpawnerJob.php 
b/src/JobQueue/ChangeSaverSpawnerJob.php
index 374c460..c858295 100644
--- a/src/JobQueue/ChangeSaverSpawnerJob.php
+++ b/src/JobQueue/ChangeSaverSpawnerJob.php
@@ -32,10 +32,10 @@
         * @throws \InvalidArgumentException
         */
        public function __construct( $title, $params, MassActionDb $db = null ) 
{
-               if( !array_key_exists( 'taskid', $params ) ) {
+               if ( !array_key_exists( 'taskid', $params ) ) {
                        throw new InvalidArgumentException( 'ChangeSaverJob 
$params needs a taskid' );
                }
-               if( is_null( $db ) ) {
+               if ( is_null( $db ) ) {
                        $db = MassActionExt::getDefaultInstance()->getDb();
                }
                $this->db = $db;
@@ -47,9 +47,10 @@
         */
        private function getTaskId() {
                $params = $this->getParams();
-               if( !array_key_exists( 'taskid', $params ) ) {
+               if ( !array_key_exists( 'taskid', $params ) ) {
                        return null;
                }
+
                return $params['taskid'];
        }
 
@@ -63,8 +64,12 @@
                        $this->db->updateTaskState( $taskId, 
Task::S_SAVE_CHANGES_ALL );
                        $task = $this->db->getTaskFromId( $taskId );
                        $targets = $this->db->getTargetsForTask( $task );
-                       foreach( $targets as $target ) {
-                               $job = new ChangeSaverJob( 
Title::newMainPage(), array( 'targetid' => $target->getId() ) );
+                       foreach ( $targets as $target ) {
+                               $job =
+                                       new ChangeSaverJob(
+                                               Title::newMainPage(),
+                                               array( 'targetid' => 
$target->getId() )
+                                       );
                                JobQueueGroup::singleton()->push( $job );
                        }
                }
@@ -73,8 +78,10 @@
                        $this->db->updateTaskState( $taskId, 
Task::S_SAVE_CHANGES_FAILED );
                        $logPublisher = new LogPublisher( $this->db );
                        $logPublisher->logJobFailed( $this );
+
                        return false;
                }
+
                return true;
        }
 }
diff --git a/src/JobQueue/TargetListJob.php b/src/JobQueue/TargetListJob.php
index 95a4149..d50e995 100644
--- a/src/JobQueue/TargetListJob.php
+++ b/src/JobQueue/TargetListJob.php
@@ -32,10 +32,10 @@
         * @throws \InvalidArgumentException
         */
        public function __construct( $title, $params, MassActionDb $db = null ) 
{
-               if( !array_key_exists( 'taskid', $params ) ) {
+               if ( !array_key_exists( 'taskid', $params ) ) {
                        throw new InvalidArgumentException( 'TargetListJob 
$params need a taskid' );
                }
-               if( is_null( $db ) ) {
+               if ( is_null( $db ) ) {
                        $db = MassActionExt::getDefaultInstance()->getDb();
                }
                $this->db = $db;
@@ -47,6 +47,7 @@
         */
        private function getTaskId() {
                $params = $this->getParams();
+
                return $params['taskid'];
        }
 
@@ -62,7 +63,10 @@
 
                        $this->db->updateTaskState( $task->getId(), 
Task::S_FIND_TARGETS );
 
-                       $targetLister = 
MassActionExt::getDefaultInstance()->getListerForTargetType( 
$task->getTargetType() );
+                       $targetLister =
+                               
MassActionExt::getDefaultInstance()->getListerForTargetType(
+                                       $task->getTargetType()
+                               );
                        $targetList = $targetLister->getList( 
$task->getMatchers() );
 
                        foreach ( $targetList as $target ) {
@@ -80,8 +84,10 @@
                        $this->db->updateTaskState( $taskId, 
Task::S_TARGET_LIST_FAILED );
                        $logPublisher = new LogPublisher( $this->db );
                        $logPublisher->logJobFailed( $this );
+
                        return false;
                }
+
                return true;
        }
 }
diff --git a/src/Log/LogFormatter.php b/src/Log/LogFormatter.php
index 9bcddff..9e405ba 100644
--- a/src/Log/LogFormatter.php
+++ b/src/Log/LogFormatter.php
@@ -22,7 +22,14 @@
                switch ( strtolower( trim( $type ) ) ) {
                        case 'taskid':
                                //TODO use linker class
-                               $value = Message::rawParam( '<a 
href="./Special:MassAction/View/' . $value . '" >Task ' . $value . '</a>' );
+                               $value =
+                                       Message::rawParam(
+                                               '<a 
href="./Special:MassAction/View/' .
+                                               $value .
+                                               '" >Task ' .
+                                               $value .
+                                               '</a>'
+                                       );
                }
 
                return $value;
diff --git a/src/Log/LogPublisher.php b/src/Log/LogPublisher.php
index b7d7de6..f81c328 100644
--- a/src/Log/LogPublisher.php
+++ b/src/Log/LogPublisher.php
@@ -21,9 +21,10 @@
         */
        private $db;
 
-       public function __construct( MassActionDb $db ){
+       public function __construct( MassActionDb $db ) {
                $this->db = $db;
        }
+
        /**
         * @param Task $task
         *
@@ -47,14 +48,12 @@
         */
        public function logJobFailed( Job $job ) {
                $params = $job->getParams();
-               if( array_key_exists( 'taskid', $params ) ){
+               if ( array_key_exists( 'taskid', $params ) ) {
                        $task = $this->db->getTaskFromId( $params['taskid'] );
-               }
-               elseif( array_key_exists( 'targetid', $params )){
+               } elseif ( array_key_exists( 'targetid', $params ) ) {
                        $target = $this->db->getTargetFromId( 
$params['targetid'] );
                        $task = $this->db->getTaskFromId( $target->getTaskId() 
);
-               }
-               else{
+               } else {
                        return false;
                }
                $logEntry = new ManualLogEntry( 'massaction', 'jobfailed' );
@@ -62,10 +61,12 @@
                //XXX: Got to pass a page here so lets go with the MainPage...
                $logEntry->setTarget( Title::newMainPage() );
                $logEntry->setComment( '' );
-               $logEntry->setParameters( array(
-                       '4:taskid:taskid' => $task->getId(),
-                       '5:jobtype:jobtype' => $job->getType(),
-               ) );
+               $logEntry->setParameters(
+                       array(
+                               '4:taskid:taskid' => $task->getId(),
+                               '5:jobtype:jobtype' => $job->getType(),
+                       )
+               );
                $logid = $logEntry->insert();
                $logEntry->publish( $logid );
        }
diff --git a/src/MassActionDb.php b/src/MassActionDb.php
index 6abac4d..25f7ac4 100644
--- a/src/MassActionDb.php
+++ b/src/MassActionDb.php
@@ -30,10 +30,10 @@
         * @param DatabaseBase|null $writeDb
         */
        public function __construct( $readDb = null, $writeDb = null ) {
-               if( is_null( $readDb ) ) {
+               if ( is_null( $readDb ) ) {
                        $readDb = wfGetDB( DB_SLAVE );
                }
-               if( is_null( $writeDb ) ) {
+               if ( is_null( $writeDb ) ) {
                        $writeDb = wfGetDB( DB_MASTER );
                }
                $this->writeDb = $writeDb;
@@ -92,12 +92,21 @@
        public function getTaskFromId( $id ) {
                $row = $this->getReadDb()->selectRow(
                        'massaction_task',
-                       array( 'mt_id', 'mt_actions', 'mt_target_type', 
'mt_matchers', 'mt_date', 'mt_user_id', 'mt_summary', 'mt_state' ),
+                       array(
+                               'mt_id',
+                               'mt_actions',
+                               'mt_target_type',
+                               'mt_matchers',
+                               'mt_date',
+                               'mt_user_id',
+                               'mt_summary',
+                               'mt_state',
+                       ),
                        array( 'mt_id' => $id, ),
                        __METHOD__
                );
 
-               if( $row === false ) {
+               if ( $row === false ) {
                        return null;
                }
 
@@ -128,12 +137,12 @@
                                'mt_target_type' => $task->getTargetType(),
                                'mt_user_id' => $task->getUserId(),
                                'mt_summary' => $task->getSummary(),
-                               'mt_matchers' => json_encode( 
$task->getMatchers() )
+                               'mt_matchers' => json_encode( 
$task->getMatchers() ),
                        ),
                        __METHOD__
                );
 
-               if( $row === false ) {
+               if ( $row === false ) {
                        throw new MWException( 'Something went wrong reading 
from db!' );
                }
 
@@ -161,11 +170,21 @@
                $db = $this->getWriteDb();
                if ( $newState == Task::S_COMPLETED ) {
                        $updateResult = $db->query(
-                               'UPDATE ' . $db->tableName( 'massaction_task' ) 
. ' ' .
+                               'UPDATE ' .
+                               $db->tableName( 'massaction_task' ) .
+                               ' ' .
                                'SET mt_state = CASE WHEN ' .
-                               '( SELECT count(*) FROM ' . $db->tableName( 
'massaction_target' ) . ' ' .
-                               'WHERE mtg_state < ' . Target::S_COMPLETED . ' 
AND mtg_task_id = ' . $taskId . ' ) = 0 ' .
-                               'THEN ' . Task::S_COMPLETED . ' ELSE mt_state 
END'
+                               '( SELECT count(*) FROM ' .
+                               $db->tableName( 'massaction_target' ) .
+                               ' ' .
+                               'WHERE mtg_state < ' .
+                               Target::S_COMPLETED .
+                               ' AND mtg_task_id = ' .
+                               $taskId .
+                               ' ) = 0 ' .
+                               'THEN ' .
+                               Task::S_COMPLETED .
+                               ' ELSE mt_state END'
                        );
                } else {
                        $updateResult = $db->update(
@@ -174,17 +193,16 @@
                                        'mt_state' => $newState,
                                ),
                                array(
-                                       'mt_id' => $taskId
+                                       'mt_id' => $taskId,
                                ),
                                __METHOD__
                        );
                }
 
-               if( $updateResult == false ) {
+               if ( $updateResult == false ) {
                        throw new MWException( 'Something went wrong reading 
from db!' );
                }
        }
-
 
        /**
         * @param Task $task
@@ -199,7 +217,7 @@
                                'mtg_task_id' => $task->getId(),
                                'mtg_target_type' => $target->getTargetType(),
                                'mtg_target_identifier' => 
$target->getTargetIdentifier(),
-                               'mtg_state' => $target->getState()
+                               'mtg_state' => $target->getState(),
                        ),
                        __METHOD__
                );
@@ -214,18 +232,24 @@
        public function getTargetFromId( $id ) {
                $row = $this->getReadDb()->selectRow(
                        'massaction_target',
-                       array( 'mtg_id', 'mtg_task_id', 
'mtg_target_identifier', 'mtg_target_type', 'mtg_state' ),
+                       array(
+                               'mtg_id',
+                               'mtg_task_id',
+                               'mtg_target_identifier',
+                               'mtg_target_type',
+                               'mtg_state',
+                       ),
                        array( 'mtg_id' => $id, ),
                        __METHOD__
                );
 
-               if( $row === false ) {
+               if ( $row === false ) {
                        throw new MWException( 'Something went wrong reading 
from db!' );
                }
 
                //TODO hide this hack in some factory or other class?
                $targetClasses = 
MassActionExt::getDefaultInstance()->getTargets();
-               if( !array_key_exists( $row->mtg_target_type , $targetClasses ) 
) {
+               if ( !array_key_exists( $row->mtg_target_type, $targetClasses ) 
) {
                        throw new MWException( 'Unexpected mtg_target_type 
getting target from ID' );
                } else {
                        //NOTE: Magic construction of objects that extend 
Target below!
@@ -245,22 +269,28 @@
         * @throws MWException
         * @return Target[]
         */
-       public function getTargetsForTask( Task $task ){
+       public function getTargetsForTask( Task $task ) {
                $selectResult = $this->getReadDb()->select(
                        'massaction_target',
-                       array( 'mtg_id', 'mtg_task_id', 
'mtg_target_identifier', 'mtg_target_type', 'mtg_state' ),
+                       array(
+                               'mtg_id',
+                               'mtg_task_id',
+                               'mtg_target_identifier',
+                               'mtg_target_type',
+                               'mtg_state',
+                       ),
                        array( 'mtg_task_id' => $task->getId(), ),
                        __METHOD__
                );
 
-               if( $selectResult == false ) {
+               if ( $selectResult == false ) {
                        throw new MWException( 'Something went wrong reading 
from db!' );
                }
 
                $targets = array();
                $targetClasses = 
MassActionExt::getDefaultInstance()->getTargets();
-               foreach( $selectResult as $row ) {
-                       if( !array_key_exists( $row->mtg_target_type, 
$targetClasses ) ) {
+               foreach ( $selectResult as $row ) {
+                       if ( !array_key_exists( $row->mtg_target_type, 
$targetClasses ) ) {
                                throw new MWException( 'Unexpected 
mtg_target_type getting targets for task' );
                        } else {
                                //NOTE: Magic construction of objects that 
extend Target below!
@@ -290,12 +320,12 @@
                                'mtg_state' => $newState,
                        ),
                        array(
-                               'mtg_id' => $targetId
+                               'mtg_id' => $targetId,
                        ),
                        __METHOD__
                );
 
-               if( $updateResult == false ) {
+               if ( $updateResult == false ) {
                        throw new MWException( 'Something went wrong updating 
state in the db!' );
                }
        }
diff --git a/src/MassActionExt.php b/src/MassActionExt.php
index 594de5c..ea0fbc9 100644
--- a/src/MassActionExt.php
+++ b/src/MassActionExt.php
@@ -44,11 +44,12 @@
                static $instance = null;
                if ( $instance === null ) {
                        $globalVarConfig = new GlobalVarConfig( 'wg' );
-                       if( !$globalVarConfig->has( 'MassActionConfig' ) ) {
+                       if ( !$globalVarConfig->has( 'MassActionConfig' ) ) {
                                throw new MWException( 'No config found for 
MassActionExtension' );
                        }
                        $instance = new self( $globalVarConfig->get( 
'MassActionConfig' ) );
                }
+
                return $instance;
        }
 
@@ -59,19 +60,23 @@
                $requiredTargetElements = array( 'class', 'lister', 'actions', 
'matchers', );
 
                $this->throwExceptionOnBadConfig( $config, 'main', array( 
'targets' ) );
-               foreach( $config as $configElementKey => $configElement ) {
-                       if( $configElementKey === 'targets' ) {
+               foreach ( $config as $configElementKey => $configElement ) {
+                       if ( $configElementKey === 'targets' ) {
 
-                               foreach( $configElement as $targetKey => 
$targetConfig ) {
-                                       $this->throwExceptionOnBadConfig( 
$targetConfig, 'target', $requiredTargetElements );
+                               foreach ( $configElement as $targetKey => 
$targetConfig ) {
+                                       $this->throwExceptionOnBadConfig(
+                                               $targetConfig,
+                                               'target',
+                                               $requiredTargetElements
+                                       );
                                        $this->targets[$targetKey] = 
$targetConfig['class'];
                                        $this->listers[$targetKey] = 
$targetConfig['lister'];
 
-                                       foreach( $targetConfig['actions'] as 
$actionKey => $actionClass ) {
+                                       foreach ( $targetConfig['actions'] as 
$actionKey => $actionClass ) {
                                                
$this->actions[$targetKey][$actionKey] = $actionClass;
                                        }
 
-                                       foreach( $targetConfig['matchers'] as 
$matcherKey => $matcherClass ) {
+                                       foreach ( $targetConfig['matchers'] as 
$matcherKey => $matcherClass ) {
                                                
$this->matchers[$targetKey][$matcherKey] = $matcherClass;
                                        }
                                }
@@ -80,9 +85,11 @@
        }
 
        private function throwExceptionOnBadConfig( $config, $label, 
$expectedElements ) {
-               foreach( $expectedElements as $key ) {
-                       if( !array_key_exists( $key, $config ) ) {
-                               throw new InvalidArgumentException( 'MassAction 
Config (' . $label . ') must have key ' . $key );
+               foreach ( $expectedElements as $key ) {
+                       if ( !array_key_exists( $key, $config ) ) {
+                               throw new InvalidArgumentException(
+                                       'MassAction Config (' . $label . ') 
must have key ' . $key
+                               );
                        }
                }
        }
@@ -103,37 +110,43 @@
 
        /**
         * @param string|null $target
+        *
         * @return array[]|string[]|null
         *     $task = null @return array[] of class names with 
[targetKey][matcherKey] => $classname
         *     $task = RealTarget > string[] array of class names with 
matcherKey keys
         *     $task = NonExistantTarget > null
         */
        public function getMatchers( $target = null ) {
-               if( !is_null( $target ) ) {
+               if ( !is_null( $target ) ) {
                        $target = strtolower( $target );
-                       if( !array_key_exists( $target, $this->matchers ) ) {
+                       if ( !array_key_exists( $target, $this->matchers ) ) {
                                return null;
                        }
+
                        return $this->matchers[$target];
                }
+
                return $this->matchers;
        }
 
        /**
         * @param string|null $target
+        *
         * @return array[]|string[]|null
         *     $task = null @return array[] of class names with 
[targetKey][actionKey] => $classname
         *     $task = RealTarget > string[] array of class names with 
actionKey keys
         *     $task = NonExistantTarget > null
         */
        public function getActions( $target = null ) {
-               if( !is_null( $target ) ) {
+               if ( !is_null( $target ) ) {
                        $target = strtolower( $target );
-                       if( !array_key_exists( $target, $this->actions ) ) {
+                       if ( !array_key_exists( $target, $this->actions ) ) {
                                return null;
                        }
+
                        return $this->actions[$target];
                }
+
                return $this->actions;
        }
 
@@ -144,9 +157,10 @@
         */
        public function getListerForTargetType( $targetType ) {
                $targetType = strtolower( $targetType );
-               if( array_key_exists( $targetType , $this->listers ) ) {
+               if ( array_key_exists( $targetType, $this->listers ) ) {
                        return new $this->listers[$targetType]();
                }
+
                return null;
        }
 
diff --git a/src/MassActionHooks.php b/src/MassActionHooks.php
index 34c90a5..f6eecc3 100644
--- a/src/MassActionHooks.php
+++ b/src/MassActionHooks.php
@@ -40,6 +40,7 @@
                        }
                }
                $files = array_merge( $files, $ourFiles );
+
                return true;
        }
 
diff --git a/src/MassActionSpecialPage.php b/src/MassActionSpecialPage.php
index a9550a8..cef0a8e 100644
--- a/src/MassActionSpecialPage.php
+++ b/src/MassActionSpecialPage.php
@@ -40,25 +40,33 @@
                $params = $this->getParamsFromSubPage( $subPage );
                try {
                        if ( count( $params ) > 0 ) {
-                               switch( array_shift( $params ) ) {
+                               switch ( array_shift( $params ) ) {
                                        case 'view':
                                                $this->executeViewTask( $params 
);
+
                                                return;
                                        case 'new':
                                                $this->executeNewTask( $params 
);
+
                                                return;
                                }
                        }
                        $this->executeDefault();
                }
-               catch( Exception $e ) {
+               catch ( Exception $e ) {
                        //TODO error message should be localised
-                       $this->getOutput()->showErrorPage( 'massaction-error', 
'massaction-errormessage', array( $e->getMessage() ) );
+                       $this->getOutput()->showErrorPage(
+                               'massaction-error',
+                               'massaction-errormessage',
+                               array( $e->getMessage() )
+                       );
                }
        }
 
        private function getParamsFromSubPage( $subPage ) {
-               $params = ( $subPage === '' ) ? array() : array_map( 
'strtolower', explode( '/', $subPage ) );
+               $params =
+                       ( $subPage === '' ) ? array() : array_map( 
'strtolower', explode( '/', $subPage ) );
+
                return $params;
        }
 
@@ -74,8 +82,11 @@
        private function executeViewTask( $params ) {
                $db = MassActionExt::getDefaultInstance()->getDb();
 
-               if( $this->getRequest()->wasPosted() ) {
-                       if ( !$this->getUser()->matchEditToken( 
$this->getRequest()->getVal( 'wpEditToken' ) ) ) {
+               if ( $this->getRequest()->wasPosted() ) {
+                       if ( !$this->getUser()->matchEditToken(
+                               $this->getRequest()->getVal( 'wpEditToken' )
+                       )
+                       ) {
                                throw new Exception( 'Did not match csrf token' 
);
                        }
 
@@ -86,38 +97,46 @@
                        switch ( $postAction ) {
                                case 'saveall':
                                        $taskId = $this->getRequest()->getVal( 
'wptaskid' );
-                                       if( is_null( $taskId ) ) {
+                                       if ( is_null( $taskId ) ) {
                                                throw new MWException( 'taskid 
is required' );
                                        }
                                        $db->updateTaskState( $taskId, 
Task::S_SAVE_CHANGES_ALL );
 
-                                       $job = new ChangeSaverSpawnerJob( 
Title::newMainPage(), array( 'taskid' => $taskId ) );
+                                       $job =
+                                               new ChangeSaverSpawnerJob(
+                                                       Title::newMainPage(),
+                                                       array( 'taskid' => 
$taskId )
+                                               );
                                        JobQueueGroup::singleton()->push( $job 
);
                                        break;
                                case 'savetarget':
                                        $targetId = 
$this->getRequest()->getVal( 'wptargetid' );
-                                       if( is_null( $targetId ) ) {
+                                       if ( is_null( $targetId ) ) {
                                                throw new MWException( 
'targetid is required' );
                                        }
                                        $db->updateTargetState( $targetId, 
Target::S_SAVING );
 
-                                       $job = new ChangeSaverJob( 
Title::newMainPage(), array( 'targetid' => $targetId ) );
+                                       $job =
+                                               new ChangeSaverJob(
+                                                       Title::newMainPage(), 
array( 'targetid' => $targetId )
+                                               );
                                        JobQueueGroup::singleton()->push( $job 
);
                                        break;
                        }
                }
 
                $taskId = isset( $params[0] ) ? $params[0] : '';
-               if( empty( $taskId ) ) {
+               if ( empty( $taskId ) ) {
                        throw new Exception( 'No taskId given to special page' 
);
                }
 
                $task = $db->getTaskFromId( $taskId );
 
-               if( is_null( $task ) ) {
+               if ( is_null( $task ) ) {
                        //TODO easy form to allow entering of task ID to view 
task? (Or list of tasks?)
                        $this->getOutput()->setPageTitle( 'View Task' );
                        $this->getOutput()->addWikiText( 'No task exists with 
the id: ' . $taskId );
+
                        return;
                }
 
@@ -153,7 +172,7 @@
                $actions = $task->getActions()->toArray();
                $html .= Html::element( 'h2', array(), 'Actions (' . count( 
$actions ) . ')' );
                $html .= Html::openElement( 'ul', array( 'id' => 'ma-actions' ) 
);
-               foreach( $actions as $action ) {
+               foreach ( $actions as $action ) {
                        $html .= Html::element(
                                'li',
                                array( 'class' => 'ma-action' ),
@@ -165,7 +184,7 @@
                $matchers = $task->getMatchers()->toArray();
                $html .= Html::element( 'h2', array(), 'Matchers (' . count( 
$matchers ) . ')' );
                $html .= Html::openElement( 'ul', array( 'id' => 'ma-matchers' 
) );
-               foreach( $matchers as $matcher ) {
+               foreach ( $matchers as $matcher ) {
                        $html .= Html::element(
                                'li',
                                array( 'class' => 'ma-matcher' ),
@@ -178,52 +197,70 @@
 
                $html .= Html::element( 'h2', array(), 'Targets (' . count( 
$targets ) . ')' );
 
-               if( $task->getState() == Task::S_TARGETS_FOUND ) {
-                       $changeForm = new HTMLForm( array(
-                               'taskid' => array(
-                                       'type' => 'hidden',
-                                       'default' => $task->getId(),
-                               ),
-                               'action' => array(
-                                       'type' => 'hidden',
-                                       'default' => 'saveall',
-                               ),
-                       ) );
+               if ( $task->getState() == Task::S_TARGETS_FOUND ) {
+                       $changeForm = new HTMLForm(
+                               array(
+                                       'taskid' => array(
+                                               'type' => 'hidden',
+                                               'default' => $task->getId(),
+                                       ),
+                                       'action' => array(
+                                               'type' => 'hidden',
+                                               'default' => 'saveall',
+                                       ),
+                               )
+                       );
                        $changeForm->setContext( $this->getContext() );
-                       $changeForm->setTitle( Title::newFromText( 
'MassAction/View/' . $task->getId(), NS_SPECIAL ) );
+                       $changeForm->setTitle(
+                               Title::newFromText( 'MassAction/View/' . 
$task->getId(), NS_SPECIAL )
+                       );
                        $changeForm->setSubmitText( 'Save All' );
                        $changeForm->prepareForm();
                        $html .= $changeForm->getHtml( '' );
                }
 
                $html .= Html::openElement( 'table', array( 'id' => 
'ma-targets' ) );
-               $html .= Html::rawElement( 'tr', array(),
+               $html .= Html::rawElement(
+                       'tr',
+                       array(),
                        Html::element( 'th', array(), 'Identifier' ) .
                        Html::element( 'th', array(), 'Name' ) .
                        Html::element( 'th', array(), 'State' )
                );
-               foreach( $targets as $target ) {
+               foreach ( $targets as $target ) {
                        $saveTargetButtonHtml = '';
-                       if( $task->getState() != Task::S_SAVE_CHANGES_ALL  && 
$target->getState() == Target::S_NEW ) {
-                               $changeForm = new HTMLForm( array(
-                                       'targetid' => array(
-                                               'type' => 'hidden',
-                                               'default' => $target->getId(),
-                                       ),
-                                       'action' => array(
-                                               'type' => 'hidden',
-                                               'default' => 'savetarget',
-                                       ),
-                               ) );
+                       if ( $task->getState() != Task::S_SAVE_CHANGES_ALL &&
+                               $target->getState() == Target::S_NEW
+                       ) {
+                               $changeForm = new HTMLForm(
+                                       array(
+                                               'targetid' => array(
+                                                       'type' => 'hidden',
+                                                       'default' => 
$target->getId(),
+                                               ),
+                                               'action' => array(
+                                                       'type' => 'hidden',
+                                                       'default' => 
'savetarget',
+                                               ),
+                                       )
+                               );
                                $changeForm->setContext( $this->getContext() );
-                               $changeForm->setTitle( Title::newFromText( 
'MassAction/View/' . $task->getId(), NS_SPECIAL ) );
+                               $changeForm->setTitle(
+                                       Title::newFromText( 'MassAction/View/' 
. $task->getId(), NS_SPECIAL )
+                               );
                                $changeForm->setSubmitText( 'Save' );
                                $changeForm->prepareForm();
                                $saveTargetButtonHtml = $changeForm->getHtml( 
'' );
                        }
-                       $html .= Html::rawElement( 'tr', array( 'class' => 
'ma-target' ),
+                       $html .= Html::rawElement(
+                               'tr',
+                               array( 'class' => 'ma-target' ),
                                Html::element( 'td', array(), 
$target->getTargetIdentifier() ) .
-                               Html::rawElement( 'td', array(), Html::element( 
'a', array( 'href' => $target->getLink() ), $target->getName() ) ) .
+                               Html::rawElement(
+                                       'td',
+                                       array(),
+                                       Html::element( 'a', array( 'href' => 
$target->getLink() ), $target->getName() )
+                               ) .
                                Html::rawElement( 'td', array(), 
$target->getStateString() . $saveTargetButtonHtml )
                        );
                }
@@ -233,7 +270,7 @@
        }
 
        private function executeNewTask( $params ) {
-               if( !$this->getRequest()->wasPosted() ) {
+               if ( !$this->getRequest()->wasPosted() ) {
                        $target = isset( $params[0] ) ? $params[0] : '';
                        if ( empty( $target ) ) {
                                $this->executeSelectTargetForm();
@@ -250,14 +287,18 @@
 
                $html = '';
                $html .= Html::openElement( 'ul' );
-               foreach( array_keys( 
MassActionExt::getDefaultInstance()->getTargets() ) as $type ) {
+               foreach ( array_keys( 
MassActionExt::getDefaultInstance()->getTargets() ) as $type ) {
                        $html .= Html::openElement( 'li' );
-                       $html .= Linker::specialLink( 'MassAction/New/' . 
ucfirst( $type ), 'massaction-newtask' );
+                       $html .= Linker::specialLink(
+                               'MassAction/New/' . ucfirst( $type ),
+                               'massaction-newtask'
+                       );
                        $html .= ' - ' . ucfirst( $type );
                        $html .= Html::closeElement( 'li' );
                }
                $html .= Html::closeElement( 'ul' );
                $this->getOutput()->addHTML( $html );
+
                return;
        }
 
@@ -276,7 +317,7 @@
                                        'type' => 'text',
                                        'label' => 'Summary',
                                        'cssclass' => 'ma-task',
-                                       'section' => 
'massaction-specialpage-general-section'
+                                       'section' => 
'massaction-specialpage-general-section',
                                ),
                                'targettype' => array(
                                        'type' => 'hidden',
@@ -293,7 +334,9 @@
 
                $htmlForm = new HTMLForm( $formDescription );
                $htmlForm->setContext( $this->getContext() );
-               $htmlForm->setTitle( Title::newFromText( 'MassAction/New/' . 
ucfirst( $target ), NS_SPECIAL ) );
+               $htmlForm->setTitle(
+                       Title::newFromText( 'MassAction/New/' . ucfirst( 
$target ), NS_SPECIAL )
+               );
                $htmlForm->setDisplayFormat( 'div' );
                $htmlForm->prepareForm();
                $this->getOutput()->addHTML( $htmlForm->getHTML( '' ) );
@@ -309,13 +352,13 @@
        private function getMatchersFormDescription( $target ) {
                /** @var HasForm[] $targetMatchers */
                $targetMatchers = 
MassActionExt::getDefaultInstance()->getMatchers( $target );
-               if( is_null( $targetMatchers ) ) {
+               if ( is_null( $targetMatchers ) ) {
                        throw new Exception( 'No Matchers found for target \'' 
. $target . '\'' );
                }
                $formDescription = array();
-               foreach( $targetMatchers as $matcherClass ) {
-                       foreach( $matcherClass::getFormDescription() as $key => 
$element ) {
-                               if( array_key_exists( 'cssclass', $element ) ) {
+               foreach ( $targetMatchers as $matcherClass ) {
+                       foreach ( $matcherClass::getFormDescription() as $key 
=> $element ) {
+                               if ( array_key_exists( 'cssclass', $element ) ) 
{
                                        $element['cssclass'] .= ' ma-matcher';
                                } else {
                                        $element['cssclass'] = 'ma-matcher';
@@ -325,6 +368,7 @@
                                $formDescription[$key] = $element;
                        }
                }
+
                return $formDescription;
        }
 
@@ -337,13 +381,13 @@
        private function getActionsFormDescription( $target ) {
                /** @var HasForm[] $targetActions */
                $targetActions = 
MassActionExt::getDefaultInstance()->getActions( $target );
-               if( is_null( $targetActions ) ) {
+               if ( is_null( $targetActions ) ) {
                        throw new Exception( 'No Actions found for target \'' . 
$target . '\'' );
                }
                $formDescription = array();
-               foreach( $targetActions as $actionClass ) {
-                       foreach( $actionClass::getFormDescription() as $key => 
$element ) {
-                               if( array_key_exists( 'cssclass', $element ) ) {
+               foreach ( $targetActions as $actionClass ) {
+                       foreach ( $actionClass::getFormDescription() as $key => 
$element ) {
+                               if ( array_key_exists( 'cssclass', $element ) ) 
{
                                        $element['cssclass'] .= ' ma-action';
                                } else {
                                        $element['cssclass'] = 'ma-action';
@@ -355,6 +399,7 @@
                                $formDescription[$key] = $element;
                        }
                }
+
                return $formDescription;
        }
 
@@ -368,41 +413,47 @@
                $summary = $this->getRequest()->getVal( 'wpsummary' );
                $targetType = $this->getRequest()->getVal( 'wptargettype' );
 
-               if( is_null( $summary ) ) {
+               if ( is_null( $summary ) ) {
                        throw new MWException( 'summary is required' );
                }
-               if( is_null( $targetType ) ) {
+               if ( is_null( $targetType ) ) {
                        throw new MWException( 'targettype is required' );
                }
 
                $targetMatchers = 
MassActionExt::getDefaultInstance()->getMatchers( $targetType );
-               if( is_null( $targetMatchers ) ) {
+               if ( is_null( $targetMatchers ) ) {
                        throw new Exception( 'Couldn\'t find matchers for 
target' );
                }
                $matchers = new Matchers();
-               foreach( $targetMatchers as $matcherKey => $matcherClass ) {
+               foreach ( $targetMatchers as $matcherKey => $matcherClass ) {
                        /** @var HasForm $matcherClass */
-                       foreach( $matcherClass::getObjectsFromWebRequest( 
$this->getRequest() ) as $extractedObject ) {
+                       foreach (
+                               $matcherClass::getObjectsFromWebRequest(
+                                       $this->getRequest()
+                               ) as $extractedObject ) {
                                $matchers->addMatcher( $extractedObject );
                        }
                }
 
                $targetActions = 
MassActionExt::getDefaultInstance()->getActions( $targetType );
-               if( is_null( $targetActions ) ) {
+               if ( is_null( $targetActions ) ) {
                        throw new Exception( 'Couldn\'t find actions for 
target' );
                }
                $actions = array();
-               foreach( $targetActions as $actionKey => $actionClass ) {
+               foreach ( $targetActions as $actionKey => $actionClass ) {
                        /** @var HasForm $actionClass */
-                       foreach( $actionClass::getObjectsFromWebRequest( 
$this->getRequest() ) as $extractedObject ) {
+                       foreach (
+                               $actionClass::getObjectsFromWebRequest(
+                                       $this->getRequest()
+                               ) as $extractedObject ) {
                                $actions[] = $extractedObject;
                        }
                }
 
-               if( count( $matchers->toArray() ) == 0 ) {
+               if ( count( $matchers->toArray() ) == 0 ) {
                        throw new MWException( 'No matchers found' );
                }
-               if( empty( $actions ) ) {
+               if ( empty( $actions ) ) {
                        throw new MWException( 'No actions found' );
                }
 
@@ -431,6 +482,5 @@
                $link = Linker::specialLink( 'MassAction/View/' . 
$task->getId(), 'massaction-viewtask' );
                $this->getOutput()->addHTML( '<p>' . $link . '</p>' );
        }
-
 
 }
diff --git a/src/Mediawiki/ApiRequestor.php b/src/Mediawiki/ApiRequestor.php
index b18c3e0..b055993 100644
--- a/src/Mediawiki/ApiRequestor.php
+++ b/src/Mediawiki/ApiRequestor.php
@@ -52,7 +52,8 @@
                        try {
                                $api->execute();
                                break; // Continue after the while block if the 
API request succeeds
-                       } catch ( UsageException $e ) {
+                       }
+                       catch ( UsageException $e ) {
                                $attemptCount++;
                                $errorCode = $e->getCodeString();
                                // If the failure is not caused by an edit 
conflict or if there
diff --git a/src/Targets/File/FileData.php b/src/Targets/File/FileData.php
index 6386a97..a600086 100644
--- a/src/Targets/File/FileData.php
+++ b/src/Targets/File/FileData.php
@@ -15,8 +15,7 @@
         * @param File $file
         */
        public function __construct( File $file ) {
-               $array = array(
-               );
+               $array = array();
                parent::__construct( $array );
        }
 
diff --git a/src/Targets/WikiPage/Actions/AppendAction.php 
b/src/Targets/WikiPage/Actions/AppendAction.php
index 640f295..b4c692d 100644
--- a/src/Targets/WikiPage/Actions/AppendAction.php
+++ b/src/Targets/WikiPage/Actions/AppendAction.php
@@ -29,9 +29,10 @@
        public function getDescription() {
                $length = strlen( $this->text );
                $snippet = '"' . substr( $this->text, 0, 25 ) . '"';
-               if( $length > 25 ) {
+               if ( $length > 25 ) {
                        $snippet = $snippet . '... (trimmed to 25 characters)';
                }
+
                return 'Appends ' . $length . ' characters to Page ' . $snippet;
        }
 
@@ -45,10 +46,13 @@
         * @return WikiPageData
         */
        public function getChangedData( TargetData $data ) {
-               if( !$data instanceof WikiPageData ) {
-                       throw new InvalidArgumentException( __METHOD__ . ' can 
only work on WikiPageData objects' );
+               if ( !$data instanceof WikiPageData ) {
+                       throw new InvalidArgumentException(
+                               __METHOD__ . ' can only work on WikiPageData 
objects'
+                       );
                }
                $data->setText( $data->getText() . $this->getText() );
+
                return $data;
        }
 
@@ -58,9 +62,10 @@
         * @return AppendAction
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
+
                return new AppendAction(
                        $serialization['text']
                );
@@ -94,7 +99,7 @@
                                        'PageActionAppendText' => array(
                                                'label' => 'Text',
                                                'type' => 'textarea',
-                                       )
+                                       ),
                                ),
                        ),
                );
@@ -108,9 +113,10 @@
        public static function getObjectsFromWebRequest( WebRequest $request ) {
                $clones = $request->getArray( 'wpPageActionAppendText', array() 
);
                $objects = array();
-               foreach( $clones as $clone ) {
+               foreach ( $clones as $clone ) {
                        $objects[] = new self( $clone['PageActionAppendText'] );
                }
+
                return $objects;
        }
 }
diff --git a/src/Targets/WikiPage/Actions/PrependAction.php 
b/src/Targets/WikiPage/Actions/PrependAction.php
index ba8efed..b32fed5 100644
--- a/src/Targets/WikiPage/Actions/PrependAction.php
+++ b/src/Targets/WikiPage/Actions/PrependAction.php
@@ -29,9 +29,10 @@
        public function getDescription() {
                $length = strlen( $this->text );
                $snippet = '"' . substr( $this->text, 0, 25 ) . '"';
-               if( $length > 25 ) {
+               if ( $length > 25 ) {
                        $snippet = $snippet . '... (trimmed to 25 characters)';
                }
+
                return 'Prepends ' . $length . ' characters to Page ' . 
$snippet;
        }
 
@@ -45,10 +46,13 @@
         * @return WikiPageData
         */
        public function getChangedData( TargetData $data ) {
-               if( !$data instanceof WikiPageData ) {
-                       throw new InvalidArgumentException( __METHOD__ . ' can 
only work on WikiPageData objects' );
+               if ( !$data instanceof WikiPageData ) {
+                       throw new InvalidArgumentException(
+                               __METHOD__ . ' can only work on WikiPageData 
objects'
+                       );
                }
                $data->setText( $this->getText() . $data->getText() );
+
                return $data;
        }
 
@@ -58,9 +62,10 @@
         * @return PrependAction
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
+
                return new PrependAction(
                        $serialization['text']
                );
@@ -94,7 +99,7 @@
                                        'PageActionPrependText' => array(
                                                'label' => 'Text',
                                                'type' => 'textarea',
-                                       )
+                                       ),
                                ),
                        ),
                );
@@ -108,9 +113,10 @@
        public static function getObjectsFromWebRequest( WebRequest $request ) {
                $clones = $request->getArray( 'wpPageActionPrependText', 
array() );
                $objects = array();
-               foreach( $clones as $clone ) {
+               foreach ( $clones as $clone ) {
                        $objects[] = new self( $clone['PageActionPrependText'] 
);
                }
+
                return $objects;
        }
 }
diff --git a/src/Targets/WikiPage/Actions/RegexRenameAction.php 
b/src/Targets/WikiPage/Actions/RegexRenameAction.php
index 26a8270..6b3d16e 100644
--- a/src/Targets/WikiPage/Actions/RegexRenameAction.php
+++ b/src/Targets/WikiPage/Actions/RegexRenameAction.php
@@ -39,12 +39,15 @@
         * @return WikiPageData
         */
        public function getChangedData( TargetData $data ) {
-               if( !$data instanceof WikiPageData ) {
-                       throw new InvalidArgumentException( __METHOD__ . ' can 
only work on WikiPageData objects' );
+               if ( !$data instanceof WikiPageData ) {
+                       throw new InvalidArgumentException(
+                               __METHOD__ . ' can only work on WikiPageData 
objects'
+                       );
                }
                $data->setTitle(
                        preg_replace( '/' . $this->pattern . '/', 
$this->replacement, $data->getTitle() )
                );
+
                return $data;
        }
 
@@ -65,9 +68,10 @@
         * @return RegexRenameAction
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
+
                return new RegexRenameAction(
                        $serialization['pattern'],
                        $serialization['replacement']
@@ -78,8 +82,12 @@
         * @return string description of the object
         */
        public function getDescription() {
-               return 'Performs a regex replace on the title using the pattern 
\'' .  $this->pattern. '\'' .
-               ' and replacement \'' . $this->replacement . '\'';
+               return 'Performs a regex replace on the title using the pattern 
\'' .
+               $this->pattern .
+               '\'' .
+               ' and replacement \'' .
+               $this->replacement .
+               '\'';
        }
 
        /**
@@ -100,7 +108,7 @@
                                        'PageActionRegexRenameReplacement' => 
array(
                                                'type' => 'text',
                                                'label' => 'Replacement',
-                                       )
+                                       ),
                                ),
                        ),
                );
@@ -114,12 +122,13 @@
        public static function getObjectsFromWebRequest( WebRequest $request ) {
                $clones = $request->getArray( 'wpPageActionRegexRename', 
array() );
                $objects = array();
-               foreach( $clones as $clone ) {
+               foreach ( $clones as $clone ) {
                        $objects[] = new self(
                                $clone['PageActionRegexRenamePattern'],
                                $clone['PageActionRegexRenameReplacement']
                        );
                }
+
                return $objects;
        }
 
diff --git a/src/Targets/WikiPage/Actions/RegexReplaceAction.php 
b/src/Targets/WikiPage/Actions/RegexReplaceAction.php
index 55fdeb5..0b31052 100644
--- a/src/Targets/WikiPage/Actions/RegexReplaceAction.php
+++ b/src/Targets/WikiPage/Actions/RegexReplaceAction.php
@@ -39,12 +39,15 @@
         * @return WikiPageData
         */
        public function getChangedData( TargetData $data ) {
-               if( !$data instanceof WikiPageData ) {
-                       throw new InvalidArgumentException( __METHOD__ . ' can 
only work on WikiPageData objects' );
+               if ( !$data instanceof WikiPageData ) {
+                       throw new InvalidArgumentException(
+                               __METHOD__ . ' can only work on WikiPageData 
objects'
+                       );
                }
                $data->setText(
                        preg_replace( '/' . $this->pattern . '/', 
$this->replacement, $data->getText() )
                );
+
                return $data;
        }
 
@@ -65,9 +68,10 @@
         * @return RegexReplaceAction
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
+
                return new RegexReplaceAction(
                        $serialization['pattern'],
                        $serialization['replacement']
@@ -78,8 +82,12 @@
         * @return string description of the object
         */
        public function getDescription() {
-               return 'Performs a regex replace on the content using the 
pattern \'' .  $this->pattern. '\'' .
-               ' and replacement \'' . $this->replacement . '\'';
+               return 'Performs a regex replace on the content using the 
pattern \'' .
+               $this->pattern .
+               '\'' .
+               ' and replacement \'' .
+               $this->replacement .
+               '\'';
        }
 
        /**
@@ -100,7 +108,7 @@
                                        'PageActionRegexReplaceReplacement' => 
array(
                                                'type' => 'text',
                                                'label' => 'Replacement',
-                                       )
+                                       ),
                                ),
                        ),
                );
@@ -114,12 +122,13 @@
        public static function getObjectsFromWebRequest( WebRequest $request ) {
                $clones = $request->getArray( 'wpPageActionRegexReplace', 
array() );
                $objects = array();
-               foreach( $clones as $clone ) {
+               foreach ( $clones as $clone ) {
                        $objects[] = new self(
                                $clone['PageActionRegexReplacePattern'],
                                $clone['PageActionRegexReplaceReplacement']
                        );
                }
+
                return $objects;
        }
 
diff --git a/src/Targets/WikiPage/Matchers/NamespaceMatcher.php 
b/src/Targets/WikiPage/Matchers/NamespaceMatcher.php
index c5b41e4..204bdef 100644
--- a/src/Targets/WikiPage/Matchers/NamespaceMatcher.php
+++ b/src/Targets/WikiPage/Matchers/NamespaceMatcher.php
@@ -54,9 +54,10 @@
         * @return NamespaceMatcher
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
+
                return new NamespaceMatcher(
                        $serialization['namespaces']
                );
@@ -83,14 +84,14 @@
                $namespaces = array();
                global $wgContLang;
                //TODO namespace list to be made in constructor??
-               foreach( $wgContLang->getFormattedNamespaces() as $nsId => 
$title ) {
+               foreach ( $wgContLang->getFormattedNamespaces() as $nsId => 
$title ) {
                        //Give the mainspace a name if it doesn't have one
-                       if( $nsId === 0 && $title === '' ) {
+                       if ( $nsId === 0 && $title === '' ) {
                                //TODO localise?
                                $title = 'Main';
                        }
                        //Ignore negative namespaces
-                       if( $nsId < 0 ) {
+                       if ( $nsId < 0 ) {
                                continue;
                        }
                        $namespaces[$title] = $nsId;
@@ -125,31 +126,31 @@
         * @return NamespaceMatcher[]
         */
        public static function getObjectsFromWebRequest( WebRequest $request ) {
-               if( is_null( $request->getVal( 'wpPageMatcherNamespaceEnabled' 
) ) ) {
+               if ( is_null( $request->getVal( 'wpPageMatcherNamespaceEnabled' 
) ) ) {
                        return array();
                }
 
                $namespaces = $request->getArray( 
'wpPageMatcherNamespaceOptions' );
-               if( is_null( $namespaces ) ) {
+               if ( is_null( $namespaces ) ) {
                        return array();
                }
 
                $matcherType = $request->getVal( 'wpPageMatcherNamespaceType' );
 
                $matcherNamespaces = array();
-               foreach( $namespaces as $namespace ) {
+               foreach ( $namespaces as $namespace ) {
                        $matcherNamespaces[] = str_replace( 'ns-', '', 
$namespace );
                }
 
                //If looking for namespaces not selected flip the ids
-               if( $matcherType === 'not' ) {
+               if ( $matcherType === 'not' ) {
                        global $wgContLang;
-                       foreach( $wgContLang->getFormattedNamespaces() as $nsId 
=> $nsName ) {
+                       foreach ( $wgContLang->getFormattedNamespaces() as 
$nsId => $nsName ) {
                                //Ignore negative namespaces..
-                               if( $nsId < 0 ) {
+                               if ( $nsId < 0 ) {
                                        continue;
                                }
-                               if( !in_array( $nsId, $matcherNamespaces ) ) {
+                               if ( !in_array( $nsId, $matcherNamespaces ) ) {
                                        $matcherNamespaces[] = $nsId;
                                } else {
                                        unset( $matcherNamespaces[array_search( 
$nsId, $matcherNamespaces )] );
@@ -158,7 +159,7 @@
                        //TODO invert the list of ns!
                }
 
-               if( !empty( $matcherNamespaces ) ) {
+               if ( !empty( $matcherNamespaces ) ) {
                        return array( new self( array_values( 
$matcherNamespaces ) ) );
                } else {
                        return array();
diff --git a/src/Targets/WikiPage/Matchers/RedirectMatcher.php 
b/src/Targets/WikiPage/Matchers/RedirectMatcher.php
index 1fd2e3a..b360ee5 100644
--- a/src/Targets/WikiPage/Matchers/RedirectMatcher.php
+++ b/src/Targets/WikiPage/Matchers/RedirectMatcher.php
@@ -20,11 +20,11 @@
         * @param bool $redirectState
         */
        public function __construct( $redirectState ) {
-               $this->redirectState = (bool) $redirectState;
+               $this->redirectState = (bool)$redirectState;
        }
 
        public function getDescription() {
-               if( $this->redirectState ) {
+               if ( $this->redirectState ) {
                        return 'Matches Redirects';
                } else {
                        return 'Matches Non Redirects';
@@ -58,9 +58,10 @@
         * @return RedirectMatcher
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
+
                return new RedirectMatcher(
                        $serialization['redirect']
                );
@@ -80,7 +81,7 @@
                );
        }
 
-       public static function getFormDescription(){
+       public static function getFormDescription() {
                return array(
                        'PageMatcherRedirectEnabled' => array(
                                'type' => 'check',
@@ -103,13 +104,13 @@
         * @return RedirectMatcher[]
         */
        public static function getObjectsFromWebRequest( WebRequest $request ) {
-               if( is_null( $request->getVal( 'wpPageMatcherRedirectEnabled' ) 
) ) {
+               if ( is_null( $request->getVal( 'wpPageMatcherRedirectEnabled' 
) ) ) {
                        return array();
                }
                $redirects = $request->getVal( 'wpPageMatcherRedirectOption' );
-               if( $redirects === 'only' ) {
+               if ( $redirects === 'only' ) {
                        return array( new self( 1 ) );
-               } else if( $redirects === 'none' ) {
+               } else if ( $redirects === 'none' ) {
                        return array( new self( 0 ) );
                } else {
                        return array();
diff --git a/src/Targets/WikiPage/Matchers/TitleRegexMatcher.php 
b/src/Targets/WikiPage/Matchers/TitleRegexMatcher.php
index 5551ef7..732ffc8 100644
--- a/src/Targets/WikiPage/Matchers/TitleRegexMatcher.php
+++ b/src/Targets/WikiPage/Matchers/TitleRegexMatcher.php
@@ -31,11 +31,11 @@
         * @param MassActionDb $db
         */
        public function __construct( $titleRegex, MassActionDb $db = null ) {
-               if( !is_string( $titleRegex ) ) {
+               if ( !is_string( $titleRegex ) ) {
                        throw new InvalidArgumentException( '$titleRegex must 
be a string' );
                }
                $this->titleRegex = $titleRegex;
-               if( $db === null ) {
+               if ( $db === null ) {
                        $db = MassActionExt::getDefaultInstance()->getDb();
                }
                $this->db = $db;
@@ -52,20 +52,23 @@
 
                $matched = preg_match_all( $allowedMatchingRegex, $regex, 
$matches );
                $matches = $matches[0];
-               if( $matched === 0 ) {
+               if ( $matched === 0 ) {
                        return preg_quote( $regex );
-               } elseif( $matched === false ) {
+               } elseif ( $matched === false ) {
                        throw new RuntimeException( 'Failed to sanitize regex' 
);
                }
 
                $parts = preg_split( $allowedMatchingRegex, $regex );
-               $parts = array_map( function( $value ) {
-                       return preg_quote( $value );
-               }, $parts );
+               $parts = array_map(
+                       function ( $value ) {
+                               return preg_quote( $value );
+                       },
+                       $parts
+               );
 
                $regex = $parts[0];
-               foreach( $matches as $key => $char ) {
-                       $regex .= $char . $parts[ $key + 1 ];
+               foreach ( $matches as $key => $char ) {
+                       $regex .= $char . $parts[$key + 1];
                }
 
                return $regex;
@@ -97,7 +100,7 @@
                        'PageMatcherTitleRegex' => array(
                                'type' => 'text',
                                'label' => 'Title Regex',
-                               'help-message' => 
'massaction-target-wikipage-titleregexmatcher-regex-help'
+                               'help-message' => 
'massaction-target-wikipage-titleregexmatcher-regex-help',
                        ),
                );
        }
@@ -108,14 +111,15 @@
         * @return TitleRegexMatcher[]
         */
        public static function getObjectsFromWebRequest( WebRequest $request ) {
-               if( is_null( $request->getVal( 'wpPageMatcherTitleRegexEnabled' 
) ) ) {
+               if ( is_null( $request->getVal( 
'wpPageMatcherTitleRegexEnabled' ) ) ) {
                        return array();
                }
                $titleRegex = $request->getVal( 'wpPageMatcherTitleRegex' );
-               if( !is_string( $titleRegex ) ) {
+               if ( !is_string( $titleRegex ) ) {
                        return array();
                }
                $titleRegex = self::sanitizeRegex( $titleRegex, array( '*', 
'.', '?' ) );
+
                return array( new TitleRegexMatcher( $titleRegex ) );
        }
 
@@ -151,9 +155,10 @@
         * @return RedirectMatcher
         */
        public static function newFromJson( $serialization ) {
-               if( !is_array( $serialization ) ) {
+               if ( !is_array( $serialization ) ) {
                        $serialization = json_decode( $serialization, true );
                }
+
                return new TitleRegexMatcher(
                        $serialization['titleregex']
                );
diff --git a/src/Targets/WikiPage/WikiPageLister.php 
b/src/Targets/WikiPage/WikiPageLister.php
index debd979..a47414c 100644
--- a/src/Targets/WikiPage/WikiPageLister.php
+++ b/src/Targets/WikiPage/WikiPageLister.php
@@ -25,28 +25,29 @@
                $vars = array( 'page_id' );
                $tables = array( 'page' );
 
-               foreach( $matchers->toArray() as $matcher ) {
+               foreach ( $matchers->toArray() as $matcher ) {
                        $tables = array_unique( array_merge( $tables, 
$matcher->getDbTables() ) );
                        $vars = array_merge( $vars, $matcher->getDbVars() );
                        $conds = array_unique( array_merge( $conds, 
$matcher->getDbConds() ) );
                }
 
                // Dont list if there are no conditions
-               if( empty( $conds ) ) {
+               if ( empty( $conds ) ) {
                        throw new MWException( 'No $conds were found in ' . 
__CLASS__ );
                }
 
                $selectResult = $dbr->select( $tables, $vars, $conds, 
__METHOD__ );
 
-               if( $selectResult == false ) {
+               if ( $selectResult == false ) {
                        throw new MWException( 'TargetLister had a db issue!' );
                }
 
                $targets = array();
-               foreach( $selectResult->result as $row ) {
+               foreach ( $selectResult->result as $row ) {
                        //TODO the 'wikipage' below for the target type should 
probably come from somewhere...
                        $targets[] = new WikiPageTarget( null, null, 
'wikipage', $row['page_id'] );
                }
+
                return $targets;
        }
 
diff --git a/src/Targets/WikiPage/WikiPageTarget.php 
b/src/Targets/WikiPage/WikiPageTarget.php
index 6c32f87..b79c1be 100644
--- a/src/Targets/WikiPage/WikiPageTarget.php
+++ b/src/Targets/WikiPage/WikiPageTarget.php
@@ -40,15 +40,17 @@
         * @return bool
         */
        public function saveChangedData( Task $task, TargetData $newData ) {
-               if( !$newData instanceof WikiPageData ) {
-                       throw new InvalidArgumentException( __METHOD__ . ' can 
only work on WikiPageData objects' );
+               if ( !$newData instanceof WikiPageData ) {
+                       throw new InvalidArgumentException(
+                               __METHOD__ . ' can only work on WikiPageData 
objects'
+                       );
                }
 
                $apiRequestor = new ApiRequestor();
                $targetData = $this->getTargetData();
                $user = User::newFromId( $task->getUserId() );
 
-               if( $targetData->getText() !== $newData->getText() ) {
+               if ( $targetData->getText() !== $newData->getText() ) {
                        try {
                                $apiRequestor->makeAPIRequest(
                                        array(
@@ -69,7 +71,7 @@
                        }
                }
 
-               if( $targetData->getTitle() !== $newData->getTitle() ) {
+               if ( $targetData->getTitle() !== $newData->getTitle() ) {
                        try {
                                $apiRequestor->makeAPIRequest(
                                        array(
@@ -85,6 +87,7 @@
                        }
                        catch ( UsageException $e ) {
                                wfDebugLog( 'massaction', $e->getMessage() );
+
                                //TODO some other way to show failed changes 
that mean we can continue with other actions?
                                return false;
                        }
diff --git a/tests/phpunit/DataModel/ActionsTest.php 
b/tests/phpunit/DataModel/ActionsTest.php
index 3e0120a..8d85e19 100644
--- a/tests/phpunit/DataModel/ActionsTest.php
+++ b/tests/phpunit/DataModel/ActionsTest.php
@@ -35,21 +35,23 @@
                        array( array(), array() ),
                        array(
                                array( new AppendAction( 'foo' ) ),
-                               array( array(
-                                       'class' => 
'MassAction\Targets\WikiPage\Actions\AppendAction',
-                                       'text' => 'foo',
-                               ) )
+                               array(
+                                       array(
+                                               'class' => 
'MassAction\Targets\WikiPage\Actions\AppendAction',
+                                               'text' => 'foo',
+                                       ),
+                               ),
                        ),
                        array(
                                array( new AppendAction( 'foo' ), new 
AppendAction( 'bar' ) ),
                                array(
                                        array(
-                                       'class' => 
'MassAction\Targets\WikiPage\Actions\AppendAction',
-                                       'text' => 'foo',
+                                               'class' => 
'MassAction\Targets\WikiPage\Actions\AppendAction',
+                                               'text' => 'foo',
                                        ),
                                        array(
-                                       'class' => 
'MassAction\Targets\WikiPage\Actions\AppendAction',
-                                       'text' => 'bar',
+                                               'class' => 
'MassAction\Targets\WikiPage\Actions\AppendAction',
+                                               'text' => 'bar',
                                        ),
                                ),
                        ),
@@ -65,4 +67,4 @@
                $this->assertEquals( $expectedArray, $array );
        }
 
-} 
\ No newline at end of file
+}
diff --git a/tests/phpunit/DataModel/MatchersTest.php 
b/tests/phpunit/DataModel/MatchersTest.php
index 45e85d3..07b6e88 100644
--- a/tests/phpunit/DataModel/MatchersTest.php
+++ b/tests/phpunit/DataModel/MatchersTest.php
@@ -36,10 +36,12 @@
                        array( array(), array() ),
                        array(
                                array( new RedirectMatcher( true ) ),
-                               array( array(
-                                       'class' => 
'MassAction\Targets\WikiPage\Matchers\RedirectMatcher',
-                                       'redirect' => true,
-                               ) )
+                               array(
+                                       array(
+                                               'class' => 
'MassAction\Targets\WikiPage\Matchers\RedirectMatcher',
+                                               'redirect' => true,
+                                       ),
+                               ),
                        ),
                        array(
                                array( new RedirectMatcher( true ), new 
NamespaceMatcher( array( 0, 5 ) ) ),
@@ -66,4 +68,4 @@
                $this->assertEquals( $expectedArray, $array );
        }
 
-} 
\ No newline at end of file
+}
diff --git a/tests/phpunit/DataModel/TaskTest.php 
b/tests/phpunit/DataModel/TaskTest.php
index 1aa78a8..d754a10 100644
--- a/tests/phpunit/DataModel/TaskTest.php
+++ b/tests/phpunit/DataModel/TaskTest.php
@@ -17,7 +17,17 @@
 
        public function provideValidConstructionData() {
                return array(
-                       array( 1, '2014-02-19', 1, 'foo', 'bar', new 
Matchers(), new Actions(), Task::S_NEW, 'New' ),
+                       array(
+                               1,
+                               '2014-02-19',
+                               1,
+                               'foo',
+                               'bar',
+                               new Matchers(),
+                               new Actions(),
+                               Task::S_NEW,
+                               'New',
+                       ),
                        array( null, null, 1, 'foo', 'bar', new Matchers(), new 
Actions(), Task::S_NEW, 'New' ),
                );
        }
@@ -25,8 +35,21 @@
        /**
         * @dataProvider provideValidConstructionData
         */
-       public function testConstruction( $id, $dateCreated, $userId, $summary, 
$targetType, $matchers, $actions, $state, $stateString ) {
-               $task = new Task( $id, $dateCreated, $userId, $summary, 
$targetType, $matchers, $actions, $state );
+       public function testConstruction(
+               $id,
+               $dateCreated,
+               $userId,
+               $summary,
+               $targetType,
+               $matchers,
+               $actions,
+               $state,
+               $stateString
+       ) {
+               $task =
+                       new Task(
+                               $id, $dateCreated, $userId, $summary, 
$targetType, $matchers, $actions, $state
+                       );
                $this->assertEquals( $id, $task->getId() );
                $this->assertEquals( $dateCreated, $task->getDateCreated() );
                $this->assertEquals( $userId, $task->getUserId() );
@@ -38,4 +61,4 @@
                $this->assertEquals( $stateString, $task->getStateString() );
        }
 
-} 
\ No newline at end of file
+}
diff --git a/tests/phpunit/Log/LogFormatterTest.php 
b/tests/phpunit/Log/LogFormatterTest.php
index 9020433..e998fba 100644
--- a/tests/phpunit/Log/LogFormatterTest.php
+++ b/tests/phpunit/Log/LogFormatterTest.php
@@ -21,4 +21,4 @@
                $this->assertInstanceOf( 'MassAction\Log\LogFormatter', 
$formatter );
        }
 
-} 
\ No newline at end of file
+}
diff --git a/tests/phpunit/MassActionDbTest.php 
b/tests/phpunit/MassActionDbTest.php
index 364f0c5..027a7cd 100644
--- a/tests/phpunit/MassActionDbTest.php
+++ b/tests/phpunit/MassActionDbTest.php
@@ -45,4 +45,4 @@
                $this->assertEquals( "'Foo'", $db->addQuotes( 'Foo' ) );
        }
 
-} 
\ No newline at end of file
+}
diff --git a/tests/phpunit/MassActionExtTest.php 
b/tests/phpunit/MassActionExtTest.php
index baedb54..748258c 100644
--- a/tests/phpunit/MassActionExtTest.php
+++ b/tests/phpunit/MassActionExtTest.php
@@ -29,7 +29,7 @@
        public function testConstructionHandlesConfigCorrectly() {
                global $wgMassActionConfig;
                $this->stashMwGlobals( 'wgMassActionConfig' );
-               require ( __DIR__ . '/../../config/default.php' );
+               require( __DIR__ . '/../../config/default.php' );
                $instance = new MassActionExt( $wgMassActionConfig );
 
                $this->assertEquals(
@@ -83,4 +83,4 @@
                $this->assertNull( $instance->getListerForTargetType( 
'FooBarBaz123' ) );
        }
 
-} 
\ No newline at end of file
+}
diff --git a/tests/phpunit/Targets/WikiPage/Matchers/TitleRegexMatcherTest.php 
b/tests/phpunit/Targets/WikiPage/Matchers/TitleRegexMatcherTest.php
index d6cd980..4d4a1b6 100644
--- a/tests/phpunit/Targets/WikiPage/Matchers/TitleRegexMatcherTest.php
+++ b/tests/phpunit/Targets/WikiPage/Matchers/TitleRegexMatcherTest.php
@@ -33,7 +33,7 @@
                                        'wpPageMatcherTitleRegex' => 
'FooBarBaz',
                                ),
                                array(
-                                       'FooBarBaz'
+                                       'FooBarBaz',
                                ),
                        ),
                        'enabled with * - 1 matcher (no escape)' => array(
@@ -42,7 +42,7 @@
                                        'wpPageMatcherTitleRegex' => 
'FooBarBaz*',
                                ),
                                array(
-                                       'FooBarBaz*'
+                                       'FooBarBaz*',
                                ),
                        ),
                        'enabled with (|) - 1 matcher (escaped)' => array(
@@ -51,7 +51,7 @@
                                        'wpPageMatcherTitleRegex' => 
'FooBarBaz(|)',
                                ),
                                array(
-                                       'FooBarBaz\(\|\)'
+                                       'FooBarBaz\(\|\)',
                                ),
                        ),
                        '1 complex' => array(
@@ -60,7 +60,7 @@
                                        'wpPageMatcherTitleRegex' => 
'\*LaLa\*Foo\/Bar(|)\w/*Baz\?*\.ham?*',
                                ),
                                array(
-                                       
'\\\\\\*LaLa\\\\\\*Foo\\\/Bar\(\|\)\\\\w/*Baz\\\\\\?*\\\\\\.ham?*'
+                                       
'\\\\\\*LaLa\\\\\\*Foo\\\/Bar\(\|\)\\\\w/*Baz\\\\\\?*\\\\\\.ham?*',
                                ),
                        ),
                );
@@ -73,27 +73,34 @@
                $request = $this->getMockRequest( $requestArray );
                $matchers = TitleRegexMatcher::getObjectsFromWebRequest( 
$request );
                $this->assertEquals( count( $expected ), count( $matchers ) );
-               foreach( $expected as $key => $regex ) {
+               foreach ( $expected as $key => $regex ) {
                        $this->assertEquals( $regex, 
$matchers[$key]->getTitleRegex() );
                }
        }
 
        /**
         * @param array $values
+        *
         * @return WebRequest
         */
-       private function getMockRequest( $values ){
+       private function getMockRequest( $values ) {
                $mock = $this->getMockBuilder( 'WebRequest' )
                        ->disableOriginalConstructor()
                        ->getMock();
                $mock->expects( $this->any() )
                        ->method( 'getVal' )
-                       ->will( $this->returnCallback( function( $param ) use ( 
$values ) {
-                               if( array_key_exists( $param, $values ) ) {
-                                       return $values[$param];
-                               }
-                               return null;
-                       } ) );
+                       ->will(
+                               $this->returnCallback(
+                                       function ( $param ) use ( $values ) {
+                                               if ( array_key_exists( $param, 
$values ) ) {
+                                                       return $values[$param];
+                                               }
+
+                                               return null;
+                                       }
+                               )
+                       );
+
                return $mock;
        }
 
@@ -113,10 +120,15 @@
                        ->getMock();
                $mock->expects( $this->any() )
                        ->method( 'addQuotes' )
-                       ->will( $this->returnCallback( function( $value ) {
-                               return "'$value'";
-                       } ) );
+                       ->will(
+                               $this->returnCallback(
+                                       function ( $value ) {
+                                               return "'$value'";
+                                       }
+                               )
+                       );
+
                return $mock;
        }
 
-}
\ No newline at end of file
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5e56928e42ebe7d5b5ad020f5385525cb53bd02a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MassAction
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to