beyondcode /
laravel-websockets
| 1 | <?php |
||
| 2 | |||
| 3 | namespace BeyondCode\LaravelWebSockets\Events; |
||
| 4 | |||
| 5 | use Illuminate\Foundation\Events\Dispatchable; |
||
| 6 | use Illuminate\Queue\SerializesModels; |
||
| 7 | use stdClass; |
||
| 8 | |||
| 9 | class UnsubscribedFromChannel |
||
| 10 | { |
||
| 11 | use Dispatchable, SerializesModels; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 12 | |||
| 13 | /** |
||
| 14 | * The WebSockets app id that the user connected to. |
||
| 15 | * |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | public $appId; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * The Socket ID associated with the connection. |
||
| 22 | * |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | public $socketId; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * The channel name. |
||
| 29 | * |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | public $channelName; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * The user received on presence channel. |
||
| 36 | * |
||
| 37 | * @var string |
||
| 38 | */ |
||
| 39 | public $user; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Create a new event instance. |
||
| 43 | * |
||
| 44 | * @param string $appId |
||
| 45 | * @param string $socketId |
||
| 46 | * @param string $channelName |
||
| 47 | * @param stdClass|null $user |
||
| 48 | * @return void |
||
| 49 | */ |
||
| 50 | public function __construct(string $appId, string $socketId, string $channelName, ?stdClass $user = null) |
||
| 51 | { |
||
| 52 | $this->appId = $appId; |
||
| 53 | $this->socketId = $socketId; |
||
| 54 | $this->channelName = $channelName; |
||
| 55 | $this->user = $user; |
||
|
0 ignored issues
–
show
It seems like
$user can also be of type stdClass. However, the property $user is declared as type string. 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...
|
|||
| 56 | } |
||
| 57 | } |
||
| 58 |