1 | <?php |
||
2 | |||
3 | namespace Jerodev\PhpIrcClient\Options; |
||
4 | |||
5 | class ClientOptions |
||
6 | { |
||
7 | /** |
||
8 | * Automaticly connect to the irc server when creating the client. |
||
9 | * |
||
10 | * @var bool |
||
11 | */ |
||
12 | public $autoConnect; |
||
13 | |||
14 | /** |
||
15 | * Automaticly rejoin a channel when kicked. |
||
16 | * |
||
17 | * @var bool |
||
18 | */ |
||
19 | public $autoRejoin; |
||
20 | |||
21 | /** |
||
22 | * The channel names to join when connecting. |
||
23 | * |
||
24 | * @var string[] |
||
25 | */ |
||
26 | public $channels; |
||
27 | |||
28 | /** |
||
29 | * The amount of time in milliseconds to wait between sending messages to the irc server. |
||
30 | * |
||
31 | * @var int |
||
32 | */ |
||
33 | public $floodProtectionDelay; |
||
34 | |||
35 | /** |
||
36 | * The nickname to use on the server. |
||
37 | * |
||
38 | * @var null|string |
||
39 | */ |
||
40 | public $nickname; |
||
41 | |||
42 | /** |
||
43 | * @param string $nickname The nickname used on the irc server. |
||
44 | * @param string|string[] $channels The channels to join on connection. |
||
45 | */ |
||
46 | public function __construct(?string $nickname = null, $channels = []) |
||
47 | { |
||
48 | $this->nickname = $nickname; |
||
49 | |||
50 | if (!is_array($channels)) { |
||
51 | $channels = [$channels]; |
||
52 | } |
||
53 | $this->channels = $channels; |
||
0 ignored issues
–
show
|
|||
54 | |||
55 | $this->autoRejoin = false; |
||
56 | $this->autoConnect = false; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Get the options for the IrcConnection from this collection. |
||
61 | * |
||
62 | * @return ConnectionOptions |
||
63 | */ |
||
64 | public function connectionOptions(): ConnectionOptions |
||
65 | { |
||
66 | $options = new ConnectionOptions(); |
||
67 | $options->floodProtectionDelay = $this->floodProtectionDelay; |
||
68 | |||
69 | return $options; |
||
70 | } |
||
71 | } |
||
72 |
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 theid
property of an instance of theAccount
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.