Skip to content

Commit b63564c

Browse files
committed
Use some proper null defaults in IMAP
1 parent e77e90d commit b63564c

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

ext/imap/php_imap.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ PHP_FUNCTION(imap_append)
866866
pils *imap_le_struct;
867867
STRING st;
868868

869-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rSS|SS", &streamind, &folder, &message, &flags, &internal_date) == FAILURE) {
869+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rSS|S!S!", &streamind, &folder, &message, &flags, &internal_date) == FAILURE) {
870870
RETURN_THROWS();
871871
}
872872

@@ -2647,7 +2647,7 @@ PHP_FUNCTION(imap_sort)
26472647
SEARCHPGM *spg=NIL;
26482648
int argc = ZEND_NUM_ARGS();
26492649

2650-
if (zend_parse_parameters(argc, "rll|lSS", &streamind, &pgm, &rev, &flags, &criteria, &charset) == FAILURE) {
2650+
if (zend_parse_parameters(argc, "rll|lS!S!", &streamind, &pgm, &rev, &flags, &criteria, &charset) == FAILURE) {
26512651
RETURN_THROWS();
26522652
}
26532653

@@ -2665,7 +2665,7 @@ PHP_FUNCTION(imap_sort)
26652665
RETURN_FALSE;
26662666
}
26672667
}
2668-
if (argc >= 5) {
2668+
if (criteria) {
26692669
search_criteria = estrndup(ZSTR_VAL(criteria), ZSTR_LEN(criteria));
26702670
spg = mail_criteria(search_criteria);
26712671
efree(search_criteria);
@@ -2678,7 +2678,7 @@ PHP_FUNCTION(imap_sort)
26782678
mypgm->function = (short) pgm;
26792679
mypgm->next = NIL;
26802680

2681-
slst = mail_sort(imap_le_struct->imap_stream, (argc == 6 ? ZSTR_VAL(charset) : NIL), spg, mypgm, (argc >= 4 ? flags : NIL));
2681+
slst = mail_sort(imap_le_struct->imap_stream, (charset ? ZSTR_VAL(charset) : NIL), spg, mypgm, (argc >= 4 ? flags : NIL));
26822682

26832683
if (spg && !(flags & SE_FREE)) {
26842684
mail_free_searchpgm(&spg);
@@ -3577,7 +3577,7 @@ PHP_FUNCTION(imap_mail)
35773577
zend_string *to=NULL, *message=NULL, *headers=NULL, *subject=NULL, *cc=NULL, *bcc=NULL, *rpath=NULL;
35783578
int argc = ZEND_NUM_ARGS();
35793579

3580-
if (zend_parse_parameters(argc, "PPP|PPPP", &to, &subject, &message,
3580+
if (zend_parse_parameters(argc, "PPP|P!P!P!P!", &to, &subject, &message,
35813581
&headers, &cc, &bcc, &rpath) == FAILURE) {
35823582
RETURN_THROWS();
35833583
}

ext/imap/php_imap.stub.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function imap_subscribe($stream_id, string $mailbox): bool {}
148148
function imap_unsubscribe($stream_id, string $mailbox): bool {}
149149

150150
/** @param resource $stream_id */
151-
function imap_append($stream_id, string $folder, string $message, string $options = UNKNOWN, string $internal_date = UNKNOWN): bool {}
151+
function imap_append($stream_id, string $folder, string $message, ?string $options = null, ?string $internal_date = null): bool {}
152152

153153
/** @param resource $stream_id */
154154
function imap_ping($stream_id): bool {}
@@ -180,7 +180,7 @@ function imap_setflag_full($stream_id, string $sequence, string $flag, int $opti
180180
function imap_clearflag_full($stream_id, string $sequence, string $flag, int $options = 0): bool {}
181181

182182
/** @param resource $stream_id */
183-
function imap_sort($stream_id, int $criteria, int $reverse, int $options = 0, string $search_criteria = UNKNOWN, string $charset = UNKNOWN): array|false {}
183+
function imap_sort($stream_id, int $criteria, int $reverse, int $options = 0, ?string $search_criteria = null, ?string $charset = null): array|false {}
184184

185185
/** @param resource $stream_id */
186186
function imap_uid($stream_id, int $msg_no): int|false {}
@@ -258,4 +258,4 @@ function imap_setacl($stream_id, string $mailbox, string $id, string $rights): b
258258
function imap_getacl($stream_id, string $mailbox): array|false {}
259259
#endif
260260

261-
function imap_mail(string $to, string $subject, string $message, string $additional_headers = UNKNOWN, string $cc = UNKNOWN, string $bcc = UNKNOWN, string $rpath = UNKNOWN): bool {}
261+
function imap_mail(string $to, string $subject, string $message, ?string $additional_headers = null, ?string $cc = null, ?string $bcc = null, ?string $rpath = null): bool {}

ext/imap/php_imap_arginfo.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 4991f82d78672ab23044864fa6dd75851952965c */
2+
* Stub hash: a1b1cb1bb36085cb43254b9d708585352d3cf72a */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_open, 0, 0, 3)
55
ZEND_ARG_TYPE_INFO(0, mailbox, IS_STRING, 0)
@@ -173,8 +173,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imap_append, 0, 3, _IS_BOOL, 0)
173173
ZEND_ARG_INFO(0, stream_id)
174174
ZEND_ARG_TYPE_INFO(0, folder, IS_STRING, 0)
175175
ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0)
176-
ZEND_ARG_TYPE_INFO(0, options, IS_STRING, 0)
177-
ZEND_ARG_TYPE_INFO(0, internal_date, IS_STRING, 0)
176+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_STRING, 1, "null")
177+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, internal_date, IS_STRING, 1, "null")
178178
ZEND_END_ARG_INFO()
179179

180180
#define arginfo_imap_ping arginfo_imap_expunge
@@ -217,8 +217,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imap_sort, 0, 3, MAY_BE_ARRAY|MA
217217
ZEND_ARG_TYPE_INFO(0, criteria, IS_LONG, 0)
218218
ZEND_ARG_TYPE_INFO(0, reverse, IS_LONG, 0)
219219
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0")
220-
ZEND_ARG_TYPE_INFO(0, search_criteria, IS_STRING, 0)
221-
ZEND_ARG_TYPE_INFO(0, charset, IS_STRING, 0)
220+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, search_criteria, IS_STRING, 1, "null")
221+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, charset, IS_STRING, 1, "null")
222222
ZEND_END_ARG_INFO()
223223

224224
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imap_uid, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
@@ -342,10 +342,10 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imap_mail, 0, 3, _IS_BOOL, 0)
342342
ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0)
343343
ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0)
344344
ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0)
345-
ZEND_ARG_TYPE_INFO(0, additional_headers, IS_STRING, 0)
346-
ZEND_ARG_TYPE_INFO(0, cc, IS_STRING, 0)
347-
ZEND_ARG_TYPE_INFO(0, bcc, IS_STRING, 0)
348-
ZEND_ARG_TYPE_INFO(0, rpath, IS_STRING, 0)
345+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, additional_headers, IS_STRING, 1, "null")
346+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cc, IS_STRING, 1, "null")
347+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bcc, IS_STRING, 1, "null")
348+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, rpath, IS_STRING, 1, "null")
349349
ZEND_END_ARG_INFO()
350350

351351

0 commit comments

Comments
 (0)