Fix PHPStan errors

This commit is contained in:
Amine Ben hammou
2019-03-04 17:01:24 +01:00
committed by M. Shull
parent 3ff55d85a9
commit ab097d356a
14 changed files with 33 additions and 14 deletions

View File

@ -20,7 +20,7 @@ class Capabilities {
$wp = new WPFunctions; $wp = new WPFunctions;
} }
$this->wp = $wp; $this->wp = $wp;
$this->access_control = new AccessControl($wp); $this->access_control = new AccessControl;
} }
function init() { function init() {

View File

@ -28,7 +28,7 @@ class Updater {
function init() { function init() {
WPFunctions::get()->addFilter('pre_set_site_transient_update_plugins', array($this, 'checkForUpdate')); WPFunctions::get()->addFilter('pre_set_site_transient_update_plugins', array($this, 'checkForUpdate'));
} }
function checkForUpdate($update_transient) { function checkForUpdate($update_transient) {
if (!is_object($update_transient)) { if (!is_object($update_transient)) {
$update_transient = new \stdClass; $update_transient = new \stdClass;

View File

@ -154,7 +154,10 @@ class Mailer {
$return_path : $return_path :
$this->settings->get('bounce.address'); $this->settings->get('bounce.address');
} }
/**
* @param \MailPoet\Models\Subscriber|array $subscriber
*/
function formatSubscriberNameAndEmailAddress($subscriber) { function formatSubscriberNameAndEmailAddress($subscriber) {
$subscriber = (is_object($subscriber)) ? $subscriber->asArray() : $subscriber; $subscriber = (is_object($subscriber)) ? $subscriber->asArray() : $subscriber;
if (!is_array($subscriber)) return $subscriber; if (!is_array($subscriber)) return $subscriber;

View File

@ -2,6 +2,7 @@
namespace MailPoet\Models; namespace MailPoet\Models;
use MailPoet\Form\Block\Date; use MailPoet\Form\Block\Date;
use MailPoet\WP\Functions as WPFunctions;
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
@ -9,7 +10,6 @@ if (!defined('ABSPATH')) exit;
* @property string $type * @property string $type
* @property string|array $params * @property string|array $params
*/ */
use MailPoet\WP\Functions as WPFunctions;
class CustomField extends Model { class CustomField extends Model {
public static $_table = MP_CUSTOM_FIELDS_TABLE; public static $_table = MP_CUSTOM_FIELDS_TABLE;

View File

@ -1,6 +1,8 @@
<?php <?php
namespace MailPoet\Models; namespace MailPoet\Models;
use MailPoet\WP\Functions as WPFunctions;
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
/** /**
@ -8,7 +10,6 @@ if (!defined('ABSPATH')) exit;
* @property string|array $body * @property string|array $body
* @property string $name * @property string $name
*/ */
use MailPoet\WP\Functions as WPFunctions;
class Form extends Model { class Form extends Model {
public static $_table = MP_FORMS_TABLE; public static $_table = MP_FORMS_TABLE;

View File

@ -2,6 +2,8 @@
namespace MailPoet\Models; namespace MailPoet\Models;
use MailPoet\WP\Functions as WPFunctions;
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
/** /**
@ -112,7 +114,6 @@ if (!defined('ABSPATH')) exit;
* @property string|null $updated_at * @property string|null $updated_at
* @property string|null $id * @property string|null $id
*/ */
use MailPoet\WP\Functions as WPFunctions;
class Model extends \Sudzy\ValidModel { class Model extends \Sudzy\ValidModel {
const DUPLICATE_RECORD = 23000; const DUPLICATE_RECORD = 23000;

View File

@ -8,6 +8,7 @@ use MailPoet\Util\Helpers;
use MailPoet\Util\Security; use MailPoet\Util\Security;
use MailPoet\WP\Emoji; use MailPoet\WP\Emoji;
use function MailPoet\Util\array_column; use function MailPoet\Util\array_column;
use MailPoet\WP\Functions as WPFunctions;
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
@ -29,7 +30,6 @@ if (!defined('ABSPATH')) exit;
* @property string $body * @property string $body
* @property string|null $schedule * @property string|null $schedule
*/ */
use MailPoet\WP\Functions as WPFunctions;
class Newsletter extends Model { class Newsletter extends Model {
public static $_table = MP_NEWSLETTERS_TABLE; public static $_table = MP_NEWSLETTERS_TABLE;

View File

@ -1,6 +1,8 @@
<?php <?php
namespace MailPoet\Models; namespace MailPoet\Models;
use MailPoet\WP\Functions as WPFunctions;
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
/** /**
@ -9,7 +11,6 @@ if (!defined('ABSPATH')) exit;
* @property string $type * @property string $type
* @property string $description * @property string $description
*/ */
use MailPoet\WP\Functions as WPFunctions;
class Segment extends Model { class Segment extends Model {
static $_table = MP_SEGMENTS_TABLE; static $_table = MP_SEGMENTS_TABLE;

View File

@ -4,6 +4,7 @@ namespace MailPoet\Models;
use MailPoet\Util\Helpers; use MailPoet\Util\Helpers;
use MailPoet\WP\Emoji; use MailPoet\WP\Emoji;
use MailPoet\Tasks\Subscribers as TaskSubscribers; use MailPoet\Tasks\Subscribers as TaskSubscribers;
use MailPoet\WP\Functions as WPFunctions;
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
@ -19,7 +20,6 @@ if (!defined('ABSPATH')) exit;
* @property string|array $subscribers * @property string|array $subscribers
* @property string|null $deleted_at * @property string|null $deleted_at
*/ */
use MailPoet\WP\Functions as WPFunctions;
class SendingQueue extends Model { class SendingQueue extends Model {
public static $_table = MP_SENDING_QUEUES_TABLE; public static $_table = MP_SENDING_QUEUES_TABLE;

View File

@ -5,6 +5,7 @@ use MailPoet\Settings\SettingsController;
use MailPoet\Subscribers\ConfirmationEmailMailer; use MailPoet\Subscribers\ConfirmationEmailMailer;
use MailPoet\Util\Helpers; use MailPoet\Util\Helpers;
use function MailPoet\Util\array_column; use function MailPoet\Util\array_column;
use MailPoet\WP\Functions as WPFunctions;
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
@ -26,7 +27,6 @@ if (!defined('ABSPATH')) exit;
* @property string $unconfirmed_data * @property string $unconfirmed_data
* @property int $is_woocommerce_user * @property int $is_woocommerce_user
*/ */
use MailPoet\WP\Functions as WPFunctions;
class Subscriber extends Model { class Subscriber extends Model {
public static $_table = MP_SUBSCRIBERS_TABLE; public static $_table = MP_SUBSCRIBERS_TABLE;

View File

@ -21,7 +21,10 @@ class Renderer {
private $template; private $template;
const NEWSLETTER_TEMPLATE = 'Template.html'; const NEWSLETTER_TEMPLATE = 'Template.html';
const FILTER_POST_PROCESS = 'mailpoet_rendering_post_process'; const FILTER_POST_PROCESS = 'mailpoet_rendering_post_process';
/**
* @param \MailPoet\Models\Newsletter|array $newsletter
*/
function __construct($newsletter, $preview = false) { function __construct($newsletter, $preview = false) {
$this->newsletter = ($newsletter instanceof Newsletter) ? $newsletter->asArray() : $newsletter; $this->newsletter = ($newsletter instanceof Newsletter) ? $newsletter->asArray() : $newsletter;
$this->preview = $preview; $this->preview = $preview;

View File

@ -8,6 +8,9 @@ use MailPoet\WP\Functions as WPFunctions;
if (!defined('ABSPATH')) exit; if (!defined('ABSPATH')) exit;
class Subscriber { class Subscriber {
/**
* @param \MailPoet\Models\Subscriber|false $subscriber
*/
static function process( static function process(
$shortcode_details, $shortcode_details,
$newsletter, $newsletter,

View File

@ -5,11 +5,11 @@ namespace MailPoet\Subscribers\ImportExport\Export;
use MailPoet\Models\Segment; use MailPoet\Models\Segment;
use MailPoet\Models\Subscriber; use MailPoet\Models\Subscriber;
use MailPoet\Models\SubscriberSegment; use MailPoet\Models\SubscriberSegment;
use MailPoet\WP\Functions as WPFunctions;
/** /**
* Gets batches of subscribers from default segments. * Gets batches of subscribers from default segments.
*/ */
use MailPoet\WP\Functions as WPFunctions;
class DefaultSubscribersGetter extends SubscribersGetter { class DefaultSubscribersGetter extends SubscribersGetter {

View File

@ -2,8 +2,12 @@
namespace MailPoet\WP; namespace MailPoet\WP;
class Functions { class Functions {
static private $instance;
static private $instance;
/**
* @return Functions
*/
static function get() { static function get() {
if (self::$instance == null) { if (self::$instance == null) {
self::$instance = new Functions; self::$instance = new Functions;
@ -154,7 +158,10 @@ class Functions {
function currentUserCan() { function currentUserCan() {
return call_user_func_array('current_user_can', func_get_args()); return call_user_func_array('current_user_can', func_get_args());
} }
/**
* @return \WP_Role | null
*/
function getRole() { function getRole() {
return call_user_func_array('get_role', func_get_args()); return call_user_func_array('get_role', func_get_args());
} }