1 | <?php |
||
22 | abstract class BaseModel implements IEloquent |
||
23 | { |
||
24 | use Containerable, Timestampable, Eventable; |
||
25 | |||
26 | protected $exists = false; |
||
27 | protected $timestamps = false; |
||
28 | |||
29 | /** @MustBeOverridden */ |
||
30 | const COLLECTION = null; |
||
31 | |||
32 | const PRIMARY_KEY = 'id'; |
||
33 | const CREATED_AT = 'created_at'; |
||
34 | const UPDATED_AT = 'updated_at'; |
||
35 | |||
36 | abstract protected static function di(): Container; |
||
37 | |||
38 | public function __construct(array $attributes = []) |
||
42 | |||
43 | public function getPrimaryKey(): string |
||
47 | |||
48 | public function setPrimaryKey(string $key) |
||
52 | |||
53 | final public static function getCollectionName(): string |
||
54 | { |
||
55 | if (static::COLLECTION == null) { |
||
56 | throw new IllegalCollectionException(); |
||
57 | } |
||
58 | return static::COLLECTION; |
||
59 | } |
||
60 | |||
61 | public function exists(bool $value = null): bool |
||
68 | |||
69 | public static function all(IQueryBuilder $query, array $columns = [], callable $callback = null): ICollection |
||
81 | |||
82 | public static function find($id, array $columns = []): IEloquent |
||
90 | |||
91 | public static function findOrFail($id, array $columns = []): IEloquent |
||
99 | |||
100 | public static function create(array $attributes): IEloquent |
||
106 | |||
107 | public static function destroy($id) |
||
111 | |||
112 | public function save(array $columns = []) |
||
131 | |||
132 | public function delete() |
||
143 | } |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: