diff --git a/lib/Config/MP2Migrator.php b/lib/Config/MP2Migrator.php
index 430d321c5a..f85b98b573 100644
--- a/lib/Config/MP2Migrator.php
+++ b/lib/Config/MP2Migrator.php
@@ -944,7 +944,13 @@ class MP2Migrator {
*/
private function replaceMP2Shortcodes($text) {
$text = str_replace('[total_subscribers]', '[mailpoet_subscribers_count]', $text);
- $text = preg_replace_callback('/\[wysija_subscribers_count list_id="(.*)" \]/', array($this, 'replaceMP2ShortcodesCallback'), $text);
+ $text = preg_replace_callback(
+ '/\[wysija_subscribers_count list_id="(.*)" \]/',
+ function ($matches) {
+ return $this->replaceMP2ShortcodesCallback($matches);
+ },
+ $text
+ );
return $text;
}
diff --git a/lib/Config/Populator.php b/lib/Config/Populator.php
index 9400a036bb..5e08bf6538 100644
--- a/lib/Config/Populator.php
+++ b/lib/Config/Populator.php
@@ -544,6 +544,10 @@ class Populator {
$task->save();
}
+ /**
+ * Remove this comment when this private function is actually used
+ * @phpcsSuppress SlevomatCodingStandard.Classes.UnusedPrivateElements
+ */
private function updateFormsSuccessMessages() {
if (version_compare($this->settings->get('db_version', '3.23.2'), '3.23.1', '>')) {
return;
diff --git a/lib/Cron/Daemon.php b/lib/Cron/Daemon.php
index 18a7aff74b..8833bdc1a1 100644
--- a/lib/Cron/Daemon.php
+++ b/lib/Cron/Daemon.php
@@ -9,15 +9,11 @@ if (!defined('ABSPATH')) exit;
class Daemon {
public $timer;
- /** @var SettingsController */
- private $settings_controller;
-
/** @var WorkersFactory */
private $workers_factory;
- function __construct(SettingsController $settings_controller, WorkersFactory $workers_factory) {
+ function __construct(WorkersFactory $workers_factory) {
$this->timer = microtime(true);
- $this->settings_controller = $settings_controller;
$this->workers_factory = $workers_factory;
}
diff --git a/lib/Cron/Workers/WooCommerceSync.php b/lib/Cron/Workers/WooCommerceSync.php
index 481d8259cb..2acf1e379f 100644
--- a/lib/Cron/Workers/WooCommerceSync.php
+++ b/lib/Cron/Workers/WooCommerceSync.php
@@ -22,8 +22,6 @@ class WooCommerceSync extends SimpleWorker {
/** @var WooCommerceHelper */
private $woocommerce_helper;
- private $taskAlreadyInProgress = false;
-
function __construct(WooCommerceSegment $woocommerce_segment, WooCommerceHelper $woocommerce_helper, $timer = false) {
$this->woocommerce_segment = $woocommerce_segment;
$this->woocommerce_helper = $woocommerce_helper;
diff --git a/lib/DI/ContainerConfigurator.php b/lib/DI/ContainerConfigurator.php
index 69cceab83f..ba24ac799b 100644
--- a/lib/DI/ContainerConfigurator.php
+++ b/lib/DI/ContainerConfigurator.php
@@ -123,6 +123,9 @@ class ContainerConfigurator implements IContainerConfigurator {
return $container;
}
+ /**
+ * @phpcsSuppress SlevomatCodingStandard.Classes.UnusedPrivateElements
+ */
private function registerPremiumService(ContainerBuilder $container, $id) {
$container->register($id)
->setPublic(true)
diff --git a/lib/Newsletter/Editor/TitleListTransformer.php b/lib/Newsletter/Editor/TitleListTransformer.php
index fa9f691f5a..ac844a1108 100644
--- a/lib/Newsletter/Editor/TitleListTransformer.php
+++ b/lib/Newsletter/Editor/TitleListTransformer.php
@@ -13,7 +13,9 @@ class TitleListTransformer {
}
function transform($posts) {
- $results = array_map(array($this, 'getPostTitle'), $posts);
+ $results = array_map(function($post) {
+ return $this->getPostTitle($post);
+ }, $posts);
return array(
$this->wrap(array(
diff --git a/lib/Subscribers/NewSubscriberNotificationMailer.php b/lib/Subscribers/NewSubscriberNotificationMailer.php
index 4644964948..1c698d29fe 100644
--- a/lib/Subscribers/NewSubscriberNotificationMailer.php
+++ b/lib/Subscribers/NewSubscriberNotificationMailer.php
@@ -19,18 +19,14 @@ class NewSubscriberNotificationMailer {
/** @var \MailPoet\Mailer\Mailer|null */
private $mailer;
- /** @var Functions */
- private $wordpress_functions;
-
/** @var SettingsController */
private $settings;
/**
* @param \MailPoet\Mailer\Mailer|null $mailer
* @param Renderer|null $renderer
- * @param Functions|null $wordpress_functions
*/
- function __construct($mailer = null, $renderer = null, $wordpress_functions = null) {
+ function __construct($mailer = null, $renderer = null) {
if ($renderer) {
$this->renderer = $renderer;
} else {
@@ -38,11 +34,6 @@ class NewSubscriberNotificationMailer {
$debugging = WP_DEBUG;
$this->renderer = new Renderer($caching, $debugging);
}
- if ($wordpress_functions) {
- $this->wordpress_functions = $wordpress_functions;
- } else {
- $this->wordpress_functions = new Functions();
- }
$this->mailer = $mailer;
$this->settings = new SettingsController();
}
diff --git a/lib/Tasks/State.php b/lib/Tasks/State.php
index 8bd34fc081..dda23d43b7 100644
--- a/lib/Tasks/State.php
+++ b/lib/Tasks/State.php
@@ -63,7 +63,9 @@ class State
$tasks = array_merge($tasks, $query->findMany());
}
- return array_map([$this, 'buildTaskData'], $tasks);
+ return array_map(function ($task) {
+ return $this->buildTaskData($task);
+ }, $tasks);
}
/**
diff --git a/tasks/code_sniffer/MailPoet/ruleset.xml b/tasks/code_sniffer/MailPoet/ruleset.xml
index 5fff7227db..4782295ce9 100644
--- a/tasks/code_sniffer/MailPoet/ruleset.xml
+++ b/tasks/code_sniffer/MailPoet/ruleset.xml
@@ -3,6 +3,8 @@
MailPoet specific rule set
+
+
diff --git a/tests/integration/Cron/DaemonHttpRunnerTest.php b/tests/integration/Cron/DaemonHttpRunnerTest.php
index 90c532d30b..f226e2e175 100644
--- a/tests/integration/Cron/DaemonHttpRunnerTest.php
+++ b/tests/integration/Cron/DaemonHttpRunnerTest.php
@@ -75,7 +75,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
]),
]);
- $daemon = new Daemon($this->settings, $workers_factory_mock);
+ $daemon = new Daemon($workers_factory_mock);
$daemon_http_runner = $this->make(new DaemonHttpRunner($daemon), array(
'pauseExecution' => null,
'callSelf' => null
@@ -124,7 +124,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
'token' => 123
);
$this->settings->set(CronHelper::DAEMON_SETTING, $data);
- $daemon->__construct(new Daemon($this->settings, $workers_factory_mock));
+ $daemon->__construct(new Daemon($workers_factory_mock));
$daemon->run($data);
}
@@ -148,7 +148,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
'token' => 123
);
$this->settings->set(CronHelper::DAEMON_SETTING, $data);
- $daemon->__construct(new Daemon($this->settings, $workers_factory_mock));
+ $daemon->__construct(new Daemon($workers_factory_mock));
$daemon->run($data);
$data_after_run = $this->settings->get(CronHelper::DAEMON_SETTING);
expect($data_after_run['token'])->equals(567);
@@ -179,7 +179,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
'token' => 123
);
$this->settings->set(CronHelper::DAEMON_SETTING, $data);
- $daemon_http_runner->__construct(new Daemon($this->settings, $this->createWorkersFactoryMock()));
+ $daemon_http_runner->__construct(new Daemon($this->createWorkersFactoryMock()));
$daemon_http_runner->run($data);
$updated_daemon = $this->settings->get(CronHelper::DAEMON_SETTING);
expect($updated_daemon['token'])->equals($daemon_http_runner->token);
@@ -199,7 +199,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
]),
]);
- $daemon = new Daemon($this->settings, $workers_factory_mock);
+ $daemon = new Daemon($workers_factory_mock);
$daemon_http_runner = $this->make(new DaemonHttpRunner($daemon), array(
'pauseExecution' => null,
'callSelf' => null
@@ -231,7 +231,7 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
'token' => 123
);
$this->settings->set(CronHelper::DAEMON_SETTING, $data);
- $daemon->__construct(new Daemon($this->settings, $this->createWorkersFactoryMock()));
+ $daemon->__construct(new Daemon($this->createWorkersFactoryMock()));
$daemon->run($data);
expect(ignore_user_abort())->equals(1);
}
diff --git a/tests/integration/Cron/DaemonTest.php b/tests/integration/Cron/DaemonTest.php
index c52ae00906..cc20d319b3 100644
--- a/tests/integration/Cron/DaemonTest.php
+++ b/tests/integration/Cron/DaemonTest.php
@@ -24,7 +24,7 @@ class DaemonTest extends \MailPoetTest {
'token' => 123
);
$this->settings->set(CronHelper::DAEMON_SETTING, $data);
- $daemon = new Daemon($this->settings, $this->createWorkersFactoryMock());
+ $daemon = new Daemon($this->createWorkersFactoryMock());
$daemon->run($data);
}
diff --git a/tests/integration/Settings/UserFlagsControllerTest.php b/tests/integration/Settings/UserFlagsControllerTest.php
index 20c52c8f37..32a078f69a 100644
--- a/tests/integration/Settings/UserFlagsControllerTest.php
+++ b/tests/integration/Settings/UserFlagsControllerTest.php
@@ -14,13 +14,10 @@ class UserFlagsControllerTest extends \MailPoetTest {
/** @var int */
private $current_user_id;
- /** @var int */
- private $other_user_id;
-
function _before() {
parent::_before();
UserFlag::deleteMany();
-
+
$current_user_id = 1;
$other_user_id = 2;
WPFunctions::set(Stub::make(new WPFunctions, [
diff --git a/tests/integration/Subscription/FormTest.php b/tests/integration/Subscription/FormTest.php
index 2be4c42885..d75ef1ee53 100644
--- a/tests/integration/Subscription/FormTest.php
+++ b/tests/integration/Subscription/FormTest.php
@@ -16,9 +16,6 @@ use MailPoet\Util\Url as UrlHelper;
class FormTest extends \MailPoetTest {
- /** @var Form */
- private $form_controller;
-
/** @var SettingsController */
private $settings;