Skip to content

Commit e88fd4c

Browse files
authored
Fix implicit marking of parameters as nullable, deprecated in PHP 8.4 (Webklex#518)
* Fix implicit marking of parameters as nullable, which is deprecated in PHP 8.4. * Change line separators to LF
1 parent 4601d2f commit e88fd4c

File tree

11 files changed

+195
-195
lines changed

11 files changed

+195
-195
lines changed

src/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ public function getFolderByPath($folder_path, bool $utf7 = false, bool $soft_fai
572572
* @throws ResponseException
573573
* @throws RuntimeException
574574
*/
575-
public function getFolders(bool $hierarchical = true, string $parent_folder = null, bool $soft_fail = false): FolderCollection {
575+
public function getFolders(bool $hierarchical = true, ?string $parent_folder = null, bool $soft_fail = false): FolderCollection {
576576
$this->checkConnection();
577577
$folders = FolderCollection::make([]);
578578

@@ -618,7 +618,7 @@ public function getFolders(bool $hierarchical = true, string $parent_folder = nu
618618
* @throws RuntimeException
619619
* @throws ResponseException
620620
*/
621-
public function getFoldersWithStatus(bool $hierarchical = true, string $parent_folder = null, bool $soft_fail = false): FolderCollection {
621+
public function getFoldersWithStatus(bool $hierarchical = true, ?string $parent_folder = null, bool $soft_fail = false): FolderCollection {
622622
$this->checkConnection();
623623
$folders = FolderCollection::make([]);
624624

@@ -793,7 +793,7 @@ public function getFolderPath(): ?string {
793793
* @throws RuntimeException
794794
* @throws ResponseException
795795
*/
796-
public function Id(array $ids = null): array {
796+
public function Id(?array $ids = null): array {
797797
$this->checkConnection();
798798
return $this->connection->ID($ids)->validatedData();
799799
}

src/ClientManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function make(array $config): Client {
7474
* @return Client
7575
* @throws Exceptions\MaskNotFoundException
7676
*/
77-
public function account(string $name = null): Client {
77+
public function account(?string $name = null): Client {
7878
$name = $name ?: $this->config->getDefaultAccount();
7979

8080
// If the connection has not been resolved we will resolve it now as all

src/Connection/Protocols/ImapProtocol.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __destruct() {
6767
*
6868
* @throws ConnectionFailedException
6969
*/
70-
public function connect(string $host, int $port = null): bool {
70+
public function connect(string $host, ?int $port = null): bool {
7171
$transport = 'tcp';
7272
$encryption = '';
7373

@@ -426,7 +426,7 @@ private function stringifyArray(array $arr): string {
426426
* @return Response
427427
* @throws RuntimeException
428428
*/
429-
public function sendRequest(string $command, array $tokens = [], string &$tag = null): Response {
429+
public function sendRequest(string $command, array $tokens = [], ?string &$tag = null): Response {
430430
if (!$tag) {
431431
$this->noun++;
432432
$tag = 'TAG' . $this->noun;
@@ -1021,7 +1021,7 @@ public function folders(string $reference = '', string $folder = '*'): Response
10211021
* @throws RuntimeException
10221022
*/
10231023
public function store(
1024-
array|string $flags, int $from, int $to = null, string $mode = null, bool $silent = true, int|string $uid = IMAP::ST_UID, string $item = null
1024+
array|string $flags, int $from, ?int $to = null, ?string $mode = null, bool $silent = true, int|string $uid = IMAP::ST_UID, ?string $item = null
10251025
): Response {
10261026
$flags = $this->escapeList(is_array($flags) ? $flags : [$flags]);
10271027
$set = $this->buildSet($from, $to);
@@ -1061,7 +1061,7 @@ public function store(
10611061
* @throws ImapServerErrorException
10621062
* @throws RuntimeException
10631063
*/
1064-
public function appendMessage(string $folder, string $message, array $flags = null, string $date = null): Response {
1064+
public function appendMessage(string $folder, string $message, ?array $flags = null, ?string $date = null): Response {
10651065
$tokens = [];
10661066
$tokens[] = $this->escapeString($folder);
10671067
if ($flags !== null) {
@@ -1091,7 +1091,7 @@ public function appendMessage(string $folder, string $message, array $flags = nu
10911091
* @throws ImapServerErrorException
10921092
* @throws RuntimeException
10931093
*/
1094-
public function copyMessage(string $folder, $from, int $to = null, int|string $uid = IMAP::ST_UID): Response {
1094+
public function copyMessage(string $folder, $from, ?int $to = null, int|string $uid = IMAP::ST_UID): Response {
10951095
$set = $this->buildSet($from, $to);
10961096
$command = $this->buildUIDCommand("COPY", $uid);
10971097

@@ -1137,7 +1137,7 @@ public function copyManyMessages(array $messages, string $folder, int|string $ui
11371137
* @throws ImapServerErrorException
11381138
* @throws RuntimeException
11391139
*/
1140-
public function moveMessage(string $folder, $from, int $to = null, int|string $uid = IMAP::ST_UID): Response {
1140+
public function moveMessage(string $folder, $from, ?int $to = null, int|string $uid = IMAP::ST_UID): Response {
11411141
$set = $this->buildSet($from, $to);
11421142
$command = $this->buildUIDCommand("MOVE", $uid);
11431143

src/Connection/Protocols/LegacyProtocol.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __destruct() {
5555
* @param string $host
5656
* @param int|null $port
5757
*/
58-
public function connect(string $host, int $port = null): void {
58+
public function connect(string $host, ?int $port = null): void {
5959
if ($this->encryption) {
6060
$encryption = strtolower($this->encryption);
6161
if ($encryption == "ssl") {
@@ -360,7 +360,7 @@ public function sizes(int|array $uids, int|string $uid = IMAP::ST_UID): Response
360360
*
361361
* @return Response message number for given message or all messages as array
362362
*/
363-
public function getUid(int $id = null): Response {
363+
public function getUid(?int $id = null): Response {
364364
return $this->response()->wrap(function($response) use ($id) {
365365
/** @var Response $response */
366366
if ($id === null) {
@@ -455,7 +455,7 @@ public function folders(string $reference = '', string $folder = '*'): Response
455455
*
456456
* @return Response new flags if $silent is false, else true or false depending on success
457457
*/
458-
public function store(array|string $flags, int $from, int $to = null, string $mode = null, bool $silent = true, int|string $uid = IMAP::ST_UID, string $item = null): Response {
458+
public function store(array|string $flags, int $from, ?int $to = null, ?string $mode = null, bool $silent = true, int|string $uid = IMAP::ST_UID, ?string $item = null): Response {
459459
$flag = trim(is_array($flags) ? implode(" ", $flags) : $flags);
460460

461461
return $this->response()->wrap(function($response) use ($mode, $from, $flag, $uid, $silent) {
@@ -491,7 +491,7 @@ public function store(array|string $flags, int $from, int $to = null, string $mo
491491
*
492492
* @return Response
493493
*/
494-
public function appendMessage(string $folder, string $message, array $flags = null, mixed $date = null): Response {
494+
public function appendMessage(string $folder, string $message, ?array $flags = null, mixed $date = null): Response {
495495
return $this->response("imap_append")->wrap(function($response) use ($folder, $message, $flags, $date) {
496496
/** @var Response $response */
497497
if ($date != null) {
@@ -522,7 +522,7 @@ public function appendMessage(string $folder, string $message, array $flags = nu
522522
*
523523
* @return Response
524524
*/
525-
public function copyMessage(string $folder, $from, int $to = null, int|string $uid = IMAP::ST_UID): Response {
525+
public function copyMessage(string $folder, $from, ?int $to = null, int|string $uid = IMAP::ST_UID): Response {
526526
return $this->response("imap_mail_copy")->wrap(function($response) use ($from, $folder, $uid) {
527527
/** @var Response $response */
528528

@@ -572,7 +572,7 @@ public function copyManyMessages(array $messages, string $folder, int|string $ui
572572
*
573573
* @return Response success
574574
*/
575-
public function moveMessage(string $folder, $from, int $to = null, int|string $uid = IMAP::ST_UID): Response {
575+
public function moveMessage(string $folder, $from, ?int $to = null, int|string $uid = IMAP::ST_UID): Response {
576576
return $this->response("imap_mail_move")->wrap(function($response) use ($from, $folder, $uid) {
577577
if (\imap_mail_move($this->stream, $from, $this->getAddress() . $folder, $uid ? IMAP::ST_UID : IMAP::NIL)) {
578578
return [

src/EncodingAliases.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ class EncodingAliases {
474474
*
475475
* @return string
476476
*/
477-
public static function get(?string $encoding, string $fallback = null): string {
477+
public static function get(?string $encoding, ?string $fallback = null): string {
478478
if (isset(self::$aliases[strtolower($encoding ?? '')])) {
479479
return self::$aliases[strtolower($encoding ?? '')];
480480
}

src/Folder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public function move(string $new_name, bool $expunge = true): array {
307307
* @throws MessageNotFoundException
308308
* @throws ResponseException
309309
*/
310-
public function overview(string $sequence = null): array {
310+
public function overview(?string $sequence = null): array {
311311
$this->client->openFolder($this->path);
312312
$sequence = $sequence === null ? "1:*" : $sequence;
313313
$uid = $this->client->getConfig()->get('options.sequence', IMAP::ST_MSGN);
@@ -329,7 +329,7 @@ public function overview(string $sequence = null): array {
329329
* @throws AuthFailedException
330330
* @throws ResponseException
331331
*/
332-
public function appendMessage(string $message, array $options = null, Carbon|string $internal_date = null): array {
332+
public function appendMessage(string $message, ?array $options = null, Carbon|string|null $internal_date = null): array {
333333
/**
334334
* Check if $internal_date is parsed. If it is null it should not be set. Otherwise, the message can't be stored.
335335
* If this parameter is set, it will set the INTERNALDATE on the appended message. The parameter should be a

src/Message.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class Message {
222222
* @throws RuntimeException
223223
* @throws ResponseException
224224
*/
225-
public function __construct(int $uid, ?int $msglist, Client $client, int $fetch_options = null, bool $fetch_body = false, bool $fetch_flags = false, int $sequence = null) {
225+
public function __construct(int $uid, ?int $msglist, Client $client, ?int $fetch_options = null, bool $fetch_body = false, bool $fetch_flags = false, ?int $sequence = null) {
226226
$this->boot($client->getConfig());
227227

228228
$default_mask = $client->getDefaultMessageMask();
@@ -329,7 +329,7 @@ public static function make(int $uid, ?int $msglist, Client $client, string $raw
329329
* @throws ResponseException
330330
* @throws RuntimeException
331331
*/
332-
public static function fromFile(string $filename, Config $config = null): Message {
332+
public static function fromFile(string $filename, ?Config $config = null): Message {
333333
$blob = file_get_contents($filename);
334334
if ($blob === false) {
335335
throw new RuntimeException("Unable to read file");
@@ -354,7 +354,7 @@ public static function fromFile(string $filename, Config $config = null): Messag
354354
* @throws ResponseException
355355
* @throws RuntimeException
356356
*/
357-
public static function fromString(string $blob, Config $config = null): Message {
357+
public static function fromString(string $blob, ?Config $config = null): Message {
358358
$reflection = new ReflectionClass(self::class);
359359
/** @var Message $instance */
360360
$instance = $reflection->newInstanceWithoutConstructor();
@@ -386,7 +386,7 @@ public static function fromString(string $blob, Config $config = null): Message
386386
* @param ?Config $config
387387
* @throws DecoderNotFoundException
388388
*/
389-
public function boot(Config $config = null): void {
389+
public function boot(?Config $config = null): void {
390390
$this->attributes = [];
391391
$this->client = null;
392392
$this->config = $config ?? Config::make();
@@ -903,7 +903,7 @@ public function getFolder(): ?Folder {
903903
* @throws RuntimeException
904904
* @throws ResponseException
905905
*/
906-
public function thread(Folder $sent_folder = null, MessageCollection &$thread = null, Folder $folder = null): MessageCollection {
906+
public function thread(?Folder $sent_folder = null, ?MessageCollection &$thread = null, ?Folder $folder = null): MessageCollection {
907907
$thread = $thread ?: MessageCollection::make();
908908
$folder = $folder ?: $this->getFolder();
909909
$sent_folder = $sent_folder ?: $this->client->getFolderByPath($this->config->get("options.common_folders.sent", "INBOX/Sent"));
@@ -1123,7 +1123,7 @@ protected function fetchNewMail(Folder $folder, int $next_uid, string $event, bo
11231123
* @throws RuntimeException
11241124
* @throws ResponseException
11251125
*/
1126-
public function delete(bool $expunge = true, string $trash_path = null, bool $force_move = false): bool {
1126+
public function delete(bool $expunge = true, ?string $trash_path = null, bool $force_move = false): bool {
11271127
$status = $this->setFlag("Deleted");
11281128
if ($force_move) {
11291129
$trash_path = $trash_path === null ? $this->config["common_folders"]["trash"] : $trash_path;
@@ -1398,7 +1398,7 @@ public function getStructure(): ?Structure {
13981398
* @param null|Message $message
13991399
* @return boolean
14001400
*/
1401-
public function is(Message $message = null): bool {
1401+
public function is(?Message $message = null): bool {
14021402
if (is_null($message)) {
14031403
return false;
14041404
}
@@ -1605,7 +1605,7 @@ public function setUid(int $uid): Message {
16051605
*
16061606
* @return Message
16071607
*/
1608-
public function setMsgn(int $msgn, int $msglist = null): Message {
1608+
public function setMsgn(int $msgn, ?int $msglist = null): Message {
16091609
$this->msgn = $msgn;
16101610
$this->msglist = $msglist;
16111611
$this->uid = null;
@@ -1636,7 +1636,7 @@ public function getSequenceId(): int {
16361636
* @param $uid
16371637
* @param int|null $msglist
16381638
*/
1639-
public function setSequenceId($uid, int $msglist = null): void {
1639+
public function setSequenceId($uid, ?int $msglist = null): void {
16401640
if ($this->getSequence() === IMAP::ST_UID) {
16411641
$this->setUid($uid);
16421642
$this->setMsglist($msglist);

src/Part.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Part {
153153
*
154154
* @throws InvalidMessageDateException
155155
*/
156-
public function __construct(string $raw_part, Config $config, Header $header = null, int $part_number = 0) {
156+
public function __construct(string $raw_part, Config $config, ?Header $header = null, int $part_number = 0) {
157157
$this->raw = $raw_part;
158158
$this->config = $config;
159159
$this->header = $header;

src/Query/WhereQuery.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ protected function push_search_criteria(string $criteria, mixed $value): void {
171171
*
172172
* @return $this
173173
*/
174-
public function orWhere(Closure $closure = null): static {
174+
public function orWhere(?Closure $closure = null): static {
175175
$this->query->push(['OR']);
176176
if ($closure !== null) $closure($this);
177177

@@ -183,7 +183,7 @@ public function orWhere(Closure $closure = null): static {
183183
*
184184
* @return $this
185185
*/
186-
public function andWhere(Closure $closure = null): static {
186+
public function andWhere(?Closure $closure = null): static {
187187
$this->query->push(['AND']);
188188
if ($closure !== null) $closure($this);
189189

0 commit comments

Comments
 (0)