scriptotek /
bibrex
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Events; |
||
| 4 | |||
| 5 | use App\Loan; |
||
| 6 | use Illuminate\Broadcasting\Channel; |
||
| 7 | use Illuminate\Http\Request; |
||
| 8 | use Illuminate\Queue\SerializesModels; |
||
| 9 | use Illuminate\Broadcasting\PrivateChannel; |
||
| 10 | use Illuminate\Broadcasting\PresenceChannel; |
||
| 11 | use Illuminate\Foundation\Events\Dispatchable; |
||
| 12 | use Illuminate\Broadcasting\InteractsWithSockets; |
||
| 13 | use Illuminate\Contracts\Broadcasting\ShouldBroadcast; |
||
| 14 | |||
| 15 | class LoanTableUpdated implements ShouldBroadcast |
||
| 16 | { |
||
| 17 | use Dispatchable, InteractsWithSockets, SerializesModels; |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 18 | |||
| 19 | /** |
||
| 20 | * Action to highlight |
||
| 21 | * |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | public $action; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Loan to highlight |
||
| 28 | * |
||
| 29 | * @var string |
||
| 30 | */ |
||
| 31 | public $loan; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Sender window |
||
| 35 | * |
||
| 36 | * @var string |
||
| 37 | */ |
||
| 38 | public $sender; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Create a new event instance. |
||
| 42 | * |
||
| 43 | * @param string $action |
||
| 44 | * @param Request $request |
||
| 45 | * @param Loan|null $loan |
||
| 46 | */ |
||
| 47 | public function __construct(string $action, Request $request, Loan $loan = null) |
||
| 48 | { |
||
| 49 | $this->action = $action; |
||
| 50 | $this->sender = $request->headers->get('x-bibrex-window'); |
||
| 51 | $this->loan = $loan ? $loan->toArray() : null; |
||
|
0 ignored issues
–
show
It seems like
$loan ? $loan->toArray() : null can also be of type array. However, the property $loan 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...
|
|||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Get the channels the event should broadcast on. |
||
| 56 | * |
||
| 57 | * @return \Illuminate\Broadcasting\Channel|array |
||
| 58 | */ |
||
| 59 | public function broadcastOn() |
||
| 60 | { |
||
| 61 | $library = \Auth::user(); |
||
| 62 | return new PrivateChannel('loans.' . $library->id); |
||
| 63 | } |
||
| 64 | } |
||
| 65 |