diff --git a/RoboFile.php b/RoboFile.php index 1344879b11..8a9a569604 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -378,7 +378,7 @@ class RoboFile extends \Robo\Tasks { 'php -d memory_limit=2G '. "$dir/phpstan.phar analyse ". "--configuration $dir/tasks/phpstan/phpstan.neon ". - '--level 2 '. + '--level 3 '. "$dir/lib" ) ->dir(__DIR__ . '/tasks/phpstan') diff --git a/lib/Config/MP2Migrator.php b/lib/Config/MP2Migrator.php index 36db73ac71..1dc30464eb 100644 --- a/lib/Config/MP2Migrator.php +++ b/lib/Config/MP2Migrator.php @@ -486,7 +486,7 @@ class MP2Migrator { * * @param string $name Parameter name * @param array $params MP2 parameters - * @return string serialized MP3 custom field params + * @return array serialized MP3 custom field params */ private function mapCustomFieldParams($name, $params) { if (!isset($params['label'])) { diff --git a/lib/Models/Model.php b/lib/Models/Model.php index c46d38451b..7debd1f898 100644 --- a/lib/Models/Model.php +++ b/lib/Models/Model.php @@ -102,7 +102,7 @@ if (!defined('ABSPATH')) exit; * @method static static filter(...$args) * @method $this hasMany($associated_class_name, $foreign_key_name=null, $foreign_key_name_in_current_models_table=null, $connection_name=null) * @method $this hasManyThrough($associated_class_name, $join_class_name=null, $key_to_base_table=null, $key_to_associated_table=null, $key_in_base_table=null, $key_in_associated_table=null, $connection_name=null) - * @method $this hasOne($associated_class_name, $foreign_key_name=null, $foreign_key_name_in_current_models_table=null, $connection_name=null) + * @method mixed hasOne($associated_class_name, $foreign_key_name=null, $foreign_key_name_in_current_models_table=null, $connection_name=null) * @method $this|bool create($data=null) * @method static $this|bool create($data=null) * @method int count() @@ -139,7 +139,7 @@ class Model extends \Sudzy\ValidModel { * given, it's used to transform `$data` before creating the new row. * * @param array $data - * @param boolean $keys + * @param array|boolean $keys * @param callable|bool $onCreate * @return self */ diff --git a/lib/Models/Newsletter.php b/lib/Models/Newsletter.php index 65aa06f764..a7084df92e 100644 --- a/lib/Models/Newsletter.php +++ b/lib/Models/Newsletter.php @@ -15,7 +15,7 @@ if (!defined('ABSPATH')) exit; /** * @property int $id * @property string $type - * @property object $queue + * @property object|boolean $queue * @property string $hash * @property string $status * @property string|object $meta diff --git a/lib/Models/NewsletterLink.php b/lib/Models/NewsletterLink.php index 739ad73e7e..2082751c17 100644 --- a/lib/Models/NewsletterLink.php +++ b/lib/Models/NewsletterLink.php @@ -8,13 +8,14 @@ if (!defined('ABSPATH')) exit; * @property int $queue_id * @property string $url * @property string $hash + * @property int|null $clicksCount */ class NewsletterLink extends Model { public static $_table = MP_NEWSLETTER_LINKS_TABLE; /** * @param Newsletter $newsletter - * @return \stdClass|null + * @return NewsletterLink|null */ static function findTopLinkForNewsletter(Newsletter $newsletter) { $link = self::selectExpr('links.*') diff --git a/lib/Models/ScheduledTask.php b/lib/Models/ScheduledTask.php index 31e986718c..92b5bcbd09 100644 --- a/lib/Models/ScheduledTask.php +++ b/lib/Models/ScheduledTask.php @@ -11,7 +11,7 @@ if (!defined('ABSPATH')) exit; * @property string|null $status * @property string|null $type * @property int $priority - * @property string $scheduled_at + * @property string|null $scheduled_at */ class ScheduledTask extends Model { public static $_table = MP_SCHEDULED_TASKS_TABLE; @@ -41,11 +41,12 @@ class ScheduledTask extends Model { /** @return StatsNotification */ function statsNotification() { - return $this->hasOne( + $model = $this->hasOne( StatsNotification::class, 'task_id', 'id' ); + return $model; } function pause() { diff --git a/lib/Models/Subscriber.php b/lib/Models/Subscriber.php index 3f365c9ccf..88263eb3d4 100644 --- a/lib/Models/Subscriber.php +++ b/lib/Models/Subscriber.php @@ -76,9 +76,7 @@ class Subscriber extends Model { function delete() { // WP Users cannot be deleted - if ($this->isWPUser() || $this->isWooCommerceUser()) { - return false; - } else { + if (!$this->isWPUser() && !$this->isWooCommerceUser()) { // delete all relations to segments SubscriberSegment::deleteSubscriptions($this); // delete all relations to custom fields diff --git a/lib/Tasks/Sending.php b/lib/Tasks/Sending.php index 330dcb86f3..4510f8cfda 100644 --- a/lib/Tasks/Sending.php +++ b/lib/Tasks/Sending.php @@ -13,7 +13,7 @@ if (!defined('ABSPATH')) exit; /** * A facade class containing all necessary models to work with a sending queue - * @property string $status + * @property string|null $status * @property int $task_id * @property int $id */ diff --git a/lib/Util/Sudzy/Engine.php b/lib/Util/Sudzy/Engine.php index 20f1f09045..2ba666faec 100644 --- a/lib/Util/Sudzy/Engine.php +++ b/lib/Util/Sudzy/Engine.php @@ -62,7 +62,7 @@ class Engine } /** - * @return string The list of usable validator methods + * @return array The list of usable validator methods */ public function getValidators() { diff --git a/lib/Util/pQuery/pQuery.php b/lib/Util/pQuery/pQuery.php index 09c98c030f..75ad958390 100644 --- a/lib/Util/pQuery/pQuery.php +++ b/lib/Util/pQuery/pQuery.php @@ -11,11 +11,12 @@ class pQuery extends \pQuery { } class Html5Parser extends \pQuery\HtmlParser { - var $root = 'MailPoet\Util\pQuery\DomNode'; + /** @var string|\pQuery\DomNode */ + public $root = 'MailPoet\Util\pQuery\DomNode'; } class DomNode extends \pQuery\DomNode { - var $childClass = 'MailPoet\Util\pQuery\DomNode'; + public $childClass = 'MailPoet\Util\pQuery\DomNode'; function getInnerText() { return html_entity_decode($this->toString(true, true, 1), ENT_NOQUOTES, 'UTF-8'); diff --git a/tasks/phpstan/phpstan.neon b/tasks/phpstan/phpstan.neon index 3c96f35eef..ad99445bcd 100644 --- a/tasks/phpstan/phpstan.neon +++ b/tasks/phpstan/phpstan.neon @@ -5,4 +5,5 @@ parameters: - '#Function members_register_.+ not found#' - '#MailPoet\\Premium\\DI\\ContainerConfigurator not found#' # this class is not available when premium is not active - '#Call to an undefined method IdiormResultSet::set()#' + - '#Argument of an invalid type pQuery\\IQuery supplied for foreach, only iterables are supported#' reportUnmatchedIgnoredErrors: false