-
Notifications
You must be signed in to change notification settings - Fork 6
Inspections
This inspection tells that you should declares the @property
annotation on class that refers to each database columns. It is useful to determine the column type, getting a better IDE code support.
This inspection affects only models that extends the Eloquent\Model
class, direct or indirectly.
$user = new User;
$user->name; // <-- should annotate @property $name if still not do
- Check for
id
column annotation; - Check for columns annotations from class properties:
$casts
and$dates
; - Check for columns annotations from accessors and mutators methods;
- Check for columns annotations from relationships methods;
- Check for columns annotations from model instance references (eg.
$user->name
); - Check for
created_at
andupdated_at
when the property$timestamps = true
; - Check for
deleted_at
column when using theSoftDeletes
trait; - Quick-fix available;
From 0.2.0 release, this inspection will try to guess the type based on some conditions:
- For
id
(or$primaryKey
) column, always will beint
(except if other type defined on$keyType
); - For any column suffixed
_id
consider asint
; - For any column suffixed
_at
consider as\Carbon\Carbon
; - For accessors, try to guess from the return type;
- For mutators, try to guess from accessor return type, if it exists;
- For any column declared on
$casts
property, consider the cast type (eg.=> "int"
, thenint
, see supported casts at Laravel docs); - For any other case, will consider
mixed
;
This inspection tells that you should declares the @property
annotation on class that refers to each Fluent
properties. It is useful to get a better IDE code support.
This inspection affects only instances that extends the Fluent
class indirectly (see examples below).
$data = new \App\MyFluentChild;
$data->value; // <-- should annotate @property $value if still not do
$data = new \Fluent;
$data->value; // <-- nothing
This inspection tells that you should not instantiate a Fluent
instance directly. You should create a child class to make possible customize it (as annotating it with @property
). It is useful to get a better IDE code support.
$data = new \Fluent; // <-- invalid: should not be instantiated directly
$data = new \App\MyFluentChild; // <-- acceptable
This inspection tells that you are using Fluent
as type, and is recommended that you return a Fluent
class child instead. It is useful to get a better IDE code support.
function getFluent(): \Fluent; // <-- invalid: should not be used as type directly
function getFluent(): \App\MyFluentChild; // <-- acceptable
- Identify
Fluent
usage as parameter type for functions or methods (eg.Fluent $fluent
); - Identify
Fluent
usage as return type for functions or methods (eg.function get(): Fluent
); - Identify
Fluent
usage as phpdoc type (eg.@property Fluent $fluent
);