1 | <?php namespace Conner\Tagging\Events; |
||
2 | |||
3 | use Conner\Tagging\Model\Tagged; |
||
4 | use Conner\Tagging\Taggable; |
||
5 | use Illuminate\Queue\SerializesModels; |
||
6 | use Illuminate\Database\Eloquent\Model; |
||
7 | |||
8 | class TagAdded |
||
9 | { |
||
10 | use SerializesModels; |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
11 | |||
12 | /** @var Model **/ |
||
13 | public $model; |
||
14 | |||
15 | /** @var string */ |
||
16 | public $tagSlug; |
||
17 | |||
18 | /** @var Tagged */ |
||
19 | public $tagged; |
||
20 | |||
21 | /** |
||
22 | * Create a new event instance. |
||
23 | * |
||
24 | * @param Taggable|Model $model |
||
25 | * @param string $tagSlug |
||
26 | * @param Tagged $tagged |
||
27 | */ |
||
28 | public function __construct($model, string $tagSlug, Tagged $tagged) |
||
29 | { |
||
30 | $this->model = $model; |
||
0 ignored issues
–
show
It seems like
$model can also be of type Conner\Tagging\Taggable . However, the property $model is declared as type Illuminate\Database\Eloquent\Model . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
31 | $this->tagSlug = $tagSlug; |
||
32 | $this->tagged = $tagged; |
||
33 | } |
||
34 | } |