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

src/Events/TagAdded.php (2 issues)

1
<?php namespace Conner\Tagging\Events;
2
3
use Conner\Tagging\Taggable;
4
use Illuminate\Queue\SerializesModels;
5
use Illuminate\Database\Eloquent\Model;
6
7
class TagAdded
8
{
9
    use SerializesModels;
0 ignored issues
show
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by Conner\Tagging\Events\TagAdded: $id, $class, $connection, $relations
Loading history...
10
11
    /** @var \Illuminate\Database\Eloquent\Model **/
12
    public $model;
13
14
    /**
15
     * Create a new event instance.
16
     *
17
     * @param Taggable|Model $model
18
     * @return void
19
     */
20
    public function __construct($model)
21
    {
22
        $this->model = $model;
0 ignored issues
show
Documentation Bug introduced by Robert Conner
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 $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...
23
    }
24
}