Fix "Static call to instance method" errors on Models

Paris uses magic methods to create model instance for static calls
This commit is contained in:
Tautvidas Sipavičius
2019-01-23 18:44:43 +02:00
parent c09766a4df
commit e13789b768
3 changed files with 20 additions and 3 deletions

View File

@ -19,16 +19,23 @@ if(!defined('ABSPATH')) exit;
* @method array getConnectionNames()
* @method $this useIdColumn($id_column)
* @method \ORM|bool findOne($id=null)
* @method static \ORM|bool findOne($id=null)
* @method array|\IdiormResultSet findMany()
* @method static array|\IdiormResultSet findMany()
* @method \IdiormResultSet findResultSet()
* @method array findArray()
* @method static array findArray()
* @method $this forceAllDirty()
* @method $this rawQuery($query, $parameters = array())
* @method static $this rawQuery($query, $parameters = array())
* @method $this tableAlias($alias)
* @method int countNullIdColumns()
* @method $this select($column, $alias=null)
* @method static $this select($column, $alias=null)
* @method $this selectExpr($expr, $alias=null)
* @method \ORM selectMany($values)
* @method static $this selectExpr($expr, $alias=null)
* @method \ORM selectMany($values,...)
* @method static \ORM selectMany($values,...)
* @method \ORM selectManyExpr($values)
* @method $this rawJoin($table, $constraint, $table_alias, $parameters = array())
* @method $this innerJoin($table, $constraint, $table_alias=null)
@ -36,11 +43,15 @@ if(!defined('ABSPATH')) exit;
* @method $this rightOuterJoin($table, $constraint, $table_alias=null)
* @method $this fullOuterJoin($table, $constraint, $table_alias=null)
* @method $this where($column_name, $value=null)
* @method static $this where($column_name, $value=null)
* @method $this whereEqual($column_name, $value=null)
* @method static $this whereEqual($column_name, $value=null)
* @method $this whereNotEqual($column_name, $value=null)
* @method static $this whereNotEqual($column_name, $value=null)
* @method $this whereIdIs($id)
* @method $this whereAnyIs($values, $operator='=')
* @method array|string whereIdIn($ids)
* @method static array|string whereIdIn($ids)
* @method $this whereLike($column_name, $value=null)
* @method $this whereNotLike($column_name, $value=null)
* @method $this whereGt($column_name, $value=null)
@ -48,13 +59,19 @@ if(!defined('ABSPATH')) exit;
* @method $this whereGte($column_name, $value=null)
* @method $this whereLte($column_name, $value=null)
* @method $this whereIn($column_name, $values)
* @method static $this whereIn($column_name, $values)
* @method $this whereNotIn($column_name, $values)
* @method $this whereNull($column_name)
* @method static $this whereNull($column_name)
* @method $this whereNotNull($column_name)
* @method static $this whereNotNull($column_name)
* @method $this whereRaw($clause, $parameters=array())
* @method static $this whereRaw($clause, $parameters=array())
* @method $this deleteMany()
* @method $this orderByDesc($column_name)
* @method static $this orderByDesc($column_name)
* @method $this orderByAsc($column_name)
* @method static $this orderByAsc($column_name)
* @method $this orderByExpr($clause)
* @method $this groupBy($column_name)
* @method $this groupByExpr($expr)
@ -76,6 +93,7 @@ if(!defined('ABSPATH')) exit;
* @method bool setExpr($key, $value = null)
* @method bool isDirty($key)
* @method $this table_alias($alias)
* @method static $this table_alias($alias)
*/
class Model extends \Sudzy\ValidModel {
const DUPLICATE_RECORD = 23000;

View File

@ -513,7 +513,7 @@ class Subscriber extends Model {
$custom_field_ids = array_keys($custom_fields_data);
// get custom fields
$custom_fields = CustomField::findMany($custom_field_ids);
$custom_fields = CustomField::whereIdIn($custom_field_ids)->findMany();
foreach($custom_fields as $custom_field) {
$value = (isset($custom_fields_data[$custom_field->id])

View File

@ -2,6 +2,5 @@ parameters:
tmpDir: ../../temp/phpstan
bootstrap: bootstrap.php
ignoreErrors:
- '#Static call to instance method MailPoet\\Models\\Model::#'
- '#Function members_register_.+ not found#'
- '#MailPoet\\Premium\\DI\\ContainerConfigurator not found#' # this class is not available when premium is not active