Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Concerns/OffersHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function registerLoopEventHandler(\Closure $callback): MqttClient
* This does not affect other registered event handlers. It is possible
* to unregister all registered event handlers by passing null as callback.
*/
public function unregisterLoopEventHandler(\Closure $callback = null): MqttClient
public function unregisterLoopEventHandler(?\Closure $callback = null): MqttClient
{
if ($callback === null) {
$this->loopEventHandlers->removeAll($this->loopEventHandlers);
Expand Down Expand Up @@ -139,7 +139,7 @@ public function registerPublishEventHandler(\Closure $callback): MqttClient
* This does not affect other registered event handlers. It is possible
* to unregister all registered event handlers by passing null as callback.
*/
public function unregisterPublishEventHandler(\Closure $callback = null): MqttClient
public function unregisterPublishEventHandler(?\Closure $callback = null): MqttClient
{
if ($callback === null) {
$this->publishEventHandlers->removeAll($this->publishEventHandlers);
Expand Down Expand Up @@ -205,7 +205,7 @@ public function registerMessageReceivedEventHandler(\Closure $callback): MqttCli
* This does not affect other registered event handlers. It is possible
* to unregister all registered event handlers by passing null as callback.
*/
public function unregisterMessageReceivedEventHandler(\Closure $callback = null): MqttClient
public function unregisterMessageReceivedEventHandler(?\Closure $callback = null): MqttClient
{
if ($callback === null) {
$this->messageReceivedEventHandlers->removeAll($this->messageReceivedEventHandlers);
Expand Down Expand Up @@ -272,7 +272,7 @@ public function registerConnectedEventHandler(\Closure $callback): MqttClient
* This does not affect other registered event handlers. It is possible
* to unregister all registered event handlers by passing null as callback.
*/
public function unregisterConnectedEventHandler(\Closure $callback = null): MqttClient
public function unregisterConnectedEventHandler(?\Closure $callback = null): MqttClient
{
if ($callback === null) {
$this->connectedEventHandlers->removeAll($this->connectedEventHandlers);
Expand Down
8 changes: 4 additions & 4 deletions src/Contracts/MqttClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface MqttClient
* @throws ConfigurationInvalidException
* @throws ConnectingToBrokerFailedException
*/
public function connect(ConnectionSettings $settings = null, bool $useCleanSession = false): void;
public function connect(?ConnectionSettings $settings = null, bool $useCleanSession = false): void;

/**
* Sends a disconnect message to the broker and closes the socket.
Expand Down Expand Up @@ -195,7 +195,7 @@ public function registerLoopEventHandler(\Closure $callback): MqttClient;
* This does not affect other registered event handlers. It is possible
* to unregister all registered event handlers by passing null as callback.
*/
public function unregisterLoopEventHandler(\Closure $callback = null): MqttClient;
public function unregisterLoopEventHandler(?\Closure $callback = null): MqttClient;

/**
* Registers a loop event handler which is called when a message is published.
Expand Down Expand Up @@ -230,7 +230,7 @@ public function registerPublishEventHandler(\Closure $callback): MqttClient;
* This does not affect other registered event handlers. It is possible
* to unregister all registered event handlers by passing null as callback.
*/
public function unregisterPublishEventHandler(\Closure $callback = null): MqttClient;
public function unregisterPublishEventHandler(?\Closure $callback = null): MqttClient;

/**
* Registers an event handler which is called when a message is received from the broker.
Expand Down Expand Up @@ -262,5 +262,5 @@ public function registerMessageReceivedEventHandler(\Closure $callback): MqttCli
* This does not affect other registered event handlers. It is possible
* to unregister all registered event handlers by passing null as callback.
*/
public function unregisterMessageReceivedEventHandler(\Closure $callback = null): MqttClient;
public function unregisterMessageReceivedEventHandler(?\Closure $callback = null): MqttClient;
}
2 changes: 1 addition & 1 deletion src/Contracts/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getPendingOutgoingMessage(int $messageId): ?PendingMessage;
*
* @return PendingMessage[]
*/
public function getPendingOutgoingMessagesLastSentBefore(DateTime $dateTime = null): array;
public function getPendingOutgoingMessagesLastSentBefore(?DateTime $dateTime = null): array;

/**
* Adds a pending outgoing message to the repository.
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/MqttClientException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MqttClientException extends \Exception
/**
* MqttClientException constructor.
*/
public function __construct(string $message = '', int $code = 0, \Throwable $parentException = null)
public function __construct(string $message = '', int $code = 0, ?\Throwable $parentException = null)
{
if (empty($message)) {
parent::__construct(
Expand Down
4 changes: 2 additions & 2 deletions src/MessageProcessors/Mqtt31MessageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(private string $clientId, LoggerInterface $logger)
/**
* {@inheritDoc}
*/
public function tryFindMessageInBuffer(string $buffer, int $bufferLength, string &$message = null, int &$requiredBytes = -1): bool
public function tryFindMessageInBuffer(string $buffer, int $bufferLength, ?string &$message = null, int &$requiredBytes = -1): bool
{
// If we received no input, we can return immediately without doing work.
if ($bufferLength === 0) {
Expand Down Expand Up @@ -328,7 +328,7 @@ public function buildPublishMessage(
string $message,
int $qualityOfService,
bool $retain,
int $messageId = null,
?int $messageId = null,
bool $isDuplicate = false,
): string
{
Expand Down
10 changes: 5 additions & 5 deletions src/MqttClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public function __construct(
private int $port = 1883,
?string $clientId = null,
string $protocol = self::MQTT_3_1,
Repository $repository = null,
LoggerInterface $logger = null
?Repository $repository = null,
?LoggerInterface $logger = null
)
{
if (!in_array($protocol, [self::MQTT_3_1, self::MQTT_3_1_1])) {
Expand All @@ -97,7 +97,7 @@ public function __construct(
/**
* {@inheritDoc}
*/
public function connect(ConnectionSettings $settings = null, bool $useCleanSession = false): void
public function connect(?ConnectionSettings $settings = null, bool $useCleanSession = false): void
{
// Always abruptly close any previous connection if we are opening a new one.
// The caller should make sure this does not happen.
Expand Down Expand Up @@ -546,7 +546,7 @@ protected function publishMessage(
/**
* {@inheritDoc}
*/
public function subscribe(string $topicFilter, callable $callback = null, int $qualityOfService = self::QOS_AT_MOST_ONCE): void
public function subscribe(string $topicFilter, ?callable $callback = null, int $qualityOfService = self::QOS_AT_MOST_ONCE): void
{
$this->ensureConnected();

Expand Down Expand Up @@ -598,7 +598,7 @@ protected function nextPingAt(): float
/**
* {@inheritDoc}
*/
public function loop(bool $allowSleep = true, bool $exitWhenQueuesEmpty = false, int $queueWaitLimit = null): void
public function loop(bool $allowSleep = true, bool $exitWhenQueuesEmpty = false, ?int $queueWaitLimit = null): void
{
$this->logger->debug('Starting client loop to process incoming messages and the resend queue.');

Expand Down
4 changes: 2 additions & 2 deletions src/PendingMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class PendingMessage
/**
* Creates a new pending message object.
*/
protected function __construct(private int $messageId, DateTime $sentAt = null)
protected function __construct(private int $messageId, ?DateTime $sentAt = null)
{
$this->lastSentAt = $sentAt ?? new DateTime();
}
Expand Down Expand Up @@ -57,7 +57,7 @@ public function getSendingAttempts(): int
/**
* Sets the date time when the message was last sent.
*/
public function setLastSentAt(DateTime $value = null): self
public function setLastSentAt(?DateTime $value = null): self
{
$this->lastSentAt = $value ?? new DateTime();

Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/MemoryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getPendingOutgoingMessage(int $messageId): ?PendingMessage
/**
* {@inheritDoc}
*/
public function getPendingOutgoingMessagesLastSentBefore(\DateTime $dateTime = null): array
public function getPendingOutgoingMessagesLastSentBefore(?\DateTime $dateTime = null): array
{
$result = [];

Expand Down
Loading