Fix phpstan level 6

[MAILPOET-1969]
This commit is contained in:
Pavel Dohnal
2019-04-09 13:46:03 +02:00
committed by M. Shull
parent 46a0b7501b
commit 3e66e9e1dd
36 changed files with 320 additions and 244 deletions

View File

@@ -22,8 +22,8 @@ if (!defined('ABSPATH')) exit;
* @method $this useIdColumn($id_column)
* @method $this|bool findOne($id=null)
* @method static static|bool findOne($id=null)
* @method array|\IdiormResultSet findMany()
* @method static array|\IdiormResultSet findMany()
* @method array findMany()
* @method static array findMany()
* @method \IdiormResultSet findResultSet()
* @method array findArray()
* @method static array findArray()
@@ -162,7 +162,7 @@ class Model extends \Sudzy\ValidModel {
}
if ($model === false) {
if (!empty($onCreate)) {
if (!empty($onCreate) && is_callable($onCreate)) {
$data = $onCreate($data);
}
$model = static::create();

View File

@@ -26,7 +26,10 @@ class ModelValidator extends \Sudzy\Engine {
$_this = $this;
foreach ($this->validators as $validator => $action) {
$this->addValidator($validator, function($params) use ($action, $_this) {
return call_user_func(array($_this, $action), $params);
$callback = [$_this, $action];
if (is_callable($callback)) {
return call_user_func($callback, $params);
}
});
}
}

View File

@@ -29,6 +29,8 @@ if (!defined('ABSPATH')) exit;
* @property string $subject
* @property string $body
* @property string|null $schedule
* @property boolean|null $isScheduled
* @property string|null $scheduledAt
*/
class Newsletter extends Model {

View File

@@ -218,7 +218,7 @@ class Subscriber extends Model {
return self::filter('withoutSegments');
} else {
$segment = Segment::findOne($value);
if ($segment !== false) {
if ($segment instanceof Segment) {
return $segment->subscribers();
}
}
@@ -459,10 +459,10 @@ class Subscriber extends Model {
->where('subscriber_id', $this->id())
->findOne();
if ($custom_field === false) {
return $default;
} else {
if ($custom_field instanceof SubscriberCustomField) {
return $custom_field->value;
} else {
return $default;
}
}
@@ -495,7 +495,10 @@ class Subscriber extends Model {
function setUnconfirmedData(array $subscriber_data) {
$subscriber_data = self::filterOutReservedColumns($subscriber_data);
$this->unconfirmed_data = json_encode($subscriber_data);
$encoded = json_encode($subscriber_data);
if (is_string($encoded)) {
$this->unconfirmed_data = $encoded;
}
}
function getUnconfirmedData() {
@@ -511,7 +514,7 @@ class Subscriber extends Model {
$segment_id = (isset($data['segment_id']) ? (int)$data['segment_id'] : 0);
$segment = Segment::findOne($segment_id);
if ($segment === false) return false;
if (!$segment instanceof Segment) return false;
$count = parent::bulkAction($orm,
function($subscriber_ids) use($segment) {
@@ -531,7 +534,7 @@ class Subscriber extends Model {
$segment_id = (isset($data['segment_id']) ? (int)$data['segment_id'] : 0);
$segment = Segment::findOne($segment_id);
if ($segment === false) return false;
if (!$segment instanceof Segment) return false;
$count = parent::bulkAction($orm,
function($subscriber_ids) use($segment) {
@@ -552,7 +555,7 @@ class Subscriber extends Model {
$segment_id = (isset($data['segment_id']) ? (int)$data['segment_id'] : 0);
$segment = Segment::findOne($segment_id);
if ($segment === false) return false;
if (!$segment instanceof Segment) return false;
$count = $orm->count();

View File

@@ -15,10 +15,10 @@ class SubscriberCustomField extends Model {
static function createOrUpdate($data = array()) {
$custom_field = CustomField::findOne($data['custom_field_id']);
if ($custom_field === false) {
return false;
} else {
if ($custom_field instanceof CustomField) {
$custom_field = $custom_field->asArray();
} else {
return false;
}
if ($custom_field['type'] === 'date') {