From 9f13f68e3909bcd72a00321d5f016154fc02ad66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tautvidas=20Sipavi=C4=8Dius?= Date: Wed, 23 Jan 2019 11:33:47 +0200 Subject: [PATCH] Fix "Access to undefined property" rule violations --- lib/API/JSON/v1/MP2Migrator.php | 2 ++ lib/Config/Menu.php | 2 ++ lib/Config/Migrator.php | 5 +++++ .../PopulatorData/Templates/NewsletterBlank121Column.php | 5 +++++ .../PopulatorData/Templates/NewsletterBlank12Column.php | 5 +++++ .../PopulatorData/Templates/NewsletterBlank13Column.php | 5 +++++ .../PopulatorData/Templates/NewsletterBlank1Column.php | 5 +++++ .../Templates/PostNotificationsBlank1Column.php | 5 +++++ lib/Config/PopulatorData/Templates/SimpleText.php | 5 +++++ lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php | 5 +++++ lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php | 5 +++++ lib/Cron/Workers/SendingQueue/SendingQueue.php | 1 + lib/Form/Util/Styles.php | 1 + lib/Mailer/Methods/SMTP.php | 1 + lib/Models/Model.php | 3 ++- lib/Newsletter/Editor/PostListTransformer.php | 3 +++ lib/Newsletter/Editor/TitleListTransformer.php | 2 ++ lib/Newsletter/Editor/Transformer.php | 2 ++ lib/Newsletter/Renderer/Renderer.php | 3 +++ lib/Router/Endpoints/ViewInBrowser.php | 1 + lib/Router/Router.php | 2 ++ lib/Subscribers/ImportExport/Import/MailChimp.php | 5 +++-- lib/WP/Notice.php | 2 ++ tasks/phpstan/phpstan.neon | 2 -- tests/integration/Router/Endpoints/ViewInBrowserTest.php | 6 +++--- 25 files changed, 75 insertions(+), 8 deletions(-) diff --git a/lib/API/JSON/v1/MP2Migrator.php b/lib/API/JSON/v1/MP2Migrator.php index aa3bd41d75..820ff76e5f 100644 --- a/lib/API/JSON/v1/MP2Migrator.php +++ b/lib/API/JSON/v1/MP2Migrator.php @@ -16,6 +16,8 @@ class MP2Migrator extends APIEndpoint { $this->MP2Migrator = new \MailPoet\Config\MP2Migrator(); } + private $MP2Migrator; + /** * Import end point * diff --git a/lib/Config/Menu.php b/lib/Config/Menu.php index d4febec313..27a4514315 100644 --- a/lib/Config/Menu.php +++ b/lib/Config/Menu.php @@ -37,6 +37,8 @@ class Menu { const LAST_ANNOUNCEMENT_DATE = '2018-12-18 10:00:00'; public $renderer; + public $mp_api_key_valid; + public $premium_key_valid; private $access_control; private $subscribers_over_limit; private $wp; diff --git a/lib/Config/Migrator.php b/lib/Config/Migrator.php index 3d7f2e0e6a..d33c7793b9 100644 --- a/lib/Config/Migrator.php +++ b/lib/Config/Migrator.php @@ -10,6 +10,11 @@ if(!defined('ABSPATH')) exit; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); class Migrator { + + public $prefix; + private $charset_collate; + private $models; + function __construct() { $this->prefix = Env::$db_prefix; $this->charset_collate = Env::$db_charset_collate; diff --git a/lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php b/lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php index e749d4a0b5..f264a70132 100644 --- a/lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php +++ b/lib/Config/PopulatorData/Templates/NewsletterBlank121Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class NewsletterBlank121Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-2-1-column'; diff --git a/lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php b/lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php index d80aa56e0d..65b9a58684 100644 --- a/lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php +++ b/lib/Config/PopulatorData/Templates/NewsletterBlank12Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class NewsletterBlank12Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-2-column'; diff --git a/lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php b/lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php index 1420fb0998..62a91c4e59 100644 --- a/lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php +++ b/lib/Config/PopulatorData/Templates/NewsletterBlank13Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class NewsletterBlank13Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-3-column'; diff --git a/lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php b/lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php index 64ae6a92a4..9ed9e20f8b 100644 --- a/lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php +++ b/lib/Config/PopulatorData/Templates/NewsletterBlank1Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class NewsletterBlank1Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/newsletter-blank-1-column'; diff --git a/lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php b/lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php index a8852594bc..975dcb3ddd 100644 --- a/lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php +++ b/lib/Config/PopulatorData/Templates/PostNotificationsBlank1Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class PostNotificationsBlank1Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/post-notifications-blank-1-column'; diff --git a/lib/Config/PopulatorData/Templates/SimpleText.php b/lib/Config/PopulatorData/Templates/SimpleText.php index 3b24c70692..b6eaad5087 100644 --- a/lib/Config/PopulatorData/Templates/SimpleText.php +++ b/lib/Config/PopulatorData/Templates/SimpleText.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class SimpleText { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/simple-text'; diff --git a/lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php b/lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php index 0eb444102b..e1bdce000f 100644 --- a/lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php +++ b/lib/Config/PopulatorData/Templates/WelcomeBlank12Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class WelcomeBlank12Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/welcome-email-blank-1-2-column'; diff --git a/lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php b/lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php index 1ad3124f7f..e454c8dfe7 100644 --- a/lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php +++ b/lib/Config/PopulatorData/Templates/WelcomeBlank1Column.php @@ -5,6 +5,11 @@ if(!defined('ABSPATH')) exit; class WelcomeBlank1Column { + private $assets_url; + private $external_template_image_url; + private $template_image_url; + private $social_icon_url; + function __construct($assets_url) { $this->assets_url = $assets_url; $this->external_template_image_url = 'https://ps.w.org/mailpoet/assets/newsletter-templates/welcome-email-blank-1-column'; diff --git a/lib/Cron/Workers/SendingQueue/SendingQueue.php b/lib/Cron/Workers/SendingQueue/SendingQueue.php index f01bf4197a..dc49b1db0a 100644 --- a/lib/Cron/Workers/SendingQueue/SendingQueue.php +++ b/lib/Cron/Workers/SendingQueue/SendingQueue.php @@ -22,6 +22,7 @@ class SendingQueue { public $mailer_task; public $newsletter_task; public $timer; + public $batch_size; const BATCH_SIZE = 20; const TASK_BATCH_SIZE = 5; diff --git a/lib/Form/Util/Styles.php b/lib/Form/Util/Styles.php index 00435cde56..60c7513897 100644 --- a/lib/Form/Util/Styles.php +++ b/lib/Form/Util/Styles.php @@ -66,6 +66,7 @@ class Styles { color:#B94A48; } EOL; + private $stylesheet; function __construct($stylesheet = null) { $this->stylesheet = $stylesheet; diff --git a/lib/Mailer/Methods/SMTP.php b/lib/Mailer/Methods/SMTP.php index fc5e2e5dae..f851c97824 100644 --- a/lib/Mailer/Methods/SMTP.php +++ b/lib/Mailer/Methods/SMTP.php @@ -18,6 +18,7 @@ class SMTP { public $reply_to; public $return_path; public $mailer; + private $mailer_logger; const SMTP_CONNECTION_TIMEOUT = 15; // seconds /** @var SMTPMapper */ diff --git a/lib/Models/Model.php b/lib/Models/Model.php index c388889734..8db2eb855a 100644 --- a/lib/Models/Model.php +++ b/lib/Models/Model.php @@ -77,6 +77,7 @@ if(!defined('ABSPATH')) exit; class Model extends \Sudzy\ValidModel { const DUPLICATE_RECORD = 23000; + public static $_table; protected $_errors; protected $_new_record; @@ -311,4 +312,4 @@ class Model extends \Sudzy\ValidModel { $this->setError($this->getValidationErrors()); return $success; } -} \ No newline at end of file +} diff --git a/lib/Newsletter/Editor/PostListTransformer.php b/lib/Newsletter/Editor/PostListTransformer.php index 622905e00f..bad9f3696f 100644 --- a/lib/Newsletter/Editor/PostListTransformer.php +++ b/lib/Newsletter/Editor/PostListTransformer.php @@ -7,6 +7,9 @@ if(!defined('ABSPATH')) exit; class PostListTransformer { + private $args; + private $transformer; + function __construct($args) { $this->args = $args; $this->transformer = new PostTransformer($args); diff --git a/lib/Newsletter/Editor/TitleListTransformer.php b/lib/Newsletter/Editor/TitleListTransformer.php index fbec65b2c2..10d9a854f8 100644 --- a/lib/Newsletter/Editor/TitleListTransformer.php +++ b/lib/Newsletter/Editor/TitleListTransformer.php @@ -5,6 +5,8 @@ if(!defined('ABSPATH')) exit; class TitleListTransformer { + private $args; + function __construct($args) { $this->args = $args; } diff --git a/lib/Newsletter/Editor/Transformer.php b/lib/Newsletter/Editor/Transformer.php index b2df6cf989..8bb8c0e638 100644 --- a/lib/Newsletter/Editor/Transformer.php +++ b/lib/Newsletter/Editor/Transformer.php @@ -8,6 +8,8 @@ if(!defined('ABSPATH')) exit; class Transformer { + private $transformer; + function __construct($args) { $title_list_only = $args['displayType'] === 'titleOnly' && $args['titleFormat'] === 'ul'; diff --git a/lib/Newsletter/Renderer/Renderer.php b/lib/Newsletter/Renderer/Renderer.php index 3fc8f3118f..4e743cac8b 100644 --- a/lib/Newsletter/Renderer/Renderer.php +++ b/lib/Newsletter/Renderer/Renderer.php @@ -15,6 +15,9 @@ class Renderer { public $CSS_inliner; public $newsletter; public $preview; + public $premium_activated; + public $mss_activated; + private $template; const NEWSLETTER_TEMPLATE = 'Template.html'; const FILTER_POST_PROCESS = 'mailpoet_rendering_post_process'; diff --git a/lib/Router/Endpoints/ViewInBrowser.php b/lib/Router/Endpoints/ViewInBrowser.php index a6d42cd462..b15d297b06 100644 --- a/lib/Router/Endpoints/ViewInBrowser.php +++ b/lib/Router/Endpoints/ViewInBrowser.php @@ -18,6 +18,7 @@ class ViewInBrowser { public $permissions = array( 'global' => AccessControl::NO_ACCESS_RESTRICTION ); + private $access_control; function __construct(AccessControl $access_control) { $this->access_control = $access_control; diff --git a/lib/Router/Router.php b/lib/Router/Router.php index 7b5e041a17..99d123faea 100644 --- a/lib/Router/Router.php +++ b/lib/Router/Router.php @@ -13,6 +13,8 @@ class Router { public $endpoint; public $action; public $data; + public $endpoint_action; + public $access_control; /** @var ContainerInterface */ private $container; const NAME = 'mailpoet_router'; diff --git a/lib/Subscribers/ImportExport/Import/MailChimp.php b/lib/Subscribers/ImportExport/Import/MailChimp.php index d214bbd4d9..389d588a14 100644 --- a/lib/Subscribers/ImportExport/Import/MailChimp.php +++ b/lib/Subscribers/ImportExport/Import/MailChimp.php @@ -7,7 +7,8 @@ class MailChimp { public $api_key; public $max_post_size; public $data_center; - public $export_url; + private $export_url; + private $lists_url; const API_KEY_REGEX = '/[a-zA-Z0-9]{32}-[a-zA-Z0-9]{2,4}$/'; function __construct($api_key) { @@ -145,4 +146,4 @@ class MailChimp { } throw new \Exception($errorMessage); } -} \ No newline at end of file +} diff --git a/lib/WP/Notice.php b/lib/WP/Notice.php index a53f699fcf..9a288df38c 100644 --- a/lib/WP/Notice.php +++ b/lib/WP/Notice.php @@ -10,6 +10,8 @@ class Notice { private $type; private $message; + private $classes; + private $data_notice_name; function __construct($type, $message, $classes = '', $data_notice_name = '') { $this->type = $type; diff --git a/tasks/phpstan/phpstan.neon b/tasks/phpstan/phpstan.neon index 545e0dd757..f189c1fce2 100644 --- a/tasks/phpstan/phpstan.neon +++ b/tasks/phpstan/phpstan.neon @@ -2,8 +2,6 @@ parameters: tmpDir: ../../temp/phpstan bootstrap: bootstrap.php ignoreErrors: - - '#Access to an undefined property#' # current code suffers from this, it should be fixed & this line removed - '#Static call to instance method MailPoet\\Models\\Model::#' - - '#Access to an undefined static property MailPoet\\Models\\Model::#' - '#Function members_register_.+ not found#' - '#MailPoet\\Premium\\DI\\ContainerConfigurator not found#' # this class is not available when premium is not active diff --git a/tests/integration/Router/Endpoints/ViewInBrowserTest.php b/tests/integration/Router/Endpoints/ViewInBrowserTest.php index 9528598467..44977169ee 100644 --- a/tests/integration/Router/Endpoints/ViewInBrowserTest.php +++ b/tests/integration/Router/Endpoints/ViewInBrowserTest.php @@ -147,12 +147,12 @@ class ViewInBrowserTest extends \MailPoetTest { $wp_user = wp_set_current_user(0); // when WP user does not have 'manage options' permission, false should be returned $wp_user->remove_role('administrator'); - $view_in_browser->access_control = new AccessControl(); + $view_in_browser = new ViewInBrowser(new AccessControl()); expect($this->view_in_browser->_validateBrowserPreviewData($data))->false(); // when WP has 'manage options' permission, data should be returned $wp_user->add_role('administrator'); - $view_in_browser->access_control = new AccessControl(); + $view_in_browser = new ViewInBrowser(new AccessControl()); expect($view_in_browser->_validateBrowserPreviewData($data))->equals($data); } @@ -168,7 +168,7 @@ class ViewInBrowserTest extends \MailPoetTest { ); $data->preview = true; wp_set_current_user(1); - $view_in_browser->access_control = new AccessControl(); + $view_in_browser = new ViewInBrowser(new AccessControl()); $result = $view_in_browser->_validateBrowserPreviewData($data); expect($result->subscriber->id)->equals(1); }