6
6
7
7
/**
8
8
* The settings used during connection to a broker.
9
+ *
10
+ * This class is immutable and all setters return a clone of the original class because
11
+ * connection settings must not change once passed to MqttClient.
9
12
*
10
13
* @package PhpMqtt\Client
11
14
*/
@@ -39,7 +42,7 @@ class ConnectionSettings
39
42
* The username used for authentication when connecting to the broker.
40
43
*
41
44
* @param string|null $username
42
- * @return ConnectionSettings
45
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
43
46
*/
44
47
public function setUsername (?string $ username ): ConnectionSettings
45
48
{
@@ -62,7 +65,7 @@ public function getUsername(): ?string
62
65
* The password used for authentication when connecting to the broker.
63
66
*
64
67
* @param string|null $password
65
- * @return ConnectionSettings
68
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
66
69
*/
67
70
public function setPassword (?string $ password ): ConnectionSettings
68
71
{
@@ -89,7 +92,7 @@ public function getPassword(): ?string
89
92
* Note: This setting has no effect on subscriptions, only on the publishing of messages.
90
93
*
91
94
* @param bool $useBlockingSocket
92
- * @return ConnectionSettings
95
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
93
96
*/
94
97
public function useBlockingSocket (bool $ useBlockingSocket ): ConnectionSettings
95
98
{
@@ -113,7 +116,7 @@ public function shouldUseBlockingSocket(): bool
113
116
* a socket connection with the broker. The value cannot be less than 1 second.
114
117
*
115
118
* @param int $connectTimeout
116
- * @return ConnectionSettings
119
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
117
120
*/
118
121
public function setConnectTimeout (int $ connectTimeout ): ConnectionSettings
119
122
{
@@ -138,7 +141,7 @@ public function getConnectTimeout(): int
138
141
* The value cannot be less than 1 second.
139
142
*
140
143
* @param int $socketTimeout
141
- * @return ConnectionSettings
144
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
142
145
*/
143
146
public function setSocketTimeout (int $ socketTimeout ): ConnectionSettings
144
147
{
@@ -162,7 +165,7 @@ public function getSocketTimeout(): int
162
165
* of pending messages without acknowledgement. The value cannot be less than 1 second.
163
166
*
164
167
* @param int $resendTimeout
165
- * @return ConnectionSettings
168
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
166
169
*/
167
170
public function setResendTimeout (int $ resendTimeout ): ConnectionSettings
168
171
{
@@ -187,7 +190,7 @@ public function getResendTimeout(): int
187
190
* and may not be higher than 65535 seconds. A reasonable value is 10 seconds (the default).
188
191
*
189
192
* @param int $keepAliveInterval
190
- * @return ConnectionSettings
193
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
191
194
*/
192
195
public function setKeepAliveInterval (int $ keepAliveInterval ): ConnectionSettings
193
196
{
@@ -212,7 +215,7 @@ public function getKeepAliveInterval(): int
212
215
* The setting cannot be used together with the clean session flag.
213
216
*
214
217
* @param bool $reconnectAutomatically
215
- * @return ConnectionSettings
218
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
216
219
*/
217
220
public function setReconnectAutomatically (bool $ reconnectAutomatically ): ConnectionSettings
218
221
{
@@ -236,7 +239,7 @@ public function shouldReconnectAutomatically(): bool
236
239
* is only relevant if {@see setReconnectAutomatically()} is set to true.
237
240
*
238
241
* @param int $maxReconnectAttempts
239
- * @return ConnectionSettings
242
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
240
243
*/
241
244
public function setMaxReconnectAttempts (int $ maxReconnectAttempts ): ConnectionSettings
242
245
{
@@ -260,7 +263,7 @@ public function getMaxReconnectAttempts(): int
260
263
* This setting is only relevant if {@see setReconnectAutomatically()} is set to true.
261
264
*
262
265
* @param int $delayBetweenReconnectAttempts
263
- * @return ConnectionSettings
266
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
264
267
*/
265
268
public function setDelayBetweenReconnectAttempts (int $ delayBetweenReconnectAttempts ): ConnectionSettings
266
269
{
@@ -287,7 +290,7 @@ public function getDelayBetweenReconnectAttempts(): int
287
290
* message are configured.
288
291
*
289
292
* @param string|null $lastWillTopic
290
- * @return ConnectionSettings
293
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
291
294
*/
292
295
public function setLastWillTopic (?string $ lastWillTopic ): ConnectionSettings
293
296
{
@@ -314,7 +317,7 @@ public function getLastWillTopic(): ?string
314
317
* topic are configured.
315
318
*
316
319
* @param string|null $lastWillMessage
317
- * @return ConnectionSettings
320
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
318
321
*/
319
322
public function setLastWillMessage (?string $ lastWillMessage ): ConnectionSettings
320
323
{
@@ -348,7 +351,7 @@ public function hasLastWill(): bool
348
351
* if it gets triggered.
349
352
*
350
353
* @param int $lastWillQualityOfService
351
- * @return ConnectionSettings
354
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
352
355
*/
353
356
public function setLastWillQualityOfService (int $ lastWillQualityOfService ): ConnectionSettings
354
357
{
@@ -373,7 +376,7 @@ public function getLastWillQualityOfService(): int
373
376
* a retained offline state in the last will and an online state as first message on connect.
374
377
*
375
378
* @param bool $lastWillRetain
376
- * @return ConnectionSettings
379
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
377
380
*/
378
381
public function setRetainLastWill (bool $ lastWillRetain ): ConnectionSettings
379
382
{
@@ -397,7 +400,7 @@ public function shouldRetainLastWill(): bool
397
400
* connect to the broker must support TLS connections.
398
401
*
399
402
* @param bool $useTls
400
- * @return ConnectionSettings
403
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
401
404
*/
402
405
public function setUseTls (bool $ useTls ): ConnectionSettings
403
406
{
@@ -420,7 +423,7 @@ public function shouldUseTls(): bool
420
423
* This flag determines if the peer certificate is verified, if TLS is used.
421
424
*
422
425
* @param bool $tlsVerifyPeer
423
- * @return ConnectionSettings
426
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
424
427
*/
425
428
public function setTlsVerifyPeer (bool $ tlsVerifyPeer ): ConnectionSettings
426
429
{
@@ -443,7 +446,7 @@ public function shouldTlsVerifyPeer(): bool
443
446
* This flag determines if the peer name is verified, if TLS is used.
444
447
*
445
448
* @param bool $tlsVerifyPeerName
446
- * @return ConnectionSettings
449
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
447
450
*/
448
451
public function setTlsVerifyPeerName (bool $ tlsVerifyPeerName ): ConnectionSettings
449
452
{
@@ -468,7 +471,7 @@ public function shouldTlsVerifyPeerName(): bool
468
471
* scenarios and public services.
469
472
*
470
473
* @param bool $tlsSelfSignedAllowed
471
- * @return ConnectionSettings
474
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
472
475
*/
473
476
public function setTlsSelfSignedAllowed (bool $ tlsSelfSignedAllowed ): ConnectionSettings
474
477
{
@@ -492,7 +495,7 @@ public function isTlsSelfSignedAllowed(): bool
492
495
* certificate, if TLS is used.
493
496
*
494
497
* @param string|null $tlsCertificateAuthorityFile
495
- * @return ConnectionSettings
498
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
496
499
*/
497
500
public function setTlsCertificateAuthorityFile (?string $ tlsCertificateAuthorityFile ): ConnectionSettings
498
501
{
@@ -521,7 +524,7 @@ public function getTlsCertificateAuthorityFile(): ?string
521
524
* array under the key "hash".
522
525
*
523
526
* @param string|null $tlsCertificateAuthorityPath
524
- * @return ConnectionSettings
527
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
525
528
*/
526
529
public function setTlsCertificateAuthorityPath (?string $ tlsCertificateAuthorityPath ): ConnectionSettings
527
530
{
@@ -549,7 +552,7 @@ public function getTlsCertificateAuthorityPath(): ?string
549
552
* A passphrase can be configured using {@see ConnectionSettings::setTlsClientCertificateKeyPassphrase()}.
550
553
*
551
554
* @param string|null $tlsClientCertificateFile
552
- * @return ConnectionSettings
555
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
553
556
*/
554
557
public function setTlsClientCertificateFile (?string $ tlsClientCertificateFile ): ConnectionSettings
555
558
{
@@ -575,7 +578,7 @@ public function getTlsClientCertificateFile(): ?string
575
578
* to be used as well.
576
579
*
577
580
* @param string|null $tlsClientCertificateKeyFile
578
- * @return ConnectionSettings
581
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
579
582
*/
580
583
public function setTlsClientCertificateKeyFile (?string $ tlsClientCertificateKeyFile ): ConnectionSettings
581
584
{
@@ -604,7 +607,7 @@ public function getTlsClientCertificateKeyFile(): ?string
604
607
* Please be aware that your passphrase is not stored in secure memory when using this option.
605
608
*
606
609
* @param string|null $tlsClientCertificateKeyPassphrase
607
- * @return ConnectionSettings
610
+ * @return ConnectionSettings A copy of the original object with the new setting applied.
608
611
*/
609
612
public function setTlsClientCertificateKeyPassphrase (?string $ tlsClientCertificateKeyPassphrase ): ConnectionSettings
610
613
{
0 commit comments