Issues (21)

example/Models/Address.php (3 issues)

1
<?php
2
3
namespace Example\Models;
4
5
use CoffeeCode\DataLayer\DataLayer;
6
7
/**
8
 * Class Address
9
 * @package Example\Models
10
 */
11
class Address extends DataLayer
12
{
13
    /**
14
     * Address constructor.
15
     */
16
    public function __construct()
17
    {
18
        parent::__construct("adresses", ["user_id"]);
19
    }
20
21
    /**
22
     * @return $this
23
     */
24
    public function getUser(): Address
25
    {
26
        $this->user = (new User())->findById($this->user_id)->data();
0 ignored issues
show
$this->user_id of type null|string is incompatible with the type integer expected by parameter $id of CoffeeCode\DataLayer\DataLayer::findById(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        $this->user = (new User())->findById(/** @scrutinizer ignore-type */ $this->user_id)->data();
Loading history...
Bug Best Practice introduced by
The property user_id does not exist on Example\Models\Address. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property user does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
27
        return $this;
28
    }
29
}