Add public keyword to methods

[MAILPOET-2413]
This commit is contained in:
Amine Ben hammou
2019-12-26 12:56:49 +01:00
committed by wxa
parent ec409042d5
commit 43df66d162
823 changed files with 4440 additions and 4440 deletions

View File

@ -3,7 +3,7 @@
namespace MailPoet\Settings;
class Charsets {
static function getAll() {
public static function getAll() {
return [
'UTF-8', 'UTF-7', 'BIG5', 'ISO-2022-JP',
'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3',

View File

@ -212,11 +212,11 @@ class Hosts {
],
];
static function getWebHosts() {
public static function getWebHosts() {
return static::$_web;
}
static function getSMTPHosts() {
public static function getSMTPHosts() {
return static::$_smtp;
}
}

View File

@ -6,10 +6,10 @@ use MailPoet\Subscription;
use MailPoet\WP\Functions as WPFunctions;
class Pages {
function __construct() {
public function __construct() {
}
function init() {
public function init() {
WPFunctions::get()->registerPostType('mailpoet_page', [
'labels' => [
'name' => WPFunctions::get()->__('MailPoet Page', 'mailpoet'),
@ -27,7 +27,7 @@ class Pages {
]);
}
static function createMailPoetPage() {
public static function createMailPoetPage() {
WPFunctions::get()->removeAllActions('pre_post_update');
WPFunctions::get()->removeAllActions('save_post');
WPFunctions::get()->removeAllActions('wp_insert_post');
@ -44,7 +44,7 @@ class Pages {
return ((int)$id > 0) ? (int)$id : false;
}
static function getMailPoetPages() {
public static function getMailPoetPages() {
return WPFunctions::get()->getPosts([
'post_type' => 'mailpoet_page',
]);
@ -55,7 +55,7 @@ class Pages {
*
* @return bool
*/
static function isMailpoetPage($id) {
public static function isMailpoetPage($id) {
$mailpoetPages = static::getMailPoetPages();
foreach ($mailpoetPages as $mailpoetPage) {
if ($mailpoetPage->ID === $id) {
@ -65,7 +65,7 @@ class Pages {
return false;
}
static function getAll() {
public static function getAll() {
$all_pages = array_merge(
static::getMailPoetPages(),
WPFunctions::get()->getPages()
@ -79,7 +79,7 @@ class Pages {
return $pages;
}
static function getPageData($page) {
public static function getPageData($page) {
$subscription_url_factory = Subscription\SubscriptionUrlFactory::getInstance();
return [
'id' => $page->ID,

View File

@ -24,11 +24,11 @@ class SettingsController {
/** @var SettingsRepository */
private $settings_repository;
function __construct(SettingsRepository $settings_repository) {
public function __construct(SettingsRepository $settings_repository) {
$this->settings_repository = $settings_repository;
}
function get($key, $default = null) {
public function get($key, $default = null) {
$this->ensureLoaded();
$key_parts = explode('.', $key);
$setting = $this->settings;
@ -48,7 +48,7 @@ class SettingsController {
return $setting;
}
function getAllDefaults() {
public function getAllDefaults() {
if ($this->defaults === null) {
$this->defaults = [
'mta_group' => self::DEFAULT_SENDING_METHOD_GROUP,
@ -84,19 +84,19 @@ class SettingsController {
* Fetches the value from DB and update in cache
* This is required for sync settings between parallel processes e.g. cron
*/
function fetch($key, $default = null) {
public function fetch($key, $default = null) {
$keys = explode('.', $key);
$main_key = $keys[0];
$this->settings[$main_key] = $this->fetchValue($main_key);
return $this->get($key, $default);
}
function getAll() {
public function getAll() {
$this->ensureLoaded();
return array_replace_recursive($this->getAllDefaults(), $this->settings);
}
function set($key, $value) {
public function set($key, $value) {
$this->ensureLoaded();
$key_parts = explode('.', $key);
$main_key = $key_parts[0];
@ -112,7 +112,7 @@ class SettingsController {
$this->settings_repository->createOrUpdateByName($main_key, $this->settings[$main_key]);
}
function delete($key) {
public function delete($key) {
$setting = $this->settings_repository->findOneByName($key);
if ($setting) {
$this->settings_repository->remove($setting);
@ -150,13 +150,13 @@ class SettingsController {
return $setting ? $setting->getValue() : null;
}
function resetCache() {
public function resetCache() {
$this->settings = [];
$this->loaded = false;
}
/** @return SettingsController */
static function getInstance() {
public static function getInstance() {
return ContainerWrapper::getInstance()->get(SettingsController::class);
}
}

View File

@ -16,11 +16,11 @@ use MailPoetVendor\Carbon\Carbon;
* @method void remove(SettingEntity $entity)
*/
class SettingsRepository extends Repository {
function findOneByName($name) {
public function findOneByName($name) {
return $this->doctrine_repository->findOneBy(['name' => $name]);
}
function createOrUpdateByName($name, $value) {
public function createOrUpdateByName($name, $value) {
// Temporarily use low-level INSERT ... ON DUPLICATE KEY UPDATE query to avoid race conditions
// between entity fetch and creation with multiple concurrent requests. This will be replaced
// by a code solving atomicity of create-or-update on entity (ORM) level in a follow-up ticket.
@ -29,7 +29,7 @@ class SettingsRepository extends Repository {
$this->entity_manager->getConnection()->executeUpdate("
INSERT INTO $table_name (name, value, created_at, updated_at)
VALUES (:name, :value, :now, :now)
ON DUPLICATE KEY UPDATE value = :value, updated_at = :now
ON DUPLICATE KEY UPDATE value = :value, updated_at = :now
", [
'name' => $name,
'value' => is_array($value) ? serialize($value) : $value,

View File

@ -16,7 +16,7 @@ class UserFlagsController {
/** @var UserFlagsRepository */
private $user_flags_repository;
function __construct(UserFlagsRepository $user_flags_repository) {
public function __construct(UserFlagsRepository $user_flags_repository) {
$this->defaults = [
'last_announcement_seen' => false,
'editor_tutorial_seen' => false,
@ -24,7 +24,7 @@ class UserFlagsController {
$this->user_flags_repository = $user_flags_repository;
}
function get($name) {
public function get($name) {
$this->ensureLoaded();
if (!isset($this->data[$name])) {
return $this->defaults[$name];
@ -32,7 +32,7 @@ class UserFlagsController {
return $this->data[$name];
}
function getAll() {
public function getAll() {
$this->ensureLoaded();
$data = $this->data;
if (!is_array($data)) {
@ -41,7 +41,7 @@ class UserFlagsController {
return array_merge($this->defaults, $data);
}
function set($name, $value) {
public function set($name, $value) {
$current_user_id = WPFunctions::get()->getCurrentUserId();
$flag = $this->user_flags_repository->findOneBy([
'user_id' => $current_user_id,
@ -62,7 +62,7 @@ class UserFlagsController {
}
}
function delete($name) {
public function delete($name) {
$current_user_id = WPFunctions::get()->getCurrentUserId();
$flag = $this->user_flags_repository->findOneBy([
'user_id' => $current_user_id,