Closed beaucollins closed 5 years ago
The $schema variable is defined as a static property on a PHP class:
$schema
/** * Day Settings Model class */ class Day_Settings extends Model { /** * Table schema for day settings. * * @var array $schema */ public static $schema = array( 'table' => 'hs_day_settings', 'entity' => 'day settings', 'primary_key' => 'hs_day_settings_id', 'fields' => array( 'hs_day_settings_id' => 'int', 'user_id' => 'int', 'date' => 'date', 'settings' => 'json', 'organization_id' => 'int' ), );
The linter sees it as an undefined variable.
Error (PHPCS-CHANGEDVariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable) Unknown lint message! Variable $schema is undefined. 52 */ 53 public function get_primary_id() { 54 $called_class = get_called_class(); >>> 55 $field = $called_class::$schema['primary_key']; 56 return $this->$field; 57 } 58
Is there a preferred way to access the $schema static property on a class that the linter allows?
Good find! This is a bug in phpcs-variable-analysis. Moved to https://github.com/sirbrillig/phpcs-variable-analysis/issues/62
The
$schema
variable is defined as a static property on a PHP class:The linter sees it as an undefined variable.
Is there a preferred way to access the
$schema
static property on a class that the linter allows?