Remove phpstan error from Models

[MAILPOET-3235]
This commit is contained in:
Jan Lysý
2021-01-12 12:14:12 +01:00
committed by Veljko V
parent b0e53b38a1
commit 7950804216
5 changed files with 6 additions and 6 deletions

View File

@ -39,11 +39,11 @@ class Form extends Model {
}
public function save() {
$this->set('body', (is_serialized($this->body))
$this->set('body', (is_string($this->body) && is_serialized($this->body))
? $this->body
: serialize($this->body)
);
$this->set('settings', (is_serialized($this->settings))
$this->set('settings', (is_string($this->settings) && is_serialized($this->settings))
? $this->settings
: serialize($this->settings)
);

View File

@ -171,7 +171,7 @@ class Model extends \MailPoetVendor\Sudzy\ValidModel {
$model = static::findOne((int)$data['id']);
}
if ($model === false && !empty($keys)) {
if ($model === false && !empty($keys) && is_array($keys)) {
foreach ($keys as $field => $value) {
if ($model === false) {
$model = static::where($field, $value);

View File

@ -548,7 +548,7 @@ class Newsletter extends Model {
public function getMeta() {
if (!$this->meta) return;
return (Helpers::isJson($this->meta)) ? json_decode($this->meta, true) : $this->meta;
return (Helpers::isJson($this->meta) && is_string($this->meta)) ? json_decode($this->meta, true) : $this->meta;
}
public static function findOneWithOptions($id) {

View File

@ -112,7 +112,7 @@ class ScheduledTask extends Model {
}
public function getMeta() {
$meta = (Helpers::isJson($this->meta)) ? json_decode($this->meta, true) : $this->meta;
$meta = (Helpers::isJson($this->meta) && is_string($this->meta)) ? json_decode($this->meta, true) : $this->meta;
return !empty($meta) ? (array)$meta : [];
}

View File

@ -109,7 +109,7 @@ class SendingQueue extends Model {
}
public function getMeta() {
return (Helpers::isJson($this->meta)) ? json_decode($this->meta, true) : $this->meta;
return (Helpers::isJson($this->meta) && is_string($this->meta)) ? json_decode($this->meta, true) : $this->meta;
}
public function isSubscriberProcessed($subscriberId) {