Passed
Push — laravel-5 ( 66f120...6eb64b )
by Robert
02:51
created

src/Events/TagRemoved.php (2 issues)

1
<?php
2
3
namespace Conner\Tagging\Events;
4
5
use Conner\Tagging\Taggable;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Queue\SerializesModels;
8
9
class TagRemoved
10
{
11
    use SerializesModels;
0 ignored issues
show
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by Conner\Tagging\Events\TagRemoved: $id, $class, $connection, $relations
Loading history...
12
13
    /** @var \Conner\Tagging\Taggable **/
14
    public $model;
15
16
    /**
17
     * Create a new event instance.
18
     *
19
     * @param Taggable|Model $model
20
     * @return void
21
     */
22
    public function __construct($model)
23
    {
24
        $this->model = $model;
0 ignored issues
show
Documentation Bug introduced by
It seems like $model can also be of type Illuminate\Database\Eloquent\Model. However, the property $model is declared as type Conner\Tagging\Taggable. 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 $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

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...
25
    }
26
}