Skip to content

Commit

Permalink
Resolve implicit null deprecation in PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
navarr committed Dec 30, 2024
1 parent 5940b7f commit f4602de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ public function disconnect(Socket $client, string $message = ''): bool
*
* @param string $command Hook to listen for (e.g. HOOK_CONNECT, HOOK_INPUT, HOOK_DISCONNECT, HOOK_TIMEOUT)
* @param Socket $client
* @param string $input Message Sent along with the Trigger
* @param string|null $input Message Sent along with the Trigger
*
* @return bool Whether or not to continue running the server (true: continue, false: shutdown)
*/
protected function triggerHooks(string $command, Socket $client, string $input = null): bool
protected function triggerHooks(string $command, Socket $client, ?string $input = null): bool
{
if (isset($this->hooks[$command])) {
foreach ($this->hooks[$command] as $callable) {
Expand Down
8 changes: 4 additions & 4 deletions src/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,14 +709,14 @@ protected static function exceptionOnFalse(?SocketResource $resource, callable $
* <p>The function <code>write()</code> writes to the socket from the given buffer.</p>
*
* @param string $buffer The buffer to be written.
* @param ?int $length The optional parameter length can specify an alternate length of bytes written to the
* @param int|null $length The optional parameter length can specify an alternate length of bytes written to the
* socket. If this length is greater than the buffer length, it is silently truncated to the length of the buffer.
*
* @return int Returns the number of bytes successfully written to the socket.
* @throws SocketException If there was a failure.
*
*/
public function write(string $buffer, int $length = null): int
public function write(string $buffer, ?int $length = null): int
{
if (null === $length) {
$length = strlen($buffer);
Expand Down Expand Up @@ -753,13 +753,13 @@ public function write(string $buffer, int $length = null): int
* <li><code>MSG_EOF</code> - Close the sender side of the socket and include an appropriate notification
* of this at the end of the sent data. The sent data completes the transaction.</li>
* <li><code>MSG_DONTROUTE</code> - Bypass routing, use direct interface.</li></ul></p>
* @param int $length The number of bytes that will be sent to the remote host from buffer.
* @param int|null $length The number of bytes that will be sent to the remote host from buffer.
*
* @return int Returns the number of bytes sent.
* @throws SocketException If there was a failure.
*
*/
public function send(string $buffer, int $flags = 0, int $length = null): int
public function send(string $buffer, int $flags = 0, ?int $length = null): int
{
if (null === $length) {
$length = strlen($buffer);
Expand Down

0 comments on commit f4602de

Please sign in to comment.