summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMáté Kocsis <kocsismate@woohoolabs.com>2021-03-13 12:11:40 +0100
committerMáté Kocsis <kocsismate@woohoolabs.com>2021-03-21 10:43:25 +0100
commitcd40fc3cb1892197a462e013f930859a5d8064b3 (patch)
tree49054b820043ae0aa7bea5b79131bcf2ba2a0886
parent6690547a58f07778e795e857e574159fe8fb3650 (diff)
downloadphp-git-cd40fc3cb1892197a462e013f930859a5d8064b3.tar.gz
Convert resources to objects in ext/ldap
Closes GH-6770
-rw-r--r--NEWS5
-rw-r--r--UPGRADING11
-rw-r--r--ext/ldap/ldap.c664
-rw-r--r--ext/ldap/ldap.stub.php271
-rw-r--r--ext/ldap/ldap_arginfo.h174
-rw-r--r--ext/ldap/tests/bug48441.phpt9
-rw-r--r--ext/ldap/tests/bug73933.phpt1
-rw-r--r--ext/ldap/tests/bug77958.phpt3
-rw-r--r--ext/ldap/tests/ldap_add_ext.phpt3
-rw-r--r--ext/ldap/tests/ldap_bind_ext.phpt12
-rw-r--r--ext/ldap/tests/ldap_connect_basic.phpt3
-rw-r--r--ext/ldap/tests/ldap_connect_variation.phpt15
-rw-r--r--ext/ldap/tests/ldap_controls.phpt15
-rw-r--r--ext/ldap/tests/ldap_delete_ext.phpt3
-rw-r--r--ext/ldap/tests/ldap_exop.phpt8
-rw-r--r--ext/ldap/tests/ldap_exop_passwd.phpt1
-rw-r--r--ext/ldap/tests/ldap_exop_whoami.phpt1
-rw-r--r--ext/ldap/tests/ldap_first_attribute_error.phpt2
-rw-r--r--ext/ldap/tests/ldap_first_entry_basic.phpt3
-rw-r--r--ext/ldap/tests/ldap_first_reference_basic.phpt3
-rw-r--r--ext/ldap/tests/ldap_get_option_controls.phpt3
-rw-r--r--ext/ldap/tests/ldap_list_basic.phpt3
-rw-r--r--ext/ldap/tests/ldap_mod_ext.phpt6
-rw-r--r--ext/ldap/tests/ldap_next_entry_basic.phpt3
-rw-r--r--ext/ldap/tests/ldap_next_reference_basic.phpt3
-rw-r--r--ext/ldap/tests/ldap_parse_result_controls.phpt3
-rw-r--r--ext/ldap/tests/ldap_read_basic.phpt3
-rw-r--r--ext/ldap/tests/ldap_rename_ext.phpt3
-rw-r--r--ext/ldap/tests/ldap_search_basic.phpt3
-rw-r--r--ext/ldap/tests/ldap_search_error.phpt4
-rw-r--r--ext/ldap/tests/ldap_search_overrides.phpt3
-rw-r--r--ext/ldap/tests/ldap_search_paged_result_controls.phpt6
-rw-r--r--ext/ldap/tests/ldap_search_sort_controls.phpt6
-rw-r--r--ext/ldap/tests/ldap_search_variation1.phpt3
-rw-r--r--ext/ldap/tests/ldap_search_variation2.phpt3
-rw-r--r--ext/ldap/tests/ldap_search_variation3.phpt6
-rw-r--r--ext/ldap/tests/ldap_search_variation4.phpt3
-rw-r--r--ext/ldap/tests/ldap_search_variation5.phpt9
-rw-r--r--ext/ldap/tests/ldap_search_variation6.phpt18
39 files changed, 707 insertions, 591 deletions
diff --git a/NEWS b/NEWS
index 4ceee93fcd..32f3b6a088 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,11 @@ PHP NEWS
. Implemented FR #68109 (Add MurmurHash V3). (Anatol, Michael)
. Implemented FR #73385 (Add xxHash support). (Anatol)
+- LDAP:
+ . Convert resource<ldap link> to object \LDAP. (Máté)
+ . Convert resource<ldap result> to object \LDAPResult. (Máté)
+ . Convert resource<ldap result entry> to object \LDAPResultEntry. (Máté)
+
- MySQLi:
. Fixed bug #70372 (Emulate mysqli_fetch_all() for libmysqlclient). (Nikita)
. Fixed bug #80330 (Replace language in APIs and source code/docs).
diff --git a/UPGRADING b/UPGRADING
index 286735a4e8..97b99a380b 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -68,6 +68,17 @@ PHP 8.1 UPGRADE NOTES
. The IMAP functions now accept and return, respectively, IMAPConnection objects
instead of resources.
+- LDAP:
+ . The LDAP functions now accept and return, respectively, LDAP objects
+ instead of "ldap link" resources. Return value checks using is_resource()
+ should be replaced with checks for `false`.
+ . The LDAP functions now accept and return, respectively, LDAPResult objects
+ instead of "ldap result" resources. Return value checks using is_resource()
+ should be replaced with checks for `false`.
+ . The LDAP functions now accept and return, respectively, LDAPResultEntry
+ objects instead of "ldap result entry" resources. Return value checks using
+ is_resource() should be replaced with checks for `false`.
+
- MySQLi:
. mysqli_fetch_fields() and mysqli_fetch_field_direct() will now always return
zero for max_length. You can compute this information by iterating over the
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index d0fc58f658..5108d68b4e 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -34,6 +34,7 @@
#include "ext/standard/dl.h"
#include "php_ldap.h"
#include "ldap_arginfo.h"
+#include "Zend/zend_interfaces.h"
#ifdef PHP_WIN32
#include <string.h>
@@ -75,18 +76,26 @@ typedef struct {
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
zval rebindproc;
#endif
+ zend_object std;
} ldap_linkdata;
typedef struct {
+ LDAPMessage *result;
+ zend_object std;
+} ldap_resultdata;
+
+typedef struct {
LDAPMessage *data;
BerElement *ber;
zval res;
-} ldap_resultentry;
+ zend_object std;
+} ldap_result_entry;
ZEND_DECLARE_MODULE_GLOBALS(ldap)
static PHP_GINIT_FUNCTION(ldap);
-static int le_link, le_result, le_result_entry;
+static zend_class_entry *ldap_link_ce, *ldap_result_ce, *ldap_result_entry_ce;
+static zend_object_handlers ldap_link_object_handlers, ldap_result_object_handlers, ldap_result_entry_object_handlers;
#ifdef COMPILE_DL_LDAP
#ifdef ZTS
@@ -95,42 +104,139 @@ ZEND_TSRMLS_CACHE_DEFINE()
ZEND_GET_MODULE(ldap)
#endif
-static void _close_ldap_link(zend_resource *rsrc) /* {{{ */
-{
- ldap_linkdata *ld = (ldap_linkdata *)rsrc->ptr;
+static inline ldap_linkdata *ldap_link_from_obj(zend_object *obj) {
+ return (ldap_linkdata *)((char *)(obj) - XtOffsetOf(ldap_linkdata, std));
+}
+
+#define Z_LDAP_LINK_P(zv) ldap_link_from_obj(Z_OBJ_P(zv))
+
+static zend_object *ldap_link_create_object(zend_class_entry *class_type) {
+ ldap_linkdata *intern = zend_object_alloc(sizeof(ldap_linkdata), class_type);
+
+ zend_object_std_init(&intern->std, class_type);
+ object_properties_init(&intern->std, class_type);
+ intern->std.handlers = &ldap_link_object_handlers;
+
+ return &intern->std;
+}
+
+static zend_function *ldap_link_get_constructor(zend_object *object) {
+ zend_throw_error(NULL, "Cannot directly construct LDAP, use ldap_create() instead");
+ return NULL;
+}
+static void ldap_link_free(ldap_linkdata *ld)
+{
/* We use ldap_destroy rather than ldap_unbind here, because ldap_unbind
* will skip the destructor entirely if a critical client control is set. */
ldap_destroy(ld->link);
+ ld->link = NULL;
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
zval_ptr_dtor(&ld->rebindproc);
#endif
- efree(ld);
LDAPG(num_links)--;
}
-/* }}} */
-static void _free_ldap_result(zend_resource *rsrc) /* {{{ */
+static void ldap_link_free_obj(zend_object *obj)
{
- LDAPMessage *result = (LDAPMessage *)rsrc->ptr;
- ldap_msgfree(result);
+ ldap_linkdata *ld = ldap_link_from_obj(obj);
+
+ if (ld->link) {
+ ldap_link_free(ld);
+ }
+
+ zend_object_std_dtor(&ld->std);
}
-/* }}} */
-static void _free_ldap_result_entry(zend_resource *rsrc) /* {{{ */
+static inline ldap_resultdata *ldap_result_from_obj(zend_object *obj) {
+ return (ldap_resultdata *)((char *)(obj) - XtOffsetOf(ldap_resultdata, std));
+}
+
+#define Z_LDAP_RESULT_P(zv) ldap_result_from_obj(Z_OBJ_P(zv))
+
+static zend_object *ldap_result_create_object(zend_class_entry *class_type) {
+ ldap_resultdata *intern = zend_object_alloc(sizeof(ldap_resultdata), class_type);
+
+ zend_object_std_init(&intern->std, class_type);
+ object_properties_init(&intern->std, class_type);
+ intern->std.handlers = &ldap_result_object_handlers;
+
+ return &intern->std;
+}
+
+static zend_function *ldap_result_get_constructor(zend_object *object) {
+ zend_throw_error(NULL, "Cannot directly construct LDAPResult, use the dedicated functions instead");
+ return NULL;
+}
+
+static void ldap_result_free(ldap_resultdata *result)
{
- ldap_resultentry *entry = (ldap_resultentry *)rsrc->ptr;
+ ldap_msgfree(result->result);
+ result->result = NULL;
+}
+
+static void ldap_result_free_obj(zend_object *obj)
+{
+ ldap_resultdata *result = ldap_result_from_obj(obj);
+
+ if (result->result) {
+ ldap_result_free(result);
+ }
+
+ zend_object_std_dtor(&result->std);
+}
+
+static inline ldap_result_entry *ldap_result_entry_from_obj(zend_object *obj) {
+ return (ldap_result_entry *)((char *)(obj) - XtOffsetOf(ldap_result_entry, std));
+}
+
+#define Z_LDAP_RESULT_ENTRY_P(zv) ldap_result_entry_from_obj(Z_OBJ_P(zv))
+
+static zend_object *ldap_result_entry_create_object(zend_class_entry *class_type) {
+ ldap_result_entry *intern = zend_object_alloc(sizeof(ldap_result_entry), class_type);
+
+ zend_object_std_init(&intern->std, class_type);
+ object_properties_init(&intern->std, class_type);
+ intern->std.handlers = &ldap_result_entry_object_handlers;
+
+ return &intern->std;
+}
+
+static zend_function *ldap_result_entry_get_constructor(zend_object *obj) {
+ zend_throw_error(NULL, "Cannot directly construct LDAPResultEntry, use the dedicated functions instead");
+ return NULL;
+}
+
+static void ldap_result_entry_free_obj(zend_object *obj)
+{
+ ldap_result_entry *entry = ldap_result_entry_from_obj(obj);
if (entry->ber != NULL) {
ber_free(entry->ber, 0);
entry->ber = NULL;
}
zval_ptr_dtor(&entry->res);
- efree(entry);
+
+ zend_object_std_dtor(&entry->std);
+}
+
+#define VERIFY_LDAP_LINK_CONNECTED(ld) \
+{ \
+ if (!ld->link) { \
+ zend_throw_error(NULL, "LDAP connection has already been closed"); \
+ RETURN_THROWS(); \
+ } \
+}
+
+#define VERIFY_LDAP_RESULT_OPEN(lr) \
+{ \
+ if (!lr->result) { \
+ zend_throw_error(NULL, "LDAP result has already been closed"); \
+ RETURN_THROWS(); \
+ } \
}
-/* }}} */
/* {{{ Parse controls from and to arrays */
static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, int request)
@@ -720,6 +826,42 @@ PHP_MINIT_FUNCTION(ldap)
{
REGISTER_INI_ENTRIES();
+ ldap_link_ce = register_class_LDAP();
+ ldap_link_ce->create_object = ldap_link_create_object;
+ ldap_link_ce->serialize = zend_class_serialize_deny;
+ ldap_link_ce->unserialize = zend_class_unserialize_deny;
+
+ memcpy(&ldap_link_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
+ ldap_link_object_handlers.offset = XtOffsetOf(ldap_linkdata, std);
+ ldap_link_object_handlers.free_obj = ldap_link_free_obj;
+ ldap_link_object_handlers.get_constructor = ldap_link_get_constructor;
+ ldap_link_object_handlers.clone_obj = NULL;
+ ldap_link_object_handlers.compare = zend_objects_not_comparable;
+
+ ldap_result_ce = register_class_LDAPResult();
+ ldap_result_ce->create_object = ldap_result_create_object;
+ ldap_result_ce->serialize = zend_class_serialize_deny;
+ ldap_result_ce->unserialize = zend_class_unserialize_deny;
+
+ memcpy(&ldap_result_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
+ ldap_result_object_handlers.offset = XtOffsetOf(ldap_resultdata, std);
+ ldap_result_object_handlers.free_obj = ldap_result_free_obj;
+ ldap_result_object_handlers.get_constructor = ldap_result_get_constructor;
+ ldap_result_object_handlers.clone_obj = NULL;
+ ldap_result_object_handlers.compare = zend_objects_not_comparable;
+
+ ldap_result_entry_ce = register_class_LDAPResultEntry();
+ ldap_result_entry_ce->create_object = ldap_result_entry_create_object;
+ ldap_result_entry_ce->serialize = zend_class_serialize_deny;
+ ldap_result_entry_ce->unserialize = zend_class_unserialize_deny;
+
+ memcpy(&ldap_result_entry_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
+ ldap_result_entry_object_handlers.offset = XtOffsetOf(ldap_result_entry, std);
+ ldap_result_entry_object_handlers.free_obj = ldap_result_entry_free_obj;
+ ldap_result_entry_object_handlers.get_constructor = ldap_result_entry_get_constructor;
+ ldap_result_entry_object_handlers.clone_obj = NULL;
+ ldap_result_entry_object_handlers.compare = zend_objects_not_comparable;
+
/* Constants to be used with deref-parameter in php_ldap_do_search() */
REGISTER_LONG_CONSTANT("LDAP_DEREF_NEVER", LDAP_DEREF_NEVER, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LDAP_DEREF_SEARCHING", LDAP_DEREF_SEARCHING, CONST_PERSISTENT | CONST_CS);
@@ -925,10 +1067,6 @@ PHP_MINIT_FUNCTION(ldap)
REGISTER_STRING_CONSTANT("LDAP_CONTROL_VLVRESPONSE", LDAP_CONTROL_VLVRESPONSE, CONST_PERSISTENT | CONST_CS);
#endif
- le_link = zend_register_list_destructors_ex(_close_ldap_link, NULL, "ldap link", module_number);
- le_result = zend_register_list_destructors_ex(_free_ldap_result, NULL, "ldap result", module_number);
- le_result_entry = zend_register_list_destructors_ex(_free_ldap_result_entry, NULL, "ldap result entry", module_number);
-
ldap_module_entry.type = type;
return SUCCESS;
@@ -1019,7 +1157,8 @@ PHP_FUNCTION(ldap_connect)
RETURN_FALSE;
}
- ld = ecalloc(1, sizeof(ldap_linkdata));
+ object_init_ex(return_value, ldap_link_ce);
+ ld = Z_LDAP_LINK_P(return_value);
{
int rc = LDAP_SUCCESS;
@@ -1028,7 +1167,6 @@ PHP_FUNCTION(ldap_connect)
size_t urllen = hostlen + sizeof( "ldap://:65535" );
if (port <= 0 || port > 65535) {
- efree(ld);
zend_argument_value_error(2, "must be between 1 and 65535");
RETURN_THROWS();
}
@@ -1047,7 +1185,7 @@ PHP_FUNCTION(ldap_connect)
*/
ldap = ldap_init(host, port);
if (ldap == NULL) {
- efree(ld);
+ zval_ptr_dtor(return_value);
php_error_docref(NULL, E_WARNING, "Could not create session handle");
RETURN_FALSE;
}
@@ -1056,20 +1194,20 @@ PHP_FUNCTION(ldap_connect)
efree(url);
}
if (rc != LDAP_SUCCESS) {
- efree(ld);
+ zval_ptr_dtor(return_value);
php_error_docref(NULL, E_WARNING, "Could not create session handle: %s", ldap_err2string(rc));
RETURN_FALSE;
}
}
if (ldap == NULL) {
- efree(ld);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
} else {
#ifdef HAVE_ORALDAP
if (ssl) {
if (ldap_init_SSL(&ldap->ld_sb, wallet, walletpasswd, authmode)) {
- efree(ld);
+ zval_ptr_dtor(return_value);
php_error_docref(NULL, E_WARNING, "SSL init failed");
RETURN_FALSE;
}
@@ -1077,7 +1215,6 @@ PHP_FUNCTION(ldap_connect)
#endif
LDAPG(num_links)++;
ld->link = ldap;
- RETURN_RES(zend_register_resource(ld, le_link));
}
}
@@ -1119,13 +1256,12 @@ PHP_FUNCTION(ldap_bind)
ldap_linkdata *ld;
int rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!", &link, &ldap_bind_dn, &ldap_bind_dnlen, &ldap_bind_pw, &ldap_bind_pwlen) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!s!", &link, ldap_link_ce, &ldap_bind_dn, &ldap_bind_dnlen, &ldap_bind_pw, &ldap_bind_pwlen) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
if (ldap_bind_dn != NULL && memchr(ldap_bind_dn, '\0', ldap_bind_dnlen) != NULL) {
_set_lderrno(ld->link, LDAP_INVALID_CREDENTIALS);
@@ -1172,16 +1308,16 @@ PHP_FUNCTION(ldap_bind_ext)
size_t ldap_bind_dnlen, ldap_bind_pwlen;
ldap_linkdata *ld;
LDAPControl **lserverctrls = NULL;
+ ldap_resultdata *result;
LDAPMessage *ldap_res;
int rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!a!", &link, &ldap_bind_dn, &ldap_bind_dnlen, &ldap_bind_pw, &ldap_bind_pwlen, &serverctrls) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!s!a!", &link, ldap_link_ce, &ldap_bind_dn, &ldap_bind_dnlen, &ldap_bind_pw, &ldap_bind_pwlen, &serverctrls) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
if (ldap_bind_dn != NULL && memchr(ldap_bind_dn, '\0', ldap_bind_dnlen) != NULL) {
_set_lderrno(ld->link, LDAP_INVALID_CREDENTIALS);
@@ -1227,7 +1363,9 @@ PHP_FUNCTION(ldap_bind_ext)
}
/* return a PHP control object */
- RETVAL_RES(zend_register_resource(ldap_res, le_result));
+ object_init_ex(return_value, ldap_result_ce);
+ result = Z_LDAP_RESULT_P(return_value);
+ result->result = ldap_res;
}
cleanup:
@@ -1337,13 +1475,12 @@ PHP_FUNCTION(ldap_sasl_bind)
size_t rc, dn_len, passwd_len, mech_len, realm_len, authc_id_len, authz_id_len, props_len;
php_ldap_bictx *ctx;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!s!s!s!s!", &link, &binddn, &dn_len, &passwd, &passwd_len, &sasl_mech, &mech_len, &sasl_realm, &realm_len, &sasl_authc_id, &authc_id_len, &sasl_authz_id, &authz_id_len, &props, &props_len) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!s!s!s!s!s!s!", &link, ldap_link_ce, &binddn, &dn_len, &passwd, &passwd_len, &sasl_mech, &mech_len, &sasl_realm, &realm_len, &sasl_authc_id, &authc_id_len, &sasl_authz_id, &authz_id_len, &props, &props_len) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
ctx = _php_sasl_setdefs(ld->link, sasl_mech, sasl_realm, sasl_authc_id, passwd, sasl_authz_id);
@@ -1369,15 +1506,15 @@ PHP_FUNCTION(ldap_unbind)
zval *link;
ldap_linkdata *ld;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &link) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &link, ldap_link_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
+
+ ldap_link_free(ld);
- zend_list_close(Z_RES_P(link));
RETURN_TRUE;
}
/* }}} */
@@ -1430,6 +1567,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
zend_string *ldap_filter = NULL, *ldap_base_dn = NULL;
char **ldap_attrs = NULL;
ldap_linkdata *ld = NULL;
+ ldap_resultdata *result;
LDAPMessage *ldap_res = NULL;
LDAPControl **lserverctrls = NULL;
int ldap_attrsonly = 0, ldap_sizelimit = -1, ldap_timelimit = -1, ldap_deref = -1;
@@ -1487,7 +1625,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
if (Z_TYPE_P(link) == IS_ARRAY) {
int i, nlinks, nbases, nfilters, *rcs;
ldap_linkdata **lds;
- zval *entry, resource;
+ zval *entry, object;
nlinks = zend_hash_num_elements(Z_ARRVAL_P(link));
if (nlinks == 0) {
@@ -1533,11 +1671,19 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
for (i=0; i<nlinks; i++) {
entry = zend_hash_get_current_data(Z_ARRVAL_P(link));
- ld = (ldap_linkdata *) zend_fetch_resource_ex(entry, "ldap link", le_link);
- if (ld == NULL) {
+ if (Z_TYPE_P(entry) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(entry), ldap_link_ce)) {
+ zend_argument_value_error(1, "must only contain objects of type LDAP");
+ ret = 0;
+ goto cleanup_parallel;
+ }
+
+ ld = Z_LDAP_LINK_P(entry);
+ if (!ld->link) {
+ zend_throw_error(NULL, "LDAP connection has already been closed");
ret = 0;
goto cleanup_parallel;
}
+
if (nbases != 0) { /* base_dn an array? */
entry = zend_hash_get_current_data(base_dn_ht);
zend_hash_move_forward(base_dn_ht);
@@ -1583,8 +1729,10 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
rcs[i] = ldap_result(lds[i]->link, LDAP_RES_ANY, 1 /* LDAP_MSG_ALL */, NULL, &ldap_res);
}
if (rcs[i] != -1) {
- ZVAL_RES(&resource, zend_register_resource(ldap_res, le_result));
- add_next_index_zval(return_value, &resource);
+ object_init_ex(&object, ldap_result_ce);
+ result = Z_LDAP_RESULT_P(&object);
+ result->result = ldap_res;
+ add_next_index_zval(return_value, &object);
} else {
add_next_index_bool(return_value, 0);
}
@@ -1593,22 +1741,23 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
cleanup_parallel:
efree(lds);
efree(rcs);
- } else {
- ld = (ldap_linkdata *) zend_fetch_resource_ex(link, "ldap link", le_link);
- if (ld == NULL) {
+ } else if (Z_TYPE_P(link) == IS_OBJECT && instanceof_function(Z_OBJCE_P(link), ldap_link_ce)) {
+ ld = Z_LDAP_LINK_P(link);
+ if (!ld->link) {
+ zend_throw_error(NULL, "LDAP connection has already been closed");
ret = 0;
goto cleanup;
}
if (!base_dn_str) {
- zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is a resource");
+ zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is an LDAP instance");
ret = 0;
goto cleanup;
}
ldap_base_dn = zend_string_copy(base_dn_str);
if (!filter_str) {
- zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is a resource");
+ zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is an LDAP instance");
ret = 0;
goto cleanup;
}
@@ -1652,9 +1801,12 @@ cleanup_parallel:
php_error_docref(NULL, E_WARNING, "Partial search results returned: Adminlimit exceeded");
}
#endif
-
- RETVAL_RES(zend_register_resource(ldap_res, le_result));
+ object_init_ex(return_value, ldap_result_ce);
+ result = Z_LDAP_RESULT_P(return_value);
+ result->result = ldap_res;
}
+ } else {
+ zend_argument_type_error(1, "must be of type LDAP|array, %s given", zend_zval_type_name(link));
}
cleanup:
@@ -1705,17 +1857,17 @@ PHP_FUNCTION(ldap_search)
PHP_FUNCTION(ldap_free_result)
{
zval *result;
- LDAPMessage *ldap_result;
+ ldap_resultdata *ldap_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &result) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &result, ldap_result_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ ldap_result = Z_LDAP_RESULT_P(result);
+ VERIFY_LDAP_RESULT_OPEN(ldap_result);
+
+ ldap_result_free(ldap_result);
- zend_list_close(Z_RES_P(result)); /* Delete list entry */
RETVAL_TRUE;
}
/* }}} */
@@ -1725,21 +1877,19 @@ PHP_FUNCTION(ldap_count_entries)
{
zval *link, *result;
ldap_linkdata *ld;
- LDAPMessage *ldap_result;
+ ldap_resultdata *ldap_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result, ldap_result_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ ldap_result = Z_LDAP_RESULT_P(result);
+ VERIFY_LDAP_RESULT_OPEN(ldap_result);
- RETURN_LONG(ldap_count_entries(ld->link, ldap_result));
+ RETURN_LONG(ldap_count_entries(ld->link, ldap_result->result));
}
/* }}} */
@@ -1748,26 +1898,25 @@ PHP_FUNCTION(ldap_first_entry)
{
zval *link, *result;
ldap_linkdata *ld;
- ldap_resultentry *resultentry;
- LDAPMessage *ldap_result, *entry;
+ ldap_result_entry *resultentry;
+ ldap_resultdata *ldap_result;
+ LDAPMessage *entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result, ldap_result_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ ldap_result = Z_LDAP_RESULT_P(result);
+ VERIFY_LDAP_RESULT_OPEN(ldap_result);
- if ((entry = ldap_first_entry(ld->link, ldap_result)) == NULL) {
+ if ((entry = ldap_first_entry(ld->link, ldap_result->result)) == NULL) {
RETVAL_FALSE;
} else {
- resultentry = emalloc(sizeof(ldap_resultentry));
- RETVAL_RES(zend_register_resource(resultentry, le_result_entry));
+ object_init_ex(return_value, ldap_result_entry_ce);
+ resultentry = Z_LDAP_RESULT_ENTRY_P(return_value);
ZVAL_COPY(&resultentry->res, result);
resultentry->data = entry;
resultentry->ber = NULL;
@@ -1780,25 +1929,23 @@ PHP_FUNCTION(ldap_next_entry)
{
zval *link, *result_entry;
ldap_linkdata *ld;
- ldap_resultentry *resultentry, *resultentry_next;
+ ldap_result_entry *resultentry, *resultentry_next;
LDAPMessage *entry_next;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result_entry) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
- if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
+
+ resultentry = Z_LDAP_RESULT_ENTRY_P(result_entry);
if ((entry_next = ldap_next_entry(ld->link, resultentry->data)) == NULL) {
RETVAL_FALSE;
} else {
- resultentry_next = emalloc(sizeof(ldap_resultentry));
- RETVAL_RES(zend_register_resource(resultentry_next, le_result_entry));
+ object_init_ex(return_value, ldap_result_entry_ce);
+ resultentry_next = Z_LDAP_RESULT_ENTRY_P(return_value);
ZVAL_COPY(&resultentry_next->res, &resultentry->res);
resultentry_next->data = entry_next;
resultentry_next->ber = NULL;
@@ -1810,7 +1957,8 @@ PHP_FUNCTION(ldap_next_entry)
PHP_FUNCTION(ldap_get_entries)
{
zval *link, *result;
- LDAPMessage *ldap_result, *ldap_result_entry;
+ ldap_resultdata *ldap_result;
+ LDAPMessage *ldap_result_entry;
zval tmp1, tmp2;
ldap_linkdata *ld;
LDAP *ldap;
@@ -1821,19 +1969,18 @@ PHP_FUNCTION(ldap_get_entries)
struct berval **ldap_value;
char *dn;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result, ldap_result_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
- if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
+
+ ldap_result = Z_LDAP_RESULT_P(result);
+ VERIFY_LDAP_RESULT_OPEN(ldap_result);
ldap = ld->link;
- num_entries = ldap_count_entries(ldap, ldap_result);
+ num_entries = ldap_count_entries(ldap, ldap_result->result);
array_init(return_value);
add_assoc_long(return_value, "count", num_entries);
@@ -1842,7 +1989,7 @@ PHP_FUNCTION(ldap_get_entries)
return;
}
- ldap_result_entry = ldap_first_entry(ldap, ldap_result);
+ ldap_result_entry = ldap_first_entry(ldap, ldap_result->result);
if (ldap_result_entry == NULL) {
zend_array_destroy(Z_ARR_P(return_value));
RETURN_FALSE;
@@ -1911,20 +2058,17 @@ PHP_FUNCTION(ldap_first_attribute)
{
zval *link, *result_entry;
ldap_linkdata *ld;
- ldap_resultentry *resultentry;
+ ldap_result_entry *resultentry;
char *attribute;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result_entry) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
- RETURN_THROWS();
- }
+ resultentry = Z_LDAP_RESULT_ENTRY_P(result_entry);
if ((attribute = ldap_first_attribute(ld->link, resultentry->data, &resultentry->ber)) == NULL) {
RETURN_FALSE;
@@ -1942,20 +2086,17 @@ PHP_FUNCTION(ldap_next_attribute)
{
zval *link, *result_entry;
ldap_linkdata *ld;
- ldap_resultentry *resultentry;
+ ldap_result_entry *resultentry;
char *attribute;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result_entry) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
- RETURN_THROWS();
- }
+ resultentry = Z_LDAP_RESULT_ENTRY_P(result_entry);
if (resultentry->ber == NULL) {
php_error_docref(NULL, E_WARNING, "Called before calling ldap_first_attribute() or no attributes found in result entry");
@@ -1985,23 +2126,20 @@ PHP_FUNCTION(ldap_get_attributes)
zval *link, *result_entry;
zval tmp;
ldap_linkdata *ld;
- ldap_resultentry *resultentry;
+ ldap_result_entry *resultentry;
char *attribute;
struct berval **ldap_value;
int i, num_values, num_attrib;
BerElement *ber;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result_entry) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
- RETURN_THROWS();
- }
+ resultentry = Z_LDAP_RESULT_ENTRY_P(result_entry);
array_init(return_value);
num_attrib = 0;
@@ -2042,23 +2180,20 @@ PHP_FUNCTION(ldap_get_values_len)
{
zval *link, *result_entry;
ldap_linkdata *ld;
- ldap_resultentry *resultentry;
+ ldap_result_entry *resultentry;
char *attr;
struct berval **ldap_value_len;
int i, num_values;
size_t attr_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrs", &link, &result_entry, &attr, &attr_len) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOs", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce, &attr, &attr_len) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
- RETURN_THROWS();
- }
+ resultentry = Z_LDAP_RESULT_ENTRY_P(result_entry);
if ((ldap_value_len = ldap_get_values_len(ld->link, resultentry->data, attr)) == NULL) {
php_error_docref(NULL, E_WARNING, "Cannot get the value(s) of attribute %s", ldap_err2string(_get_lderrno(ld->link)));
@@ -2083,20 +2218,17 @@ PHP_FUNCTION(ldap_get_dn)
{
zval *link, *result_entry;
ldap_linkdata *ld;
- ldap_resultentry *resultentry;
+ ldap_result_entry *resultentry;
char *text;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result_entry) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
- RETURN_THROWS();
- }
+ resultentry = Z_LDAP_RESULT_ENTRY_P(result_entry);
text = ldap_get_dn(ld->link, resultentry->data);
if (text != NULL) {
@@ -2179,6 +2311,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
char *dn;
LDAPMod **ldap_mods;
LDAPControl **lserverctrls = NULL;
+ ldap_resultdata *result;
LDAPMessage *ldap_res;
int i, j, num_attribs, num_values, msgid;
size_t dn_len;
@@ -2187,13 +2320,12 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
zend_ulong index;
int is_full_add=0; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsa/|a!", &link, &dn, &dn_len, &entry, &serverctrls) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osa/|a!", &link, ldap_link_ce, &dn, &dn_len, &entry, &serverctrls) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
num_attribs = zend_hash_num_elements(Z_ARRVAL_P(entry));
ldap_mods = safe_emalloc((num_attribs+1), sizeof(LDAPMod *), 0);
@@ -2303,7 +2435,9 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
}
/* return a PHP control object */
- RETVAL_RES(zend_register_resource(ldap_res, le_result));
+ object_init_ex(return_value, ldap_result_ce);
+ result = Z_LDAP_RESULT_P(return_value);
+ result->result = ldap_res;
} else RETVAL_TRUE;
} else {
if (ext) {
@@ -2323,7 +2457,9 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
}
/* return a PHP control object */
- RETVAL_RES(zend_register_resource(ldap_res, le_result));
+ object_init_ex(return_value, ldap_result_ce);
+ result = Z_LDAP_RESULT_P(return_value);
+ result->result = ldap_res;
} else RETVAL_TRUE;
}
@@ -2413,18 +2549,18 @@ static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, int ext)
zval *link;
ldap_linkdata *ld;
LDAPControl **lserverctrls = NULL;
+ ldap_resultdata *result;
LDAPMessage *ldap_res;
char *dn;
int rc, msgid;
size_t dn_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|a!", &link, &dn, &dn_len, &serverctrls) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os|a!", &link, ldap_link_ce, &dn, &dn_len, &serverctrls) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
if (serverctrls) {
lserverctrls = _php_ldap_controls_from_array(ld->link, serverctrls, 3);
@@ -2452,7 +2588,9 @@ static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, int ext)
}
/* return a PHP control object */
- RETVAL_RES(zend_register_resource(ldap_res, le_result));
+ object_init_ex(return_value, ldap_result_ce);
+ result = Z_LDAP_RESULT_P(return_value);
+ result->result = ldap_res;
} else {
RETVAL_TRUE;
}
@@ -2561,13 +2699,12 @@ PHP_FUNCTION(ldap_modify_batch)
);
*/
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsa/|a!", &link, &dn, &dn_len, &mods, &serverctrls) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osa/|a!", &link, ldap_link_ce, &dn, &dn_len, &mods, &serverctrls) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
/* perform validation */
{
@@ -2843,13 +2980,12 @@ PHP_FUNCTION(ldap_errno)
zval *link;
ldap_linkdata *ld;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &link) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &link, ldap_link_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
RETURN_LONG(_get_lderrno(ld->link));
}
@@ -2875,13 +3011,12 @@ PHP_FUNCTION(ldap_error)
ldap_linkdata *ld;
int ld_errno;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &link) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &link, ldap_link_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
ld_errno = _get_lderrno(ld->link);
@@ -2901,13 +3036,12 @@ PHP_FUNCTION(ldap_compare)
int errno;
struct berval lvalue;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsss|a!", &link, &dn, &dn_len, &attr, &attr_len, &value, &value_len, &serverctrls) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osss|a!", &link, ldap_link_ce, &dn, &dn_len, &attr, &attr_len, &value, &value_len, &serverctrls) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
if (serverctrls) {
lserverctrls = _php_ldap_controls_from_array(ld->link, serverctrls, 5);
@@ -2953,13 +3087,12 @@ PHP_FUNCTION(ldap_get_option)
ldap_linkdata *ld;
zend_long option;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlz", &link, &option, &retval) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Olz", &link, ldap_link_ce, &option, &retval) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
switch (option) {
/* options with int value */
@@ -3116,21 +3249,20 @@ PHP_FUNCTION(ldap_get_option)
/* {{{ Set the value of various session-wide parameters */
PHP_FUNCTION(ldap_set_option)
{
- zval *link, *newval;
+ zval *link = NULL, *newval;
ldap_linkdata *ld;
LDAP *ldap;
zend_long option;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "zlz", &link, &option, &newval) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O!lz", &link, ldap_link_ce, &option, &newval) != SUCCESS) {
RETURN_THROWS();
}
- if (Z_TYPE_P(link) == IS_NULL) {
+ if (!link) {
ldap = NULL;
} else {
- if ((ld = (ldap_linkdata *)zend_fetch_resource_ex(link, "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
ldap = ld->link;
}
@@ -3300,25 +3432,23 @@ PHP_FUNCTION(ldap_parse_result)
{
zval *link, *result, *errcode, *matcheddn, *errmsg, *referrals, *serverctrls;
ldap_linkdata *ld;
- LDAPMessage *ldap_result;
+ ldap_resultdata *ldap_result;
LDAPControl **lserverctrls = NULL;
char **lreferrals, **refp;
char *lmatcheddn, *lerrmsg;
int rc, lerrcode, myargcount = ZEND_NUM_ARGS();
- if (zend_parse_parameters(myargcount, "rrz|zzzz", &link, &result, &errcode, &matcheddn, &errmsg, &referrals, &serverctrls) != SUCCESS) {
+ if (zend_parse_parameters(myargcount, "OOz|zzzz", &link, ldap_link_ce, &result, ldap_result_ce, &errcode, &matcheddn, &errmsg, &referrals, &serverctrls) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ ldap_result = Z_LDAP_RESULT_P(result);
+ VERIFY_LDAP_RESULT_OPEN(ldap_result);
- rc = ldap_parse_result(ld->link, ldap_result, &lerrcode,
+ rc = ldap_parse_result(ld->link, ldap_result->result, &lerrcode,
myargcount > 3 ? &lmatcheddn : NULL,
myargcount > 4 ? &lerrmsg : NULL,
myargcount > 5 ? &lreferrals : NULL,
@@ -3375,24 +3505,22 @@ PHP_FUNCTION(ldap_parse_exop)
{
zval *link, *result, *retdata, *retoid;
ldap_linkdata *ld;
- LDAPMessage *ldap_result;
+ ldap_resultdata *ldap_result;
char *lretoid;
struct berval *lretdata;
int rc, myargcount = ZEND_NUM_ARGS();
- if (zend_parse_parameters(myargcount, "rr|zz", &link, &result, &retdata, &retoid) != SUCCESS) {
+ if (zend_parse_parameters(myargcount, "OO|zz", &link, ldap_link_ce, &result, ldap_result_ce, &retdata, &retoid) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ ldap_result = Z_LDAP_RESULT_P(result);
+ VERIFY_LDAP_RESULT_OPEN(ldap_result);
- rc = ldap_parse_extended_result(ld->link, ldap_result,
+ rc = ldap_parse_extended_result(ld->link, ldap_result->result,
myargcount > 3 ? &lretoid: NULL,
myargcount > 2 ? &lretdata: NULL,
0);
@@ -3431,21 +3559,19 @@ PHP_FUNCTION(ldap_count_references)
{
zval *link, *result;
ldap_linkdata *ld;
- LDAPMessage *ldap_result;
+ ldap_resultdata *ldap_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result, ldap_result_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ ldap_result = Z_LDAP_RESULT_P(result);
+ VERIFY_LDAP_RESULT_OPEN(ldap_result);
- RETURN_LONG(ldap_count_references(ld->link, ldap_result));
+ RETURN_LONG(ldap_count_references(ld->link, ldap_result->result));
}
/* }}} */
@@ -3454,26 +3580,25 @@ PHP_FUNCTION(ldap_first_reference)
{
zval *link, *result;
ldap_linkdata *ld;
- ldap_resultentry *resultentry;
- LDAPMessage *ldap_result, *entry;
+ ldap_result_entry *resultentry;
+ ldap_resultdata *ldap_result;
+ LDAPMessage *entry;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result, ldap_result_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((ldap_result = (LDAPMessage *)zend_fetch_resource(Z_RES_P(result), "ldap result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ ldap_result = Z_LDAP_RESULT_P(result);
+ VERIFY_LDAP_RESULT_OPEN(ldap_result);
- if ((entry = ldap_first_reference(ld->link, ldap_result)) == NULL) {
+ if ((entry = ldap_first_reference(ld->link, ldap_result->result)) == NULL) {
RETVAL_FALSE;
} else {
- resultentry = emalloc(sizeof(ldap_resultentry));
- RETVAL_RES(zend_register_resource(resultentry, le_result_entry));
+ object_init_ex(return_value, ldap_result_entry_ce);
+ resultentry = Z_LDAP_RESULT_ENTRY_P(return_value);
ZVAL_COPY(&resultentry->res, result);
resultentry->data = entry;
resultentry->ber = NULL;
@@ -3486,26 +3611,23 @@ PHP_FUNCTION(ldap_next_reference)
{
zval *link, *result_entry;
ldap_linkdata *ld;
- ldap_resultentry *resultentry, *resultentry_next;
+ ldap_result_entry *resultentry, *resultentry_next;
LDAPMessage *entry_next;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rr", &link, &result_entry) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OO", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
- RETURN_THROWS();
- }
+ resultentry = Z_LDAP_RESULT_ENTRY_P(result_entry);
if ((entry_next = ldap_next_reference(ld->link, resultentry->data)) == NULL) {
RETVAL_FALSE;
} else {
- resultentry_next = emalloc(sizeof(ldap_resultentry));
- RETVAL_RES(zend_register_resource(resultentry_next, le_result_entry));
+ object_init_ex(return_value, ldap_result_entry_ce);
+ resultentry_next = Z_LDAP_RESULT_ENTRY_P(return_value);
ZVAL_COPY(&resultentry_next->res, &resultentry->res);
resultentry_next->data = entry_next;
resultentry_next->ber = NULL;
@@ -3519,20 +3641,17 @@ PHP_FUNCTION(ldap_parse_reference)
{
zval *link, *result_entry, *referrals;
ldap_linkdata *ld;
- ldap_resultentry *resultentry;
+ ldap_result_entry *resultentry;
char **lreferrals, **refp;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rrz", &link, &result_entry, &referrals) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OOz", &link, ldap_link_ce, &result_entry, ldap_result_entry_ce, &referrals) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
- if ((resultentry = (ldap_resultentry *)zend_fetch_resource(Z_RES_P(result_entry), "ldap result entry", le_result_entry)) == NULL) {
- RETURN_THROWS();
- }
+ resultentry = Z_LDAP_RESULT_ENTRY_P(result_entry);
if (ldap_parse_reference(ld->link, resultentry->data, &lreferrals, NULL /* &serverctrls */, 0) != LDAP_SUCCESS) {
RETURN_FALSE;
@@ -3563,19 +3682,19 @@ static void php_ldap_do_rename(INTERNAL_FUNCTION_PARAMETERS, int ext)
zval *link;
ldap_linkdata *ld;
LDAPControl **lserverctrls = NULL;
+ ldap_resultdata *result;
LDAPMessage *ldap_res;
int rc, msgid;
char *dn, *newrdn, *newparent;
size_t dn_len, newrdn_len, newparent_len;
bool deleteoldrdn;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsssb|a!", &link, &dn, &dn_len, &newrdn, &newrdn_len, &newparent, &newparent_len, &deleteoldrdn, &serverctrls) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osssb|a!", &link, ldap_link_ce, &dn, &dn_len, &newrdn, &newrdn_len, &newparent, &newparent_len, &deleteoldrdn, &serverctrls) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
if (newparent_len == 0) {
newparent = NULL;
@@ -3623,7 +3742,9 @@ static void php_ldap_do_rename(INTERNAL_FUNCTION_PARAMETERS, int ext)
}
/* return a PHP control object */
- RETVAL_RES(zend_register_resource(ldap_res, le_result));
+ object_init_ex(return_value, ldap_result_ce);
+ result = Z_LDAP_RESULT_P(return_value);
+ result->result = ldap_res;
} else {
RETVAL_TRUE;
}
@@ -3659,13 +3780,12 @@ PHP_FUNCTION(ldap_start_tls)
ldap_linkdata *ld;
int rc, protocol = LDAP_VERSION3;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &link) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &link, ldap_link_ce) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
if (((rc = ldap_set_option(ld->link, LDAP_OPT_PROTOCOL_VERSION, &protocol)) != LDAP_SUCCESS) ||
((rc = ldap_start_tls_s(ld->link, NULL, NULL)) != LDAP_SUCCESS)
@@ -3684,17 +3804,21 @@ PHP_FUNCTION(ldap_start_tls)
/* {{{ _ldap_rebind_proc() */
int _ldap_rebind_proc(LDAP *ldap, const char *url, ber_tag_t req, ber_int_t msgid, void *params)
{
- ldap_linkdata *ld;
+ ldap_linkdata *ld = NULL;
int retval;
zval cb_args[2];
zval cb_retval;
zval *cb_link = (zval *) params;
- ld = (ldap_linkdata *) zend_fetch_resource_ex(cb_link, "ldap link", le_link);
+ ld = Z_LDAP_LINK_P(cb_link);
+ if (!ld->link) {
+ zend_throw_error(NULL, "LDAP connection has already been closed");
+ return LDAP_OTHER;
+ }
/* link exists and callback set? */
- if (ld == NULL || Z_ISUNDEF(ld->rebindproc)) {
- php_error_docref(NULL, E_WARNING, "Link not found or no callback set");
+ if (Z_ISUNDEF(ld->rebindproc)) {
+ php_error_docref(NULL, E_WARNING, "No callback set");
return LDAP_OTHER;
}
@@ -3721,13 +3845,12 @@ PHP_FUNCTION(ldap_set_rebind_proc)
zend_fcall_info_cache fcc;
ldap_linkdata *ld;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rf!", &link, &fci, &fcc) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Of!", &link, ldap_link_ce, &fci, &fcc) == FAILURE) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
if (!ZEND_FCI_INITIALIZED(fci)) {
/* unregister rebind procedure */
@@ -3894,17 +4017,17 @@ PHP_FUNCTION(ldap_exop)
zend_string *reqoid, *reqdata = NULL;
struct berval lreqdata, *lretdata = NULL;
ldap_linkdata *ld;
+ ldap_resultdata *result;
LDAPMessage *ldap_res;
LDAPControl **lserverctrls = NULL;
int rc, msgid;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rS|S!a!zz", &link, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS|S!a!zz", &link, ldap_link_ce, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
if (reqdata) {
lreqdata.bv_val = ZSTR_VAL(reqdata);
@@ -3976,7 +4099,9 @@ PHP_FUNCTION(ldap_exop)
}
/* return a PHP control object */
- RETVAL_RES(zend_register_resource(ldap_res, le_result));
+ object_init_ex(return_value, ldap_result_ce);
+ result = Z_LDAP_RESULT_P(return_value);
+ result->result = ldap_res;
cleanup:
if (lserverctrls) {
@@ -4001,13 +4126,12 @@ PHP_FUNCTION(ldap_exop_passwd)
int rc, myargcount = ZEND_NUM_ARGS(), msgid, err;
char* errmsg = NULL;
- if (zend_parse_parameters(myargcount, "r|sssz/", &link, &luser.bv_val, &luser.bv_len, &loldpw.bv_val, &loldpw.bv_len, &lnewpw.bv_val, &lnewpw.bv_len, &serverctrls) == FAILURE) {
+ if (zend_parse_parameters(myargcount, "O|sssz/", &link, ldap_link_ce, &luser.bv_val, &luser.bv_len, &loldpw.bv_val, &loldpw.bv_len, &lnewpw.bv_val, &lnewpw.bv_len, &serverctrls) == FAILURE) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
switch (myargcount) {
case 5:
@@ -4097,13 +4221,12 @@ PHP_FUNCTION(ldap_exop_whoami)
ldap_linkdata *ld;
int rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &link) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &link, ldap_link_ce) == FAILURE) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
/* synchronous call */
rc = ldap_whoami_s(ld->link, &lauthzid, NULL, NULL);
@@ -4135,13 +4258,12 @@ PHP_FUNCTION(ldap_exop_refresh)
ldap_linkdata *ld;
int rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsl", &link, &ldn.bv_val, &ldn.bv_len, &ttl) != SUCCESS) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osl", &link, ldap_link_ce, &ldn.bv_val, &ldn.bv_len, &ttl) != SUCCESS) {
RETURN_THROWS();
}
- if ((ld = (ldap_linkdata *)zend_fetch_resource(Z_RES_P(link), "ldap link", le_link)) == NULL) {
- RETURN_THROWS();
- }
+ ld = Z_LDAP_LINK_P(link);
+ VERIFY_LDAP_LINK_CONNECTED(ld);
lttl = (ber_int_t) ttl;
diff --git a/ext/ldap/ldap.stub.php b/ext/ldap/ldap.stub.php
index 47e93b8436..981f9e1bbb 100644
--- a/ext/ldap/ldap.stub.php
+++ b/ext/ldap/ldap.stub.php
@@ -2,265 +2,151 @@
/** @generate-class-entries */
+/** @strict-properties */
+final class LDAP
+{
+}
+
+/** @strict-properties */
+final class LDAPResult
+{
+}
+
+/** @strict-properties */
+final class LDAPResultEntry
+{
+}
+
#ifdef HAVE_ORALDAP
-/** @return resource|false */
-function ldap_connect(?string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $password = UNKNOWN, int $auth_mode = GSLC_SSL_NO_AUTH) {}
+function ldap_connect(?string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $password = UNKNOWN, int $auth_mode = GSLC_SSL_NO_AUTH): LDAP|false {}
#else
-/** @return resource|false */
-function ldap_connect(?string $uri = null, int $port = 389) {}
+function ldap_connect(?string $uri = null, int $port = 389): LDAP|false {}
#endif
-/** @param resource $ldap */
-function ldap_unbind($ldap): bool {}
+function ldap_unbind(LDAP $ldap): bool {}
-/**
- * @param resource $ldap
- * @alias ldap_unbind
- */
-function ldap_close($ldap): bool {}
+/** @alias ldap_unbind */
+function ldap_close(LDAP $ldap): bool {}
-/** @param resource $ldap */
-function ldap_bind($ldap, ?string $dn = null, ?string $password = null): bool {}
+function ldap_bind(LDAP $ldap, ?string $dn = null, ?string $password = null): bool {}
-/**
- * @param resource $ldap
- * @return resource|false
- */
-function ldap_bind_ext($ldap, ?string $dn = null, ?string $password = null, ?array $controls = null) {}
+function ldap_bind_ext(LDAP $ldap, ?string $dn = null, ?string $password = null, ?array $controls = null): LDAPResult|false {}
#ifdef HAVE_LDAP_SASL
-/** @param resource $ldap */
-function ldap_sasl_bind($ldap, ?string $dn = null, ?string $password = null, ?string $mech = null, ?string $realm = null, ?string $authc_id = null, ?string $authz_id = null, ?string $props = null): bool {}
+function ldap_sasl_bind(LDAP $ldap, ?string $dn = null, ?string $password = null, ?string $mech = null, ?string $realm = null, ?string $authc_id = null, ?string $authz_id = null, ?string $props = null): bool {}
#endif
-/**
- * @param resource|array $ldap
- * @return resource|array|false
- */
-function ldap_read($ldap, array|string $base, array|string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, ?array $controls = null) {}
+/** @param LDAP|array $ldap */
+function ldap_read($ldap, array|string $base, array|string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): LDAPResult|array|false {}
-/**
- * @param resource|array $ldap
- * @return resource|array|false
- */
-function ldap_list($ldap, array|string $base, array|string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, ?array $controls = null) {}
+/** @param LDAP|array $ldap */
+function ldap_list($ldap, array|string $base, array|string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): LDAPResult|array|false {}
-/**
- * @param resource|array $ldap
- * @return resource|array|false
- */
-function ldap_search($ldap, array|string $base, array|string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, ?array $controls = null) {}
-
-/** @param resource $ldap */
-function ldap_free_result($ldap): bool {}
+/** @param LDAP|array $ldap */
+function ldap_search($ldap, array|string $base, array|string $filter, array $attributes = [], int $attributes_only = 0, int $sizelimit = -1, int $timelimit = -1, int $deref = LDAP_DEREF_NEVER, ?array $controls = null): LDAPResult|array|false {}
+function ldap_free_result(LDAPResult $result): bool {}
-/**
- * @param resource $ldap
- * @param resource $result
- */
-function ldap_count_entries($ldap, $result): int {}
+function ldap_count_entries(LDAP $ldap, LDAPResult $result): int {}
-/**
- * @param resource $ldap
- * @param resource $result
- * @return resource|false
- */
-function ldap_first_entry($ldap, $result) {}
+function ldap_first_entry(LDAP $ldap, LDAPResult $result): LDAPResultEntry|false {}
-/**
- * @param resource $ldap
- * @param resource $entry
- * @return resource|false
- */
-function ldap_next_entry($ldap, $entry) {}
+function ldap_next_entry(LDAP $ldap, LDAPResultEntry $entry): LDAPResultEntry|false {}
-/**
- * @param resource $ldap
- * @param resource $result
- */
-function ldap_get_entries($ldap, $result): array|false {}
+function ldap_get_entries(LDAP $ldap, LDAPResult $result): array|false {}
-/**
- * @param resource $ldap
- * @param resource $entry
- */
-function ldap_first_attribute($ldap, $entry): string|false {}
+function ldap_first_attribute(LDAP $ldap, LDAPResultEntry $entry): string|false {}
-/**
- * @param resource $ldap
- * @param resource $entry
- */
-function ldap_next_attribute($ldap, $entry): string|false {}
+function ldap_next_attribute(LDAP $ldap, LDAPResultEntry $entry): string|false {}
-/**
- * @param resource $ldap
- * @param resource $entry
- */
-function ldap_get_attributes($ldap, $entry): array {}
+function ldap_get_attributes(LDAP $ldap, LDAPResultEntry $entry): array {}
-/**
- * @param resource $ldap
- * @param resource $entry
- */
-function ldap_get_values_len($ldap, $entry, string $attribute): array|false {}
+function ldap_get_values_len(LDAP $ldap, LDAPResultEntry $entry, string $attribute): array|false {}
-/**
- * @param resource $ldap
- * @param resource $entry
- * @alias ldap_get_values_len
- */
-function ldap_get_values($ldap, $entry, string $attribute): array|false {}
+/** @alias ldap_get_values_len */
+function ldap_get_values(LDAP $ldap, LDAPResultEntry $entry, string $attribute): array|false {}
-/**
- * @param resource $ldap
- * @param resource $entry
- */
-function ldap_get_dn($ldap, $entry): string|false {}
+function ldap_get_dn(LDAP $ldap, LDAPResultEntry $entry): string|false {}
function ldap_explode_dn(string $dn, int $with_attrib): array|false {}
function ldap_dn2ufn(string $dn): string|false {}
-/** @param resource $ldap */
-function ldap_add($ldap, string $dn, array $entry, ?array $controls = null): bool {}
+function ldap_add(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
-/**
- * @param resource $ldap
- * @return resource|false
- */
-function ldap_add_ext($ldap, string $dn, array $entry, ?array $controls = null) {}
+function ldap_add_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
-/** @param resource $ldap */
-function ldap_delete($ldap, string $dn, ?array $controls = null): bool {}
+function ldap_delete(LDAP $ldap, string $dn, ?array $controls = null): bool {}
-/**
- * @param resource $ldap
- * @return resource|false
- */
-function ldap_delete_ext($ldap, string $dn, ?array $controls = null) {}
+function ldap_delete_ext(LDAP $ldap, string $dn, ?array $controls = null): LDAPResult|false {}
-/** @param resource $ldap */
-function ldap_modify_batch($ldap, string $dn, array $modifications_info, ?array $controls = null): bool {}
+function ldap_modify_batch(LDAP $ldap, string $dn, array $modifications_info, ?array $controls = null): bool {}
-/** @param resource $ldap */
-function ldap_mod_add($ldap, string $dn, array $entry, ?array $controls = null): bool {}
+function ldap_mod_add(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
-/**
- * @param resource $ldap
- * @return resource|false
- */
-function ldap_mod_add_ext($ldap, string $dn, array $entry, ?array $controls = null) {}
+function ldap_mod_add_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
-/** @param resource $ldap */
-function ldap_mod_replace($ldap, string $dn, array $entry, ?array $controls = null): bool {}
+function ldap_mod_replace(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
-/**
- * @param resource $ldap
- * @alias ldap_mod_replace
- */
-function ldap_modify($ldap, string $dn, array $entry, ?array $controls = null): bool {}
+/** @alias ldap_mod_replace */
+function ldap_modify(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
-/**
- * @param resource $ldap
- * @return resource|false
- */
-function ldap_mod_replace_ext($ldap, string $dn, array $entry, ?array $controls = null) {}
+function ldap_mod_replace_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
-/** @param resource $ldap */
-function ldap_mod_del($ldap, string $dn, array $entry, ?array $controls = null): bool {}
+function ldap_mod_del(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
-/**
- * @param resource $ldap
- * @return resource|false
- */
-function ldap_mod_del_ext($ldap, string $dn, array $entry, ?array $controls = null) {}
+function ldap_mod_del_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
-/** @param resource $ldap */
-function ldap_errno($ldap): int {}
+function ldap_errno(LDAP $ldap): int {}
-/** @param resource $ldap */
-function ldap_error($ldap): string {}
+function ldap_error(LDAP $ldap): string {}
function ldap_err2str(int $errno): string {}
-/** @param resource $ldap */
-function ldap_compare($ldap, string $dn, string $attribute, string $value, ?array $controls = null): bool|int {}
+function ldap_compare(LDAP $ldap, string $dn, string $attribute, string $value, ?array $controls = null): bool|int {}
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
-/** @param resource $ldap */
-function ldap_rename($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): bool {}
-
-/**
- * @param resource $ldap
- * @return resource|false
- */
-function ldap_rename_ext($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null) {}
+function ldap_rename(LDAP $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): bool {}
+function ldap_rename_ext(LDAP $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): LDAPResult|false {}
/**
- * @param resource $ldap
* @param array|string|int $value
*/
-function ldap_get_option($ldap, int $option, &$value = null): bool {}
+function ldap_get_option(LDAP $ldap, int $option, &$value = null): bool {}
-/**
- * @param resource|null $ldap
- * @param array|string|int|bool $value
- */
-function ldap_set_option($ldap, int $option, $value): bool {}
+/** @param array|string|int|bool $value */
+function ldap_set_option(?LDAP $ldap, int $option, $value): bool {}
-/**
- * @param resource $ldap
- * @param resource $result
- */
-function ldap_count_references($ldap, $result): int {}
+function ldap_count_references(LDAP $ldap, LDAPResult $result): int {}
-/**
- * @param resource $ldap
- * @param resource $result
- * @return resource|false
- */
-function ldap_first_reference($ldap, $result) {}
+function ldap_first_reference(LDAP $ldap, LDAPResult $result): LDAPResultEntry|false {}
-/**
- * @param resource $ldap
- * @param resource $entry
- * @return resource|false
- */
-function ldap_next_reference($ldap, $entry) {}
+function ldap_next_reference(LDAP $ldap, LDAPResultEntry $entry): LDAPResultEntry|false {}
#ifdef HAVE_LDAP_PARSE_REFERENCE
-/**
- * @param resource $ldap
- * @param resource $entry
- * @param array $referrals
- */
-function ldap_parse_reference($ldap, $entry, &$referrals): bool {}
+/** @param array $referrals */
+function ldap_parse_reference(LDAP $ldap, LDAPResultEntry $entry, &$referrals): bool {}
#endif
#ifdef HAVE_LDAP_PARSE_RESULT
/**
- * @param resource $ldap
- * @param resource $result
* @param int $error_code
* @param string $matched_dn
* @param string $error_message
* @param array $referrals
* @param array $controls
*/
-function ldap_parse_result($ldap, $result, &$error_code, &$matched_dn = null, &$error_message = null, &$referrals = null, &$controls = null): bool {}
+function ldap_parse_result(LDAP $ldap, LDAPResult $result, &$error_code, &$matched_dn = null, &$error_message = null, &$referrals = null, &$controls = null): bool {}
#endif
#endif
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
-/** @param resource $ldap */
-function ldap_set_rebind_proc($ldap, ?callable $callback): bool {}
+function ldap_set_rebind_proc(LDAP $ldap, ?callable $callback): bool {}
#endif
#ifdef HAVE_LDAP_START_TLS_S
-/** @param resource $ldap */
-function ldap_start_tls($ldap): bool {}
+function ldap_start_tls(LDAP $ldap): bool {}
#endif
function ldap_escape(string $value, string $ignore = "", int $flags = 0): string {}
@@ -274,39 +160,32 @@ function ldap_8859_to_t61(string $value): string|false {}
#ifdef HAVE_LDAP_EXTENDED_OPERATION_S
/**
- * @param resource $ldap
* @param string $response_data
* @param string $response_oid
- * @return resource|bool
*/
-function ldap_exop($ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = UNKNOWN, &$response_oid = null) {}
+function ldap_exop(LDAP $ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = UNKNOWN, &$response_oid = null): LDAPResult|bool {}
#endif
#ifdef HAVE_LDAP_PASSWD
/**
- * @param resource $ldap
* @param array $controls
*/
-function ldap_exop_passwd($ldap, string $user = "", string $old_password = "", string $new_password = "", &$controls = null): string|bool {}
+function ldap_exop_passwd(LDAP $ldap, string $user = "", string $old_password = "", string $new_password = "", &$controls = null): string|bool {}
#endif
#ifdef HAVE_LDAP_WHOAMI_S
-/** @param resource $ldap */
-function ldap_exop_whoami($ldap): string|false {}
+function ldap_exop_whoami(LDAP $ldap): string|false {}
#endif
#ifdef HAVE_LDAP_REFRESH_S
-/** @param resource $ldap */
-function ldap_exop_refresh($ldap, string $dn, int $ttl): int|false {}
+function ldap_exop_refresh(LDAP $ldap, string $dn, int $ttl): int|false {}
#endif
#ifdef HAVE_LDAP_PARSE_EXTENDED_RESULT
/**
- * @param resource $ldap
- * @param resource $result
* @param string $response_data
* @param string $response_oid
*/
-function ldap_parse_exop($ldap, $result, &$response_data = null, &$response_oid = null): bool {}
+function ldap_parse_exop(LDAP $ldap, LDAPResult $result, &$response_data = null, &$response_oid = null): bool {}
#endif
diff --git a/ext/ldap/ldap_arginfo.h b/ext/ldap/ldap_arginfo.h
index 14fac1a031..bcefcac8c0 100644
--- a/ext/ldap/ldap_arginfo.h
+++ b/ext/ldap/ldap_arginfo.h
@@ -1,8 +1,8 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 5cae0fbe180164126aa99ad5465822d87fe73fb9 */
+ * Stub hash: 9829bfa03164e646ed81aa6601589409002db960 */
#if defined(HAVE_ORALDAP)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_connect, 0, 0, LDAP, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, uri, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "389")
ZEND_ARG_TYPE_INFO(0, wallet, IS_STRING, 0)
@@ -12,26 +12,26 @@ ZEND_END_ARG_INFO()
#endif
#if !(defined(HAVE_ORALDAP))
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_connect, 0, 0, LDAP, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, uri, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "389")
ZEND_END_ARG_INFO()
#endif
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_unbind, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_END_ARG_INFO()
#define arginfo_ldap_close arginfo_ldap_unbind
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_bind, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, dn, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, password, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_bind_ext, 0, 0, 1)
- ZEND_ARG_INFO(0, ldap)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_bind_ext, 0, 1, LDAPResult, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, dn, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, password, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "null")
@@ -39,7 +39,7 @@ ZEND_END_ARG_INFO()
#if defined(HAVE_LDAP_SASL)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_sasl_bind, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, dn, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, password, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mech, IS_STRING, 1, "null")
@@ -50,7 +50,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_sasl_bind, 0, 1, _IS_BOOL,
ZEND_END_ARG_INFO()
#endif
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_read, 0, 0, 3)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_read, 0, 3, LDAPResult, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_INFO(0, ldap)
ZEND_ARG_TYPE_MASK(0, base, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
ZEND_ARG_TYPE_MASK(0, filter, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
@@ -66,43 +66,45 @@ ZEND_END_ARG_INFO()
#define arginfo_ldap_search arginfo_ldap_read
-#define arginfo_ldap_free_result arginfo_ldap_unbind
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_free_result, 0, 1, _IS_BOOL, 0)
+ ZEND_ARG_OBJ_INFO(0, result, LDAPResult, 0)
+ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_count_entries, 0, 2, IS_LONG, 0)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, result)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, result, LDAPResult, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_first_entry, 0, 0, 2)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, result)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_first_entry, 0, 2, LDAPResultEntry, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, result, LDAPResult, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_next_entry, 0, 0, 2)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, entry)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_next_entry, 0, 2, LDAPResultEntry, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, entry, LDAPResultEntry, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_get_entries, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, result)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, result, LDAPResult, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_first_attribute, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, entry)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, entry, LDAPResultEntry, 0)
ZEND_END_ARG_INFO()
#define arginfo_ldap_next_attribute arginfo_ldap_first_attribute
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_get_attributes, 0, 2, IS_ARRAY, 0)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, entry)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, entry, LDAPResultEntry, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_get_values_len, 0, 3, MAY_BE_ARRAY|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, entry)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, entry, LDAPResultEntry, 0)
ZEND_ARG_TYPE_INFO(0, attribute, IS_STRING, 0)
ZEND_END_ARG_INFO()
@@ -120,33 +122,33 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_dn2ufn, 0, 1, MAY_BE_STRING
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_add, 0, 3, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, dn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, entry, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_add_ext, 0, 0, 3)
- ZEND_ARG_INFO(0, ldap)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_add_ext, 0, 3, LDAPResult, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, dn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, entry, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_delete, 0, 2, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, dn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_delete_ext, 0, 0, 2)
- ZEND_ARG_INFO(0, ldap)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_delete_ext, 0, 2, LDAPResult, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, dn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_modify_batch, 0, 3, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, dn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, modifications_info, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "null")
@@ -167,11 +169,11 @@ ZEND_END_ARG_INFO()
#define arginfo_ldap_mod_del_ext arginfo_ldap_add_ext
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_errno, 0, 1, IS_LONG, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_error, 0, 1, IS_STRING, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_err2str, 0, 1, IS_STRING, 0)
@@ -179,7 +181,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_err2str, 0, 1, IS_STRING, 0
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_compare, 0, 4, MAY_BE_BOOL|MAY_BE_LONG)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, dn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, attribute, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
@@ -188,7 +190,7 @@ ZEND_END_ARG_INFO()
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_rename, 0, 5, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, dn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, new_rdn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, new_parent, IS_STRING, 0)
@@ -198,8 +200,8 @@ ZEND_END_ARG_INFO()
#endif
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_rename_ext, 0, 0, 5)
- ZEND_ARG_INFO(0, ldap)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_rename_ext, 0, 5, LDAPResult, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, dn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, new_rdn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, new_parent, IS_STRING, 0)
@@ -210,7 +212,7 @@ ZEND_END_ARG_INFO()
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_get_option, 0, 2, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, value, "null")
ZEND_END_ARG_INFO()
@@ -218,7 +220,7 @@ ZEND_END_ARG_INFO()
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_set_option, 0, 3, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 1)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
@@ -226,37 +228,37 @@ ZEND_END_ARG_INFO()
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_count_references, 0, 2, IS_LONG, 0)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, result)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, result, LDAPResult, 0)
ZEND_END_ARG_INFO()
#endif
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_first_reference, 0, 0, 2)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, result)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_first_reference, 0, 2, LDAPResultEntry, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, result, LDAPResult, 0)
ZEND_END_ARG_INFO()
#endif
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_next_reference, 0, 0, 2)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, entry)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_next_reference, 0, 2, LDAPResultEntry, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, entry, LDAPResultEntry, 0)
ZEND_END_ARG_INFO()
#endif
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP) && defined(HAVE_LDAP_PARSE_REFERENCE)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_parse_reference, 0, 3, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, entry)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, entry, LDAPResultEntry, 0)
ZEND_ARG_INFO(1, referrals)
ZEND_END_ARG_INFO()
#endif
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP) && defined(HAVE_LDAP_PARSE_RESULT)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_parse_result, 0, 3, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, result)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, result, LDAPResult, 0)
ZEND_ARG_INFO(1, error_code)
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, matched_dn, "null")
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, error_message, "null")
@@ -267,14 +269,14 @@ ZEND_END_ARG_INFO()
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_set_rebind_proc, 0, 2, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 1)
ZEND_END_ARG_INFO()
#endif
#if defined(HAVE_LDAP_START_TLS_S)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_start_tls, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_END_ARG_INFO()
#endif
@@ -295,8 +297,8 @@ ZEND_END_ARG_INFO()
#endif
#if defined(HAVE_LDAP_EXTENDED_OPERATION_S)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_exop, 0, 0, 2)
- ZEND_ARG_INFO(0, ldap)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_exop, 0, 2, LDAPResult, MAY_BE_BOOL)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, request_oid, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, request_data, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "NULL")
@@ -307,7 +309,7 @@ ZEND_END_ARG_INFO()
#if defined(HAVE_LDAP_PASSWD)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_exop_passwd, 0, 1, MAY_BE_STRING|MAY_BE_BOOL)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, user, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, old_password, IS_STRING, 0, "\"\"")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, new_password, IS_STRING, 0, "\"\"")
@@ -317,13 +319,13 @@ ZEND_END_ARG_INFO()
#if defined(HAVE_LDAP_WHOAMI_S)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_exop_whoami, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_END_ARG_INFO()
#endif
#if defined(HAVE_LDAP_REFRESH_S)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_exop_refresh, 0, 3, MAY_BE_LONG|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, ldap)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
ZEND_ARG_TYPE_INFO(0, dn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, ttl, IS_LONG, 0)
ZEND_END_ARG_INFO()
@@ -331,8 +333,8 @@ ZEND_END_ARG_INFO()
#if defined(HAVE_LDAP_PARSE_EXTENDED_RESULT)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ldap_parse_exop, 0, 2, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, ldap)
- ZEND_ARG_INFO(0, result)
+ ZEND_ARG_OBJ_INFO(0, ldap, LDAP, 0)
+ ZEND_ARG_OBJ_INFO(0, result, LDAPResult, 0)
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, response_data, "null")
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, response_oid, "null")
ZEND_END_ARG_INFO()
@@ -541,3 +543,51 @@ static const zend_function_entry ext_functions[] = {
#endif
ZEND_FE_END
};
+
+
+static const zend_function_entry class_LDAP_methods[] = {
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_LDAPResult_methods[] = {
+ ZEND_FE_END
+};
+
+
+static const zend_function_entry class_LDAPResultEntry_methods[] = {
+ ZEND_FE_END
+};
+
+static zend_class_entry *register_class_LDAP(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "LDAP", class_LDAP_methods);
+ class_entry = zend_register_internal_class_ex(&ce, NULL);
+ class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES;
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_LDAPResult(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "LDAPResult", class_LDAPResult_methods);
+ class_entry = zend_register_internal_class_ex(&ce, NULL);
+ class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES;
+
+ return class_entry;
+}
+
+static zend_class_entry *register_class_LDAPResultEntry(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_CLASS_ENTRY(ce, "LDAPResultEntry", class_LDAPResultEntry_methods);
+ class_entry = zend_register_internal_class_ex(&ce, NULL);
+ class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES;
+
+ return class_entry;
+}
diff --git a/ext/ldap/tests/bug48441.phpt b/ext/ldap/tests/bug48441.phpt
index c4b224c7a7..fc24816211 100644
--- a/ext/ldap/tests/bug48441.phpt
+++ b/ext/ldap/tests/bug48441.phpt
@@ -38,7 +38,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(4) {
["count"]=>
int(3)
@@ -93,7 +94,8 @@ array(4) {
}
Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
@@ -112,7 +114,8 @@ array(2) {
string(%d) "cn=userA,%s"
}
}
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(4) {
["count"]=>
int(3)
diff --git a/ext/ldap/tests/bug73933.phpt b/ext/ldap/tests/bug73933.phpt
index 0a02aca2ed..3dd093223a 100644
--- a/ext/ldap/tests/bug73933.phpt
+++ b/ext/ldap/tests/bug73933.phpt
@@ -20,7 +20,6 @@ ldap_modify_batch($ldap, '', array( [
"test@example.com",
"test-2@example.com", ]]));
-
ldap_close($ldap);
?>
diff --git a/ext/ldap/tests/bug77958.phpt b/ext/ldap/tests/bug77958.phpt
index b370b40eda..318ebf0e9b 100644
--- a/ext/ldap/tests/bug77958.phpt
+++ b/ext/ldap/tests/bug77958.phpt
@@ -42,7 +42,8 @@ remove_dummy_data($link, $base);
?>
--EXPECTF--
bool(true)
-resource(%d) of type (ldap result entry)
+object(LDAPResultEntry)#%d (0) {
+}
array(3) {
[0]=>
string(14) "xx-xx-xx-xx-xx"
diff --git a/ext/ldap/tests/ldap_add_ext.phpt b/ext/ldap/tests/ldap_add_ext.phpt
index fbcaff523b..8fb2d3db5b 100644
--- a/ext/ldap/tests/ldap_add_ext.phpt
+++ b/ext/ldap/tests/ldap_add_ext.phpt
@@ -41,7 +41,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
ldap_delete($link, "o=test_ldap_add_ext,$base");
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
int(0)
string(0) ""
diff --git a/ext/ldap/tests/ldap_bind_ext.phpt b/ext/ldap/tests/ldap_bind_ext.phpt
index 685b0588ce..f43edf76c3 100644
--- a/ext/ldap/tests/ldap_bind_ext.phpt
+++ b/ext/ldap/tests/ldap_bind_ext.phpt
@@ -44,25 +44,29 @@ var_dump(
);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
int(0)
string(0) ""
array(0) {
}
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
int(0)
string(0) ""
array(0) {
}
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
int(49)
string(0) ""
array(0) {
}
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
int(34)
string(10) "invalid DN"
diff --git a/ext/ldap/tests/ldap_connect_basic.phpt b/ext/ldap/tests/ldap_connect_basic.phpt
index 0d03c99d59..3be030b4fa 100644
--- a/ext/ldap/tests/ldap_connect_basic.phpt
+++ b/ext/ldap/tests/ldap_connect_basic.phpt
@@ -13,4 +13,5 @@ $link = ldap_connect($host, $port);
var_dump($link);
?>
--EXPECTF--
-resource(%d) of type (ldap link)
+object(LDAP)#%d (0) {
+}
diff --git a/ext/ldap/tests/ldap_connect_variation.phpt b/ext/ldap/tests/ldap_connect_variation.phpt
index 1405e0706f..36c72e0202 100644
--- a/ext/ldap/tests/ldap_connect_variation.phpt
+++ b/ext/ldap/tests/ldap_connect_variation.phpt
@@ -30,8 +30,13 @@ $link = ldap_connect("nonexistent" . $host);
var_dump($link);
?>
--EXPECTF--
-resource(%d) of type (ldap link)
-resource(%d) of type (ldap link)
-resource(%d) of type (ldap link)
-resource(%d) of type (ldap link)
-resource(%d) of type (ldap link)
+object(LDAP)#%d (0) {
+}
+object(LDAP)#%d (0) {
+}
+object(LDAP)#%d (0) {
+}
+object(LDAP)#%d (0) {
+}
+object(LDAP)#%d (0) {
+}
diff --git a/ext/ldap/tests/ldap_controls.phpt b/ext/ldap/tests/ldap_controls.phpt
index e6e0ab6164..396202f3cb 100644
--- a/ext/ldap/tests/ldap_controls.phpt
+++ b/ext/ldap/tests/ldap_controls.phpt
@@ -65,7 +65,8 @@ Warning: ldap_modify(): Modify: Assertion Failed in %s on line %d
Warning: ldap_delete(): Delete: Assertion Failed in %s on line %d
Warning: ldap_compare(): Compare: Assertion Failed in %s on line %d
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
@@ -88,7 +89,8 @@ array(2) {
}
bool(false)
bool(true)
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
@@ -110,7 +112,8 @@ array(2) {
}
}
bool(false)
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
@@ -138,7 +141,8 @@ bool(false)
bool(true)
int(-1)
bool(true)
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(4) {
["count"]=>
int(3)
@@ -149,7 +153,8 @@ array(4) {
[2]=>
string(10) "Antarctica"
}
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(3) {
["count"]=>
int(2)
diff --git a/ext/ldap/tests/ldap_delete_ext.phpt b/ext/ldap/tests/ldap_delete_ext.phpt
index bcdc15ba51..5e7eeafecf 100644
--- a/ext/ldap/tests/ldap_delete_ext.phpt
+++ b/ext/ldap/tests/ldap_delete_ext.phpt
@@ -43,7 +43,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
ldap_delete($link, "dc=my-domain,$base");
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
int(0)
string(0) ""
diff --git a/ext/ldap/tests/ldap_exop.phpt b/ext/ldap/tests/ldap_exop.phpt
index abb63e877f..dc443c2c5f 100644
--- a/ext/ldap/tests/ldap_exop.phpt
+++ b/ext/ldap/tests/ldap_exop.phpt
@@ -36,8 +36,6 @@ function extract_genpw($retdata)
$userAPassword = "oops";
-// ldap_exop(resource link, string reqoid [, string reqdata [, array servercontrols [, string &retdata [, string &retoid]]]])
-// bool ldap_parse_exop(resource link, resource result [, string &retdata [, string &retoid]])
var_dump(
ldap_exop($link, LDAP_EXOP_WHO_AM_I, NULL, NULL, $retdata, $retoid),
$retdata,
@@ -69,11 +67,13 @@ string(%d) "dn:%s"
string(0) ""
bool(true)
string(%d) "dn:cn=user%s"
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
string(%d) "dn:%s"
bool(true)
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
string(%d) "%s"
string(0) ""
diff --git a/ext/ldap/tests/ldap_exop_passwd.phpt b/ext/ldap/tests/ldap_exop_passwd.phpt
index 1b0a1e7397..f04d258aee 100644
--- a/ext/ldap/tests/ldap_exop_passwd.phpt
+++ b/ext/ldap/tests/ldap_exop_passwd.phpt
@@ -14,7 +14,6 @@ insert_dummy_data($link, $base);
// ldap_exop_passwd() allows to pass the DN, OLD and NEW passwords,
// and optionally returns the NEW password if none was passed.
-// ldap_exop_passwd(resource link [, string user [, string oldpw [, string newpw [, string newpasswd ]]]])
var_dump(
$genpw = ldap_exop_passwd($link, "cn=userA,$base", "oops", "", $ctrls),
$ctrls,
diff --git a/ext/ldap/tests/ldap_exop_whoami.phpt b/ext/ldap/tests/ldap_exop_whoami.phpt
index 2c71848b00..35c86ca155 100644
--- a/ext/ldap/tests/ldap_exop_whoami.phpt
+++ b/ext/ldap/tests/ldap_exop_whoami.phpt
@@ -12,7 +12,6 @@ require "connect.inc";
$link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
insert_dummy_data($link, $base);
-// ldap_exop_whoami(resource link [, string authzid])
var_dump(
ldap_exop_whoami($link)
);
diff --git a/ext/ldap/tests/ldap_first_attribute_error.phpt b/ext/ldap/tests/ldap_first_attribute_error.phpt
index 79138669bc..d5c11ca800 100644
--- a/ext/ldap/tests/ldap_first_attribute_error.phpt
+++ b/ext/ldap/tests/ldap_first_attribute_error.phpt
@@ -17,4 +17,4 @@ try {
}
?>
--EXPECT--
-ldap_first_attribute(): supplied resource is not a valid ldap result entry resource
+ldap_first_attribute(): Argument #2 ($entry) must be of type LDAPResultEntry, LDAP given
diff --git a/ext/ldap/tests/ldap_first_entry_basic.phpt b/ext/ldap/tests/ldap_first_entry_basic.phpt
index 94d46d6d87..56a4943b6a 100644
--- a/ext/ldap/tests/ldap_first_entry_basic.phpt
+++ b/ext/ldap/tests/ldap_first_entry_basic.phpt
@@ -26,7 +26,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result entry)
+object(LDAPResultEntry)#%d (0) {
+}
array(2) {
[0]=>
string(7) "testSN%d"
diff --git a/ext/ldap/tests/ldap_first_reference_basic.phpt b/ext/ldap/tests/ldap_first_reference_basic.phpt
index 0e41ee2458..9d00d08f43 100644
--- a/ext/ldap/tests/ldap_first_reference_basic.phpt
+++ b/ext/ldap/tests/ldap_first_reference_basic.phpt
@@ -33,7 +33,8 @@ ldap_delete($link, "cn=userref,$base", [['oid' => LDAP_CONTROL_MANAGEDSAIT, 'isc
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result entry)
+object(LDAPResultEntry)#%d (0) {
+}
array(1) {
[0]=>
string(%d) "cn=userA,%s"
diff --git a/ext/ldap/tests/ldap_get_option_controls.phpt b/ext/ldap/tests/ldap_get_option_controls.phpt
index 813f33e069..6cb61084b9 100644
--- a/ext/ldap/tests/ldap_get_option_controls.phpt
+++ b/ext/ldap/tests/ldap_get_option_controls.phpt
@@ -104,7 +104,8 @@ array(1) {
}
}
}
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
int(1)
bool(true)
bool(false)
diff --git a/ext/ldap/tests/ldap_list_basic.phpt b/ext/ldap/tests/ldap_list_basic.phpt
index f4d8bda31b..5a10166b88 100644
--- a/ext/ldap/tests/ldap_list_basic.phpt
+++ b/ext/ldap/tests/ldap_list_basic.phpt
@@ -28,7 +28,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(3) {
["count"]=>
int(2)
diff --git a/ext/ldap/tests/ldap_mod_ext.phpt b/ext/ldap/tests/ldap_mod_ext.phpt
index 0ca091fed8..9b4b32eef3 100644
--- a/ext/ldap/tests/ldap_mod_ext.phpt
+++ b/ext/ldap/tests/ldap_mod_ext.phpt
@@ -62,7 +62,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
int(0)
string(0) ""
@@ -133,7 +134,8 @@ array(2) {
string(%d) "o=test,%s"
}
}
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
int(0)
string(0) ""
diff --git a/ext/ldap/tests/ldap_next_entry_basic.phpt b/ext/ldap/tests/ldap_next_entry_basic.phpt
index d8f03ce291..b640b83836 100644
--- a/ext/ldap/tests/ldap_next_entry_basic.phpt
+++ b/ext/ldap/tests/ldap_next_entry_basic.phpt
@@ -28,7 +28,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result entry)
+object(LDAPResultEntry)#%d (0) {
+}
array(2) {
[0]=>
string(7) "testSN%d"
diff --git a/ext/ldap/tests/ldap_next_reference_basic.phpt b/ext/ldap/tests/ldap_next_reference_basic.phpt
index 7af26ff91c..1cc03b4dcf 100644
--- a/ext/ldap/tests/ldap_next_reference_basic.phpt
+++ b/ext/ldap/tests/ldap_next_reference_basic.phpt
@@ -39,7 +39,8 @@ ldap_delete($link, "cn=userref2,$base", [['oid' => LDAP_CONTROL_MANAGEDSAIT, 'is
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result entry)
+object(LDAPResultEntry)#%d (0) {
+}
array(1) {
[0]=>
string(%d) "cn=userB,%s"
diff --git a/ext/ldap/tests/ldap_parse_result_controls.phpt b/ext/ldap/tests/ldap_parse_result_controls.phpt
index 2a5f7e1d3b..1abb9887c1 100644
--- a/ext/ldap/tests/ldap_parse_result_controls.phpt
+++ b/ext/ldap/tests/ldap_parse_result_controls.phpt
@@ -36,7 +36,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
string(22) "1.2.840.113556.1.4.319"
int(%d)
diff --git a/ext/ldap/tests/ldap_read_basic.phpt b/ext/ldap/tests/ldap_read_basic.phpt
index 596c02a71e..2597395d6b 100644
--- a/ext/ldap/tests/ldap_read_basic.phpt
+++ b/ext/ldap/tests/ldap_read_basic.phpt
@@ -28,7 +28,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
diff --git a/ext/ldap/tests/ldap_rename_ext.phpt b/ext/ldap/tests/ldap_rename_ext.phpt
index e4f7d8364e..9d249c71ec 100644
--- a/ext/ldap/tests/ldap_rename_ext.phpt
+++ b/ext/ldap/tests/ldap_rename_ext.phpt
@@ -42,7 +42,8 @@ ldap_rename($link, "cn=userZ,$base", "cn=userA", "$base", true);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
bool(true)
int(0)
string(0) ""
diff --git a/ext/ldap/tests/ldap_search_basic.phpt b/ext/ldap/tests/ldap_search_basic.phpt
index f7ed449c16..b10a1d7b11 100644
--- a/ext/ldap/tests/ldap_search_basic.phpt
+++ b/ext/ldap/tests/ldap_search_basic.phpt
@@ -29,7 +29,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(4) {
["count"]=>
int(3)
diff --git a/ext/ldap/tests/ldap_search_error.phpt b/ext/ldap/tests/ldap_search_error.phpt
index 3e8167bf2c..1b02e549b3 100644
--- a/ext/ldap/tests/ldap_search_error.phpt
+++ b/ext/ldap/tests/ldap_search_error.phpt
@@ -61,5 +61,5 @@ bool(false)
ldap_search(): Argument #1 ($ldap) cannot be empty
ldap_search(): Argument #2 ($base) must have the same number of elements as the links array
ldap_search(): Argument #3 ($filter) must have the same number of elements as the links array
-ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is a resource
-ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is a resource
+ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is an LDAP instance
+ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is an LDAP instance
diff --git a/ext/ldap/tests/ldap_search_overrides.phpt b/ext/ldap/tests/ldap_search_overrides.phpt
index 01a96fd86a..eaf042c6d2 100644
--- a/ext/ldap/tests/ldap_search_overrides.phpt
+++ b/ext/ldap/tests/ldap_search_overrides.phpt
@@ -42,7 +42,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(4) {
["count"]=>
int(3)
diff --git a/ext/ldap/tests/ldap_search_paged_result_controls.phpt b/ext/ldap/tests/ldap_search_paged_result_controls.phpt
index f60acd3e0c..7e55fb359f 100644
--- a/ext/ldap/tests/ldap_search_paged_result_controls.phpt
+++ b/ext/ldap/tests/ldap_search_paged_result_controls.phpt
@@ -36,7 +36,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(3) {
["count"]=>
int(2)
@@ -74,7 +75,8 @@ array(3) {
}
}
bool(true)
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
diff --git a/ext/ldap/tests/ldap_search_sort_controls.phpt b/ext/ldap/tests/ldap_search_sort_controls.phpt
index f55faf4930..886064a72c 100644
--- a/ext/ldap/tests/ldap_search_sort_controls.phpt
+++ b/ext/ldap/tests/ldap_search_sort_controls.phpt
@@ -78,7 +78,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(4) {
["count"]=>
int(3)
@@ -146,7 +147,8 @@ array(1) {
}
}
}
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(3) {
["count"]=>
int(2)
diff --git a/ext/ldap/tests/ldap_search_variation1.phpt b/ext/ldap/tests/ldap_search_variation1.phpt
index 88eb79aa77..60d2ea21b6 100644
--- a/ext/ldap/tests/ldap_search_variation1.phpt
+++ b/ext/ldap/tests/ldap_search_variation1.phpt
@@ -31,7 +31,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
diff --git a/ext/ldap/tests/ldap_search_variation2.phpt b/ext/ldap/tests/ldap_search_variation2.phpt
index 8b130aaa08..5f0f284dc5 100644
--- a/ext/ldap/tests/ldap_search_variation2.phpt
+++ b/ext/ldap/tests/ldap_search_variation2.phpt
@@ -29,7 +29,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(4) {
["count"]=>
int(3)
diff --git a/ext/ldap/tests/ldap_search_variation3.phpt b/ext/ldap/tests/ldap_search_variation3.phpt
index d0b6ec5cad..17b0da4574 100644
--- a/ext/ldap/tests/ldap_search_variation3.phpt
+++ b/ext/ldap/tests/ldap_search_variation3.phpt
@@ -36,7 +36,8 @@ $link = ldap_connect_and_bind($host, $port, $user, $passwd, $protocol_version);
remove_dummy_data($link, $base);
?>
--EXPECTF--
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(4) {
["count"]=>
int(3)
@@ -85,7 +86,8 @@ array(4) {
}
Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
diff --git a/ext/ldap/tests/ldap_search_variation4.phpt b/ext/ldap/tests/ldap_search_variation4.phpt
index 694840b397..981f110627 100644
--- a/ext/ldap/tests/ldap_search_variation4.phpt
+++ b/ext/ldap/tests/ldap_search_variation4.phpt
@@ -32,7 +32,8 @@ remove_dummy_data($link, $base);
?>
--EXPECTF--
Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
diff --git a/ext/ldap/tests/ldap_search_variation5.phpt b/ext/ldap/tests/ldap_search_variation5.phpt
index 211df9a128..7f3674edc0 100644
--- a/ext/ldap/tests/ldap_search_variation5.phpt
+++ b/ext/ldap/tests/ldap_search_variation5.phpt
@@ -40,7 +40,8 @@ remove_dummy_data($link, $base);
?>
--EXPECTF--
Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
@@ -61,7 +62,8 @@ array(2) {
}
Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
@@ -82,7 +84,8 @@ array(2) {
}
Warning: ldap_search(): Partial search results returned: Sizelimit exceeded in %s on line %d
-resource(%d) of type (ldap result)
+object(LDAPResult)#%d (0) {
+}
array(2) {
["count"]=>
int(1)
diff --git a/ext/ldap/tests/ldap_search_variation6.phpt b/ext/ldap/tests/ldap_search_variation6.phpt
index 6451c2930b..e0b5ba9825 100644
--- a/ext/ldap/tests/ldap_search_variation6.phpt
+++ b/ext/ldap/tests/ldap_search_variation6.phpt
@@ -45,9 +45,11 @@ remove_dummy_data($link, $base);
--EXPECTF--
array(2) {
[0]=>
- resource(%d) of type (ldap result)
+ object(LDAPResult)#%d (0) {
+ }
[1]=>
- resource(%d) of type (ldap result)
+ object(LDAPResult)#%d (0) {
+ }
}
array(4) {
["count"]=>
@@ -212,9 +214,11 @@ array(4) {
bool(true)
array(2) {
[0]=>
- resource(%d) of type (ldap result)
+ object(LDAPResult)#%d (0) {
+ }
[1]=>
- resource(%d) of type (ldap result)
+ object(LDAPResult)#%d (0) {
+ }
}
array(1) {
["count"]=>
@@ -226,9 +230,11 @@ array(1) {
}
array(2) {
[0]=>
- resource(%d) of type (ldap result)
+ object(LDAPResult)#%d (0) {
+ }
[1]=>
- resource(%d) of type (ldap result)
+ object(LDAPResult)#%d (0) {
+ }
}
array(1) {
["count"]=>