Skip to content

Commit 27d40da

Browse files
committed
Convert IMAPConnection to IMAP\Connection
1 parent f932d3d commit 27d40da

File tree

6 files changed

+115
-110
lines changed

6 files changed

+115
-110
lines changed

ext/imap/php_imap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static zend_object* imap_object_create(zend_class_entry* ce) {
171171
}
172172

173173
static zend_function *imap_object_get_constructor(zend_object *zobj) {
174-
zend_throw_error(NULL, "Cannot directly construct IMAPConnection, use imap_open() instead");
174+
zend_throw_error(NULL, "Cannot directly construct IMAP\\Connection, use imap_open() instead");
175175
return NULL;
176176
}
177177

@@ -198,7 +198,7 @@ static void imap_object_destroy(zend_object *zobj) {
198198
#define GET_IMAP_STREAM(imap_conn_struct, zval_imap_obj) \
199199
imap_conn_struct = imap_object_from_zend_object(Z_OBJ_P(zval_imap_obj)); \
200200
if (!imap_conn_struct) { \
201-
zend_throw_exception(zend_ce_value_error, "IMAPConnection is already closed", 0); \
201+
zend_throw_exception(zend_ce_value_error, "IMAP\\Connection is already closed", 0); \
202202
RETURN_THROWS(); \
203203
}
204204

@@ -477,7 +477,7 @@ PHP_MINIT_FUNCTION(imap)
477477
ssl_onceonlyinit ();
478478
#endif
479479

480-
php_imap_ce = register_class_IMAPConnection();
480+
php_imap_ce = register_class_IMAP_Connection();
481481
php_imap_ce->create_object = imap_object_create;
482482
php_imap_ce->serialize = zend_class_serialize_deny;
483483
php_imap_ce->unserialize = zend_class_unserialize_deny;
@@ -785,7 +785,7 @@ PHP_FUNCTION(imap_open)
785785
/* Check for PHP_EXPUNGE and not CL_EXPUNGE as the user land facing CL_EXPUNGE constant is defined
786786
* to something different to prevent clashes between CL_EXPUNGE and an OP_* constant allowing setting
787787
* the CL_EXPUNGE flag which will expunge when the mailbox is closed (be that manually, or via the
788-
* IMAPConnection object being destroyed naturally at the end of the PHP script */
788+
* IMAP\Connection object being destroyed naturally at the end of the PHP script */
789789
if (flags && ((flags & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | PHP_EXPUNGE | OP_DEBUG | OP_SHORTCACHE
790790
| OP_SILENT | OP_PROTOTYPE | OP_SECURE)) != 0)) {
791791
zend_argument_value_error(4, "must be a bitmask of the OP_* constants, and CL_EXPUNGE");
@@ -908,7 +908,7 @@ PHP_FUNCTION(imap_reopen)
908908
/* Check for PHP_EXPUNGE and not CL_EXPUNGE as the user land facing CL_EXPUNGE constant is defined
909909
* to something different to prevent clashes between CL_EXPUNGE and an OP_* constant allowing setting
910910
* the CL_EXPUNGE flag which will expunge when the mailbox is closed (be that manually, or via the
911-
* IMAPConnection object being destroyed naturally at the end of the PHP script */
911+
* IMAP\Connection object being destroyed naturally at the end of the PHP script */
912912
if (options && ((options & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | OP_EXPUNGE | PHP_EXPUNGE)) != 0)) {
913913
zend_argument_value_error(3, "must be a bitmask of OP_READONLY, OP_ANONYMOUS, OP_HALFOPEN, "
914914
"OP_EXPUNGE, and CL_EXPUNGE");
@@ -940,7 +940,7 @@ PHP_FUNCTION(imap_reopen)
940940

941941
imap_conn_struct->imap_stream = mail_open(imap_conn_struct->imap_stream, ZSTR_VAL(mailbox), flags);
942942
if (imap_conn_struct->imap_stream == NIL) {
943-
/* IMAPConnection object will release it self. */
943+
/* IMAP\Connection object will release it self. */
944944
php_error_docref(NULL, E_WARNING, "Couldn't re-open stream");
945945
RETURN_FALSE;
946946
}

ext/imap/php_imap.stub.php

Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,111 +2,115 @@
22

33
/** @generate-class-entries */
44

5-
/** @strict-properties */
6-
final class IMAPConnection {
5+
namespace IMAP {
6+
/** @strict-properties */
7+
final class Connection {
8+
}
79
}
810

9-
function imap_open(string $mailbox, string $user, string $password, int $flags = 0, int $retries = 0, array $options = []): IMAPConnection|false {}
11+
namespace {
1012

11-
function imap_reopen(IMAPConnection $imap, string $mailbox, int $flags = 0, int $retries = 0): bool {}
13+
function imap_open(string $mailbox, string $user, string $password, int $flags = 0, int $retries = 0, array $options = []): IMAP\Connection|false {}
1214

13-
function imap_close(IMAPConnection $imap, int $flags = 0): bool {}
15+
function imap_reopen(IMAP\Connection $imap, string $mailbox, int $flags = 0, int $retries = 0): bool {}
1416

15-
function imap_num_msg(IMAPConnection $imap): int|false {}
17+
function imap_close(IMAP\Connection $imap, int $flags = 0): bool {}
1618

17-
function imap_num_recent(IMAPConnection $imap): int {}
19+
function imap_num_msg(IMAP\Connection $imap): int|false {}
1820

19-
function imap_headers(IMAPConnection $imap): array|false {}
21+
function imap_num_recent(IMAP\Connection $imap): int {}
2022

21-
function imap_headerinfo(IMAPConnection $imap, int $message_num, int $from_length = 0, int $subject_length = 0): stdClass|false {}
23+
function imap_headers(IMAP\Connection $imap): array|false {}
2224

23-
function imap_rfc822_parse_headers(string $headers, string $default_hostname = "UNKNOWN"): stdClass {}
25+
function imap_headerinfo(IMAP\Connection $imap, int $message_num, int $from_length = 0, int $subject_length = 0): \stdClass|false {}
26+
27+
function imap_rfc822_parse_headers(string $headers, string $default_hostname = "UNKNOWN"): \stdClass {}
2428

2529
function imap_rfc822_write_address(string $mailbox, string $hostname, string $personal): string|false {}
2630

2731
function imap_rfc822_parse_adrlist(string $string, string $default_hostname): array {}
2832

29-
function imap_body(IMAPConnection $imap, int $message_num, int $flags = 0): string|false {}
33+
function imap_body(IMAP\Connection $imap, int $message_num, int $flags = 0): string|false {}
3034

3135
/**
3236
* @alias imap_body
3337
*/
34-
function imap_fetchtext(IMAPConnection $imap, int $message_num, int $flags = 0): string|false {}
38+
function imap_fetchtext(IMAP\Connection $imap, int $message_num, int $flags = 0): string|false {}
3539

36-
function imap_bodystruct(IMAPConnection $imap, int $message_num, string $section): stdClass|false {}
40+
function imap_bodystruct(IMAP\Connection $imap, int $message_num, string $section): \stdClass|false {}
3741

38-
function imap_fetchbody(IMAPConnection $imap, int $message_num, string $section, int $flags = 0): string|false {}
42+
function imap_fetchbody(IMAP\Connection $imap, int $message_num, string $section, int $flags = 0): string|false {}
3943

40-
function imap_fetchmime(IMAPConnection $imap, int $message_num, string $section, int $flags = 0): string|false {}
44+
function imap_fetchmime(IMAP\Connection $imap, int $message_num, string $section, int $flags = 0): string|false {}
4145

4246
/**
4347
* @param resource|string|int $file
4448
*/
45-
function imap_savebody(IMAPConnection $imap, $file, int $message_num, string $section = "", int $flags = 0): bool {}
49+
function imap_savebody(IMAP\Connection $imap, $file, int $message_num, string $section = "", int $flags = 0): bool {}
4650

47-
function imap_fetchheader(IMAPConnection $imap, int $message_num, int $flags = 0): string|false {}
51+
function imap_fetchheader(IMAP\Connection $imap, int $message_num, int $flags = 0): string|false {}
4852

49-
function imap_fetchstructure(IMAPConnection $imap, int $message_num, int $flags = 0): stdClass|false {}
53+
function imap_fetchstructure(IMAP\Connection $imap, int $message_num, int $flags = 0): \stdClass|false {}
5054

5155
/**
5256
*/
53-
function imap_gc(IMAPConnection $imap, int $flags): bool {}
57+
function imap_gc(IMAP\Connection $imap, int $flags): bool {}
5458

5559
/**
5660
*/
57-
function imap_expunge(IMAPConnection $imap): bool {}
61+
function imap_expunge(IMAP\Connection $imap): bool {}
5862

5963
/**
6064
*/
61-
function imap_delete(IMAPConnection $imap, string $message_num, int $flags = 0): bool {}
65+
function imap_delete(IMAP\Connection $imap, string $message_num, int $flags = 0): bool {}
6266

6367
/**
6468
*/
65-
function imap_undelete(IMAPConnection $imap, string $message_num, int $flags = 0): bool {}
69+
function imap_undelete(IMAP\Connection $imap, string $message_num, int $flags = 0): bool {}
6670

67-
function imap_check(IMAPConnection $imap): stdClass|false {}
71+
function imap_check(IMAP\Connection $imap): \stdClass|false {}
6872

69-
function imap_listscan(IMAPConnection $imap, string $reference, string $pattern, string $content): array|false {}
73+
function imap_listscan(IMAP\Connection $imap, string $reference, string $pattern, string $content): array|false {}
7074

7175
/**
7276
* @alias imap_listscan
7377
*/
74-
function imap_scan(IMAPConnection $imap, string $reference, string $pattern, string $content): array|false {}
78+
function imap_scan(IMAP\Connection $imap, string $reference, string $pattern, string $content): array|false {}
7579

7680
/**
7781
* @alias imap_listscan
7882
*/
79-
function imap_scanmailbox(IMAPConnection $imap, string $reference, string $pattern, string $content): array|false {}
83+
function imap_scanmailbox(IMAP\Connection $imap, string $reference, string $pattern, string $content): array|false {}
8084

81-
function imap_mail_copy(IMAPConnection $imap, string $message_nums, string $mailbox, int $flags = 0): bool {}
85+
function imap_mail_copy(IMAP\Connection $imap, string $message_nums, string $mailbox, int $flags = 0): bool {}
8286

83-
function imap_mail_move(IMAPConnection $imap, string $message_nums, string $mailbox, int $flags = 0): bool {}
87+
function imap_mail_move(IMAP\Connection $imap, string $message_nums, string $mailbox, int $flags = 0): bool {}
8488

8589
function imap_mail_compose(array $envelope, array $bodies): string|false {}
8690

87-
function imap_createmailbox(IMAPConnection $imap, string $mailbox): bool {}
91+
function imap_createmailbox(IMAP\Connection $imap, string $mailbox): bool {}
8892

8993
/**
9094
* @alias imap_createmailbox
9195
*/
92-
function imap_create(IMAPConnection $imap, string $mailbox): bool {}
96+
function imap_create(IMAP\Connection $imap, string $mailbox): bool {}
9397

94-
function imap_renamemailbox(IMAPConnection $imap, string $from, string $to): bool {}
98+
function imap_renamemailbox(IMAP\Connection $imap, string $from, string $to): bool {}
9599

96100
/**
97101
* @alias imap_renamemailbox
98102
*/
99-
function imap_rename(IMAPConnection $imap, string $from, string $to): bool {}
103+
function imap_rename(IMAP\Connection $imap, string $from, string $to): bool {}
100104

101-
function imap_deletemailbox(IMAPConnection $imap, string $mailbox): bool {}
105+
function imap_deletemailbox(IMAP\Connection $imap, string $mailbox): bool {}
102106

103-
function imap_subscribe(IMAPConnection $imap, string $mailbox): bool {}
107+
function imap_subscribe(IMAP\Connection $imap, string $mailbox): bool {}
104108

105-
function imap_unsubscribe(IMAPConnection $imap, string $mailbox): bool {}
109+
function imap_unsubscribe(IMAP\Connection $imap, string $mailbox): bool {}
106110

107-
function imap_append(IMAPConnection $imap, string $folder, string $message, ?string $options = null, ?string $internal_date = null): bool {}
111+
function imap_append(IMAP\Connection $imap, string $folder, string $message, ?string $options = null, ?string $internal_date = null): bool {}
108112

109-
function imap_ping(IMAPConnection $imap): bool {}
113+
function imap_ping(IMAP\Connection $imap): bool {}
110114

111115
function imap_base64(string $string): string|false {}
112116

@@ -118,47 +122,47 @@ function imap_binary(string $string): string|false {}
118122

119123
function imap_utf8(string $mime_encoded_text): string {}
120124

121-
function imap_status(IMAPConnection $imap, string $mailbox, int $flags): stdClass|false {}
125+
function imap_status(IMAP\Connection $imap, string $mailbox, int $flags): \stdClass|false {}
122126

123-
function imap_mailboxmsginfo(IMAPConnection $imap): stdClass {}
127+
function imap_mailboxmsginfo(IMAP\Connection $imap): \stdClass {}
124128

125-
function imap_setflag_full(IMAPConnection $imap, string $sequence, string $flag, int $options = 0): bool {}
129+
function imap_setflag_full(IMAP\Connection $imap, string $sequence, string $flag, int $options = 0): bool {}
126130

127-
function imap_clearflag_full(IMAPConnection $imap, string $sequence, string $flag, int $options = 0): bool {}
131+
function imap_clearflag_full(IMAP\Connection $imap, string $sequence, string $flag, int $options = 0): bool {}
128132

129-
function imap_sort(IMAPConnection $imap, int $criteria, bool $reverse, int $flags = 0, ?string $search_criteria = null, ?string $charset = null): array|false {}
133+
function imap_sort(IMAP\Connection $imap, int $criteria, bool $reverse, int $flags = 0, ?string $search_criteria = null, ?string $charset = null): array|false {}
130134

131-
function imap_uid(IMAPConnection $imap, int $message_num): int|false {}
135+
function imap_uid(IMAP\Connection $imap, int $message_num): int|false {}
132136

133-
function imap_msgno(IMAPConnection $imap, int $message_uid): int {}
137+
function imap_msgno(IMAP\Connection $imap, int $message_uid): int {}
134138

135-
function imap_list(IMAPConnection $imap, string $reference, string $pattern): array|false {}
139+
function imap_list(IMAP\Connection $imap, string $reference, string $pattern): array|false {}
136140

137141
/**
138142
* @alias imap_list
139143
*/
140-
function imap_listmailbox(IMAPConnection $imap, string $reference, string $pattern): array|false {}
144+
function imap_listmailbox(IMAP\Connection $imap, string $reference, string $pattern): array|false {}
141145

142-
function imap_lsub(IMAPConnection $imap, string $reference, string $pattern): array|false {}
146+
function imap_lsub(IMAP\Connection $imap, string $reference, string $pattern): array|false {}
143147

144148
/**
145149
* @alias imap_lsub
146150
*/
147-
function imap_listsubscribed(IMAPConnection $imap, string $reference, string $pattern): array|false {}
151+
function imap_listsubscribed(IMAP\Connection $imap, string $reference, string $pattern): array|false {}
148152

149-
function imap_getsubscribed(IMAPConnection $imap, string $reference, string $pattern): array|false {}
153+
function imap_getsubscribed(IMAP\Connection $imap, string $reference, string $pattern): array|false {}
150154

151-
function imap_getmailboxes(IMAPConnection $imap, string $reference, string $pattern): array|false {}
155+
function imap_getmailboxes(IMAP\Connection $imap, string $reference, string $pattern): array|false {}
152156

153-
function imap_fetch_overview(IMAPConnection $imap, string $sequence, int $flags = 0): array|false {}
157+
function imap_fetch_overview(IMAP\Connection $imap, string $sequence, int $flags = 0): array|false {}
154158

155159
function imap_alerts(): array|false {}
156160

157161
function imap_errors(): array|false {}
158162

159163
function imap_last_error(): string|false {}
160164

161-
function imap_search(IMAPConnection $imap, string $criteria, int $flags = SE_FREE, string $charset = ""): array|false {}
165+
function imap_search(IMAP\Connection $imap, string $criteria, int $flags = SE_FREE, string $charset = ""): array|false {}
162166

163167
function imap_utf7_decode(string $string): string|false {}
164168

@@ -172,20 +176,21 @@ function imap_mutf7_to_utf8(string $string): string|false {}
172176

173177
function imap_mime_header_decode(string $string): array|false {}
174178

175-
function imap_thread(IMAPConnection $imap, int $flags = SE_FREE): array|false {}
179+
function imap_thread(IMAP\Connection $imap, int $flags = SE_FREE): array|false {}
176180

177181
function imap_timeout(int $timeout_type, int $timeout = -1): int|bool {}
178182

179183
#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
180-
function imap_get_quota(IMAPConnection $imap, string $quota_root): array|false {}
184+
function imap_get_quota(IMAP\Connection $imap, string $quota_root): array|false {}
181185

182-
function imap_get_quotaroot(IMAPConnection $imap, string $mailbox): array|false {}
186+
function imap_get_quotaroot(IMAP\Connection $imap, string $mailbox): array|false {}
183187

184-
function imap_set_quota(IMAPConnection $imap, string $quota_root, int $mailbox_size): bool {}
188+
function imap_set_quota(IMAP\Connection $imap, string $quota_root, int $mailbox_size): bool {}
185189

186-
function imap_setacl(IMAPConnection $imap, string $mailbox, string $user_id, string $rights): bool {}
190+
function imap_setacl(IMAP\Connection $imap, string $mailbox, string $user_id, string $rights): bool {}
187191

188-
function imap_getacl(IMAPConnection $imap, string $mailbox): array|false {}
192+
function imap_getacl(IMAP\Connection $imap, string $mailbox): array|false {}
189193
#endif
190194

191195
function imap_mail(string $to, string $subject, string $message, ?string $additional_headers = null, ?string $cc = null, ?string $bcc = null, ?string $return_path = null): bool {}
196+
}

0 commit comments

Comments
 (0)