Skip to content

Convert IMAPConnection to IMAP\Connection #6925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2021
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
12 changes: 6 additions & 6 deletions ext/imap/php_imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static zend_object* imap_object_create(zend_class_entry* ce) {
}

static zend_function *imap_object_get_constructor(zend_object *zobj) {
zend_throw_error(NULL, "Cannot directly construct IMAPConnection, use imap_open() instead");
zend_throw_error(NULL, "Cannot directly construct IMAP\\Connection, use imap_open() instead");
return NULL;
}

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

Expand Down Expand Up @@ -477,7 +477,7 @@ PHP_MINIT_FUNCTION(imap)
ssl_onceonlyinit ();
#endif

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

imap_conn_struct->imap_stream = mail_open(imap_conn_struct->imap_stream, ZSTR_VAL(mailbox), flags);
if (imap_conn_struct->imap_stream == NIL) {
/* IMAPConnection object will release it self. */
/* IMAP\Connection object will release it self. */
php_error_docref(NULL, E_WARNING, "Couldn't re-open stream");
RETURN_FALSE;
}
Expand Down
121 changes: 63 additions & 58 deletions ext/imap/php_imap.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,111 +2,115 @@

/** @generate-class-entries */

/** @strict-properties */
final class IMAPConnection {
namespace IMAP {
/** @strict-properties */
final class Connection {
}
}

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

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

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

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

function imap_num_recent(IMAPConnection $imap): int {}
function imap_num_msg(IMAP\Connection $imap): int|false {}

function imap_headers(IMAPConnection $imap): array|false {}
function imap_num_recent(IMAP\Connection $imap): int {}

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

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

function imap_rfc822_parse_headers(string $headers, string $default_hostname = "UNKNOWN"): \stdClass {}

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

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

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

/**
* @alias imap_body
*/
function imap_fetchtext(IMAPConnection $imap, int $message_num, int $flags = 0): string|false {}
function imap_fetchtext(IMAP\Connection $imap, int $message_num, int $flags = 0): string|false {}

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

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

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

/**
* @param resource|string|int $file
*/
function imap_savebody(IMAPConnection $imap, $file, int $message_num, string $section = "", int $flags = 0): bool {}
function imap_savebody(IMAP\Connection $imap, $file, int $message_num, string $section = "", int $flags = 0): bool {}

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

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

/**
*/
function imap_gc(IMAPConnection $imap, int $flags): bool {}
function imap_gc(IMAP\Connection $imap, int $flags): bool {}

/**
*/
function imap_expunge(IMAPConnection $imap): bool {}
function imap_expunge(IMAP\Connection $imap): bool {}

/**
*/
function imap_delete(IMAPConnection $imap, string $message_num, int $flags = 0): bool {}
function imap_delete(IMAP\Connection $imap, string $message_num, int $flags = 0): bool {}

/**
*/
function imap_undelete(IMAPConnection $imap, string $message_num, int $flags = 0): bool {}
function imap_undelete(IMAP\Connection $imap, string $message_num, int $flags = 0): bool {}

function imap_check(IMAPConnection $imap): stdClass|false {}
function imap_check(IMAP\Connection $imap): \stdClass|false {}

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

/**
* @alias imap_listscan
*/
function imap_scan(IMAPConnection $imap, string $reference, string $pattern, string $content): array|false {}
function imap_scan(IMAP\Connection $imap, string $reference, string $pattern, string $content): array|false {}

/**
* @alias imap_listscan
*/
function imap_scanmailbox(IMAPConnection $imap, string $reference, string $pattern, string $content): array|false {}
function imap_scanmailbox(IMAP\Connection $imap, string $reference, string $pattern, string $content): array|false {}

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

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

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

function imap_createmailbox(IMAPConnection $imap, string $mailbox): bool {}
function imap_createmailbox(IMAP\Connection $imap, string $mailbox): bool {}

/**
* @alias imap_createmailbox
*/
function imap_create(IMAPConnection $imap, string $mailbox): bool {}
function imap_create(IMAP\Connection $imap, string $mailbox): bool {}

function imap_renamemailbox(IMAPConnection $imap, string $from, string $to): bool {}
function imap_renamemailbox(IMAP\Connection $imap, string $from, string $to): bool {}

/**
* @alias imap_renamemailbox
*/
function imap_rename(IMAPConnection $imap, string $from, string $to): bool {}
function imap_rename(IMAP\Connection $imap, string $from, string $to): bool {}

function imap_deletemailbox(IMAPConnection $imap, string $mailbox): bool {}
function imap_deletemailbox(IMAP\Connection $imap, string $mailbox): bool {}

function imap_subscribe(IMAPConnection $imap, string $mailbox): bool {}
function imap_subscribe(IMAP\Connection $imap, string $mailbox): bool {}

function imap_unsubscribe(IMAPConnection $imap, string $mailbox): bool {}
function imap_unsubscribe(IMAP\Connection $imap, string $mailbox): bool {}

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

function imap_ping(IMAPConnection $imap): bool {}
function imap_ping(IMAP\Connection $imap): bool {}

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

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

function imap_utf8(string $mime_encoded_text): string {}

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

function imap_mailboxmsginfo(IMAPConnection $imap): stdClass {}
function imap_mailboxmsginfo(IMAP\Connection $imap): \stdClass {}

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

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

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

function imap_uid(IMAPConnection $imap, int $message_num): int|false {}
function imap_uid(IMAP\Connection $imap, int $message_num): int|false {}

function imap_msgno(IMAPConnection $imap, int $message_uid): int {}
function imap_msgno(IMAP\Connection $imap, int $message_uid): int {}

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

/**
* @alias imap_list
*/
function imap_listmailbox(IMAPConnection $imap, string $reference, string $pattern): array|false {}
function imap_listmailbox(IMAP\Connection $imap, string $reference, string $pattern): array|false {}

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

/**
* @alias imap_lsub
*/
function imap_listsubscribed(IMAPConnection $imap, string $reference, string $pattern): array|false {}
function imap_listsubscribed(IMAP\Connection $imap, string $reference, string $pattern): array|false {}

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

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

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

function imap_alerts(): array|false {}

function imap_errors(): array|false {}

function imap_last_error(): string|false {}

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

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

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

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

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

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

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

function imap_get_quotaroot(IMAPConnection $imap, string $mailbox): array|false {}
function imap_get_quotaroot(IMAP\Connection $imap, string $mailbox): array|false {}

function imap_set_quota(IMAPConnection $imap, string $quota_root, int $mailbox_size): bool {}
function imap_set_quota(IMAP\Connection $imap, string $quota_root, int $mailbox_size): bool {}

function imap_setacl(IMAPConnection $imap, string $mailbox, string $user_id, string $rights): bool {}
function imap_setacl(IMAP\Connection $imap, string $mailbox, string $user_id, string $rights): bool {}

function imap_getacl(IMAPConnection $imap, string $mailbox): array|false {}
function imap_getacl(IMAP\Connection $imap, string $mailbox): array|false {}
#endif

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