Skip to content

Commit 458afc0

Browse files
authored
Update to require minimum PHP 8 (#170)
* Require PHP 8.0 * Apply rector with PHP 8 defaults * Add manual changes as needed * Test PHP 8.2 and 8.3 instead of 7.4
1 parent 532339e commit 458afc0

33 files changed

+83
-734
lines changed

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
php-version: ['7.4', '8.0', '8.1']
18+
php-version: ['8.0', '8.1', '8.2', '8.3']
1919
mqtt-broker: ['mosquitto-1.6', 'mosquitto-2.0', 'hivemq', 'emqx', 'rabbitmq']
2020
include:
21-
- php-version: '8.1'
21+
- php-version: '8.3'
2222
mqtt-broker: 'mosquitto-2.0'
2323
run-sonarqube-analysis: true
2424

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
},
2929
"require": {
30-
"php": "^7.4|^8.0",
30+
"php": "^8.0",
3131
"psr/log": "^1.1|^2.0|^3.0",
3232
"myclabs/php-enum": "^1.7"
3333
},

src/Concerns/GeneratesRandomClientIds.php

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ trait GeneratesRandomClientIds
1313
{
1414
/**
1515
* Generates a random client id in the form of an md5 hash.
16-
*
17-
* @return string
1816
*/
1917
protected function generateRandomClientId(): string
2018
{

src/Concerns/OffersHooks.php

-45
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ trait OffersHooks
2828

2929
/**
3030
* Needs to be called in order to initialize the trait.
31-
*
32-
* @return void
3331
*/
3432
protected function initializeEventHandlers(): void
3533
{
@@ -59,9 +57,6 @@ protected function initializeEventHandlers(): void
5957
* ```
6058
*
6159
* Multiple event handlers can be registered at the same time.
62-
*
63-
* @param \Closure $callback
64-
* @return MqttClient
6560
*/
6661
public function registerLoopEventHandler(\Closure $callback): MqttClient
6762
{
@@ -77,9 +72,6 @@ public function registerLoopEventHandler(\Closure $callback): MqttClient
7772
*
7873
* This does not affect other registered event handlers. It is possible
7974
* to unregister all registered event handlers by passing null as callback.
80-
*
81-
* @param \Closure|null $callback
82-
* @return MqttClient
8375
*/
8476
public function unregisterLoopEventHandler(\Closure $callback = null): MqttClient
8577
{
@@ -96,9 +88,6 @@ public function unregisterLoopEventHandler(\Closure $callback = null): MqttClien
9688
/**
9789
* Runs all registered loop event handlers with the given parameters.
9890
* Each event handler is executed in a try-catch block to avoid spilling exceptions.
99-
*
100-
* @param float $elapsedTime
101-
* @return void
10291
*/
10392
private function runLoopEventHandlers(float $elapsedTime): void
10493
{
@@ -134,9 +123,6 @@ private function runLoopEventHandlers(float $elapsedTime): void
134123
* ```
135124
*
136125
* Multiple event handlers can be registered at the same time.
137-
*
138-
* @param \Closure $callback
139-
* @return MqttClient
140126
*/
141127
public function registerPublishEventHandler(\Closure $callback): MqttClient
142128
{
@@ -152,9 +138,6 @@ public function registerPublishEventHandler(\Closure $callback): MqttClient
152138
*
153139
* This does not affect other registered event handlers. It is possible
154140
* to unregister all registered event handlers by passing null as callback.
155-
*
156-
* @param \Closure|null $callback
157-
* @return MqttClient
158141
*/
159142
public function unregisterPublishEventHandler(\Closure $callback = null): MqttClient
160143
{
@@ -171,13 +154,6 @@ public function unregisterPublishEventHandler(\Closure $callback = null): MqttCl
171154
/**
172155
* Runs all the registered publish event handlers with the given parameters.
173156
* Each event handler is executed in a try-catch block to avoid spilling exceptions.
174-
*
175-
* @param string $topic
176-
* @param string $message
177-
* @param int|null $messageId
178-
* @param int $qualityOfService
179-
* @param bool $retain
180-
* @return void
181157
*/
182158
private function runPublishEventHandlers(string $topic, string $message, ?int $messageId, int $qualityOfService, bool $retain): void
183159
{
@@ -214,9 +190,6 @@ private function runPublishEventHandlers(string $topic, string $message, ?int $m
214190
* ```
215191
*
216192
* Multiple event handlers can be registered at the same time.
217-
*
218-
* @param \Closure $callback
219-
* @return MqttClient
220193
*/
221194
public function registerMessageReceivedEventHandler(\Closure $callback): MqttClient
222195
{
@@ -231,9 +204,6 @@ public function registerMessageReceivedEventHandler(\Closure $callback): MqttCli
231204
*
232205
* This does not affect other registered event handlers. It is possible
233206
* to unregister all registered event handlers by passing null as callback.
234-
*
235-
* @param \Closure|null $callback
236-
* @return MqttClient
237207
*/
238208
public function unregisterMessageReceivedEventHandler(\Closure $callback = null): MqttClient
239209
{
@@ -250,12 +220,6 @@ public function unregisterMessageReceivedEventHandler(\Closure $callback = null)
250220
/**
251221
* Runs all the registered message received event handlers with the given parameters.
252222
* Each event handler is executed in a try-catch block to avoid spilling exceptions.
253-
*
254-
* @param string $topic
255-
* @param string $message
256-
* @param int $qualityOfService
257-
* @param bool $retained
258-
* @return void
259223
*/
260224
private function runMessageReceivedEventHandlers(string $topic, string $message, int $qualityOfService, bool $retained): void
261225
{
@@ -293,9 +257,6 @@ private function runMessageReceivedEventHandlers(string $topic, string $message,
293257
* ```
294258
*
295259
* Multiple event handlers can be registered at the same time.
296-
*
297-
* @param \Closure $callback
298-
* @return MqttClient
299260
*/
300261
public function registerConnectedEventHandler(\Closure $callback): MqttClient
301262
{
@@ -310,9 +271,6 @@ public function registerConnectedEventHandler(\Closure $callback): MqttClient
310271
*
311272
* This does not affect other registered event handlers. It is possible
312273
* to unregister all registered event handlers by passing null as callback.
313-
*
314-
* @param \Closure|null $callback
315-
* @return MqttClient
316274
*/
317275
public function unregisterConnectedEventHandler(\Closure $callback = null): MqttClient
318276
{
@@ -329,9 +287,6 @@ public function unregisterConnectedEventHandler(\Closure $callback = null): Mqtt
329287
/**
330288
* Runs all the registered connected event handlers.
331289
* Each event handler is executed in a try-catch block to avoid spilling exceptions.
332-
*
333-
* @param bool $isAutoReconnect
334-
* @return void
335290
*/
336291
private function runConnectedEventHandlers(bool $isAutoReconnect): void
337292
{

src/Concerns/TranscodesData.php

-12
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ trait TranscodesData
1919
* \x00\x0bhello world
2020
*
2121
* where \x00\0x0b is the hex representation of 00000000 00001011 = 11
22-
*
23-
* @param string $data
24-
* @return string
2522
*/
2623
protected function buildLengthPrefixedString(string $data): string
2724
{
@@ -35,9 +32,6 @@ protected function buildLengthPrefixedString(string $data): string
3532
/**
3633
* Converts the given string to a number, assuming it is an MSB encoded message id.
3734
* MSB means preceding characters have higher value.
38-
*
39-
* @param string $encodedMessageId
40-
* @return int
4135
*/
4236
protected function decodeMessageId(string $encodedMessageId): int
4337
{
@@ -53,9 +47,6 @@ protected function decodeMessageId(string $encodedMessageId): int
5347

5448
/**
5549
* Encodes the given message identifier as string.
56-
*
57-
* @param int $messageId
58-
* @return string
5950
*/
6051
protected function encodeMessageId(int $messageId): string
6152
{
@@ -65,9 +56,6 @@ protected function encodeMessageId(int $messageId): string
6556
/**
6657
* Encodes the length of a message as string, so it can be transmitted
6758
* over the wire.
68-
*
69-
* @param int $length
70-
* @return string
7159
*/
7260
protected function encodeMessageLength(int $length): string
7361
{

src/Concerns/ValidatesConfiguration.php

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ trait ValidatesConfiguration
2121
* which means they are misconfigured, an exception containing information about
2222
* the configuration error is thrown.
2323
*
24-
* @param ConnectionSettings $settings
25-
* @return void
2624
* @throws ConfigurationInvalidException
2725
*/
2826
protected function ensureConnectionSettingsAreValid(ConnectionSettings $settings): void

src/Concerns/WorksWithBuffers.php

-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ trait WorksWithBuffers
1313
{
1414
/**
1515
* Pops the first $limit bytes from the given buffer and returns them.
16-
*
17-
* @param string $buffer
18-
* @param int $limit
19-
* @return string
2016
*/
2117
protected function pop(string &$buffer, int $limit): string
2218
{

0 commit comments

Comments
 (0)