Skip to content

Move resource-object classes of LDAP to \LDAP namespaces #6963

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ PHP NEWS
. 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é)
. Convert resource<ldap link> to object \LDAP\Connection. (Máté)
. Convert resource<ldap result> to object \LDAP\Result. (Máté)
. Convert resource<ldap result entry> to object \LDAP\ResultEntry. (Máté)

- MySQLi:
. Fixed bug #70372 (Emulate mysqli_fetch_all() for libmysqlclient). (Nikita)
Expand Down
6 changes: 3 additions & 3 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ PHP 8.1 UPGRADE NOTES
instead of resources.

- LDAP:
. The LDAP functions now accept and return, respectively, LDAP objects
. The LDAP functions now accept and return, respectively, LDAP\Connection 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
. The LDAP functions now accept and return, respectively, LDAP\Result 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
. The LDAP functions now accept and return, respectively, LDAP\ResultEntry
objects instead of "ldap result entry" resources. Return value checks using
is_resource() should be replaced with checks for `false`.

Expand Down
12 changes: 6 additions & 6 deletions ext/ldap/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static zend_object *ldap_link_create_object(zend_class_entry *class_type) {
}

static zend_function *ldap_link_get_constructor(zend_object *object) {
zend_throw_error(NULL, "Cannot directly construct LDAP, use ldap_create() instead");
zend_throw_error(NULL, "Cannot directly construct LDAP\\Connection, use ldap_create() instead");
return NULL;
}

Expand Down Expand Up @@ -167,7 +167,7 @@ static zend_object *ldap_result_create_object(zend_class_entry *class_type) {
}

static zend_function *ldap_result_get_constructor(zend_object *object) {
zend_throw_error(NULL, "Cannot directly construct LDAPResult, use the dedicated functions instead");
zend_throw_error(NULL, "Cannot directly construct LDAP\\Result, use the dedicated functions instead");
return NULL;
}

Expand Down Expand Up @@ -205,7 +205,7 @@ static zend_object *ldap_result_entry_create_object(zend_class_entry *class_type
}

static zend_function *ldap_result_entry_get_constructor(zend_object *obj) {
zend_throw_error(NULL, "Cannot directly construct LDAPResultEntry, use the dedicated functions instead");
zend_throw_error(NULL, "Cannot directly construct LDAP\\ResultEntry, use the dedicated functions instead");
return NULL;
}

Expand Down Expand Up @@ -826,7 +826,7 @@ PHP_MINIT_FUNCTION(ldap)
{
REGISTER_INI_ENTRIES();

ldap_link_ce = register_class_LDAP();
ldap_link_ce = register_class_LDAP_Connection();
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;
Expand All @@ -838,7 +838,7 @@ PHP_MINIT_FUNCTION(ldap)
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 = register_class_LDAP_Result();
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;
Expand All @@ -850,7 +850,7 @@ PHP_MINIT_FUNCTION(ldap)
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 = register_class_LDAP_ResultEntry();
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;
Expand Down
140 changes: 73 additions & 67 deletions ext/ldap/ldap.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,131 +2,135 @@

/** @generate-class-entries */

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

/** @strict-properties */
final class Result
{
}

/** @strict-properties */
final class ResultEntry
{
}
}

/** @strict-properties */
final class LDAPResult
{
}

/** @strict-properties */
final class LDAPResultEntry
{
}
namespace {

#ifdef HAVE_ORALDAP
function ldap_connect(?string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $password = UNKNOWN, int $auth_mode = GSLC_SSL_NO_AUTH): LDAP|false {}
function ldap_connect(?string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $password = UNKNOWN, int $auth_mode = GSLC_SSL_NO_AUTH): LDAP\Connection|false {}
#else
function ldap_connect(?string $uri = null, int $port = 389): LDAP|false {}
function ldap_connect(?string $uri = null, int $port = 389): LDAP\Connection|false {}
#endif

function ldap_unbind(LDAP $ldap): bool {}
function ldap_unbind(LDAP\Connection $ldap): bool {}

/** @alias ldap_unbind */
function ldap_close(LDAP $ldap): bool {}
function ldap_close(LDAP\Connection $ldap): bool {}

function ldap_bind(LDAP $ldap, ?string $dn = null, ?string $password = null): bool {}
function ldap_bind(LDAP\Connection $ldap, ?string $dn = null, ?string $password = null): bool {}

function ldap_bind_ext(LDAP $ldap, ?string $dn = null, ?string $password = null, ?array $controls = null): LDAPResult|false {}
function ldap_bind_ext(LDAP\Connection $ldap, ?string $dn = null, ?string $password = null, ?array $controls = null): LDAP\Result|false {}

#ifdef HAVE_LDAP_SASL
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 {}
function ldap_sasl_bind(LDAP\Connection $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 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 LDAP\Connection|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): LDAP\Result|array|false {}

/** @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 LDAP\Connection|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): LDAP\Result|array|false {}

/** @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 {}
/** @param LDAP\Connection|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): LDAP\Result|array|false {}

function ldap_free_result(LDAPResult $result): bool {}
function ldap_free_result(LDAP\Result $result): bool {}

function ldap_count_entries(LDAP $ldap, LDAPResult $result): int {}
function ldap_count_entries(LDAP\Connection $ldap, LDAP\Result $result): int {}

function ldap_first_entry(LDAP $ldap, LDAPResult $result): LDAPResultEntry|false {}
function ldap_first_entry(LDAP\Connection $ldap, LDAP\Result $result): LDAP\ResultEntry|false {}

function ldap_next_entry(LDAP $ldap, LDAPResultEntry $entry): LDAPResultEntry|false {}
function ldap_next_entry(LDAP\Connection $ldap, LDAP\ResultEntry $entry): LDAP\ResultEntry|false {}

function ldap_get_entries(LDAP $ldap, LDAPResult $result): array|false {}
function ldap_get_entries(LDAP\Connection $ldap, LDAP\Result $result): array|false {}

function ldap_first_attribute(LDAP $ldap, LDAPResultEntry $entry): string|false {}
function ldap_first_attribute(LDAP\Connection $ldap, LDAP\ResultEntry $entry): string|false {}

function ldap_next_attribute(LDAP $ldap, LDAPResultEntry $entry): string|false {}
function ldap_next_attribute(LDAP\Connection $ldap, LDAP\ResultEntry $entry): string|false {}

function ldap_get_attributes(LDAP $ldap, LDAPResultEntry $entry): array {}
function ldap_get_attributes(LDAP\Connection $ldap, LDAP\ResultEntry $entry): array {}

function ldap_get_values_len(LDAP $ldap, LDAPResultEntry $entry, string $attribute): array|false {}
function ldap_get_values_len(LDAP\Connection $ldap, LDAP\ResultEntry $entry, string $attribute): array|false {}

/** @alias ldap_get_values_len */
function ldap_get_values(LDAP $ldap, LDAPResultEntry $entry, string $attribute): array|false {}
function ldap_get_values(LDAP\Connection $ldap, LDAP\ResultEntry $entry, string $attribute): array|false {}

function ldap_get_dn(LDAP $ldap, LDAPResultEntry $entry): string|false {}
function ldap_get_dn(LDAP\Connection $ldap, LDAP\ResultEntry $entry): string|false {}

function ldap_explode_dn(string $dn, int $with_attrib): array|false {}

function ldap_dn2ufn(string $dn): string|false {}

function ldap_add(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
function ldap_add(LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): bool {}

function ldap_add_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
function ldap_add_ext(LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): LDAP\Result|false {}

function ldap_delete(LDAP $ldap, string $dn, ?array $controls = null): bool {}
function ldap_delete(LDAP\Connection $ldap, string $dn, ?array $controls = null): bool {}

function ldap_delete_ext(LDAP $ldap, string $dn, ?array $controls = null): LDAPResult|false {}
function ldap_delete_ext(LDAP\Connection $ldap, string $dn, ?array $controls = null): LDAP\Result|false {}

function ldap_modify_batch(LDAP $ldap, string $dn, array $modifications_info, ?array $controls = null): bool {}
function ldap_modify_batch(LDAP\Connection $ldap, string $dn, array $modifications_info, ?array $controls = null): bool {}

function ldap_mod_add(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
function ldap_mod_add(LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): bool {}

function ldap_mod_add_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
function ldap_mod_add_ext(LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): LDAP\Result|false {}

function ldap_mod_replace(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
function ldap_mod_replace(LDAP\Connection $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 {}
function ldap_modify(LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): bool {}

function ldap_mod_replace_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
function ldap_mod_replace_ext(LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): LDAP\Result|false {}

function ldap_mod_del(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
function ldap_mod_del(LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): bool {}

function ldap_mod_del_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
function ldap_mod_del_ext(LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null): LDAP\Result|false {}

function ldap_errno(LDAP $ldap): int {}
function ldap_errno(LDAP\Connection $ldap): int {}

function ldap_error(LDAP $ldap): string {}
function ldap_error(LDAP\Connection $ldap): string {}

function ldap_err2str(int $errno): string {}

function ldap_compare(LDAP $ldap, string $dn, string $attribute, string $value, ?array $controls = null): bool|int {}
function ldap_compare(LDAP\Connection $ldap, string $dn, string $attribute, string $value, ?array $controls = null): bool|int {}

#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
function ldap_rename(LDAP $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): bool {}
function ldap_rename(LDAP\Connection $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 {}
function ldap_rename_ext(LDAP\Connection $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): LDAP\Result|false {}

/**
* @param array|string|int $value
*/
function ldap_get_option(LDAP $ldap, int $option, &$value = null): bool {}
function ldap_get_option(LDAP\Connection $ldap, int $option, &$value = null): bool {}

/** @param array|string|int|bool $value */
function ldap_set_option(?LDAP $ldap, int $option, $value): bool {}
function ldap_set_option(?LDAP\Connection $ldap, int $option, $value): bool {}

function ldap_count_references(LDAP $ldap, LDAPResult $result): int {}
function ldap_count_references(LDAP\Connection $ldap, LDAP\Result $result): int {}

function ldap_first_reference(LDAP $ldap, LDAPResult $result): LDAPResultEntry|false {}
function ldap_first_reference(LDAP\Connection $ldap, LDAP\Result $result): LDAP\ResultEntry|false {}

function ldap_next_reference(LDAP $ldap, LDAPResultEntry $entry): LDAPResultEntry|false {}
function ldap_next_reference(LDAP\Connection $ldap, LDAP\ResultEntry $entry): LDAP\ResultEntry|false {}

#ifdef HAVE_LDAP_PARSE_REFERENCE
/** @param array $referrals */
function ldap_parse_reference(LDAP $ldap, LDAPResultEntry $entry, &$referrals): bool {}
function ldap_parse_reference(LDAP\Connection $ldap, LDAP\ResultEntry $entry, &$referrals): bool {}
#endif

#ifdef HAVE_LDAP_PARSE_RESULT
Expand All @@ -137,16 +141,16 @@ function ldap_parse_reference(LDAP $ldap, LDAPResultEntry $entry, &$referrals):
* @param array $referrals
* @param array $controls
*/
function ldap_parse_result(LDAP $ldap, LDAPResult $result, &$error_code, &$matched_dn = null, &$error_message = null, &$referrals = null, &$controls = null): bool {}
function ldap_parse_result(LDAP\Connection $ldap, LDAP\Result $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)
function ldap_set_rebind_proc(LDAP $ldap, ?callable $callback): bool {}
function ldap_set_rebind_proc(LDAP\Connection $ldap, ?callable $callback): bool {}
#endif

#ifdef HAVE_LDAP_START_TLS_S
function ldap_start_tls(LDAP $ldap): bool {}
function ldap_start_tls(LDAP\Connection $ldap): bool {}
#endif

function ldap_escape(string $value, string $ignore = "", int $flags = 0): string {}
Expand All @@ -163,29 +167,31 @@ function ldap_8859_to_t61(string $value): string|false {}
* @param string $response_data
* @param string $response_oid
*/
function ldap_exop(LDAP $ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = UNKNOWN, &$response_oid = null): LDAPResult|bool {}
function ldap_exop(LDAP\Connection $ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = UNKNOWN, &$response_oid = null): LDAP\Result|bool {}
#endif

#ifdef HAVE_LDAP_PASSWD
/**
* @param array $controls
*/
function ldap_exop_passwd(LDAP $ldap, string $user = "", string $old_password = "", string $new_password = "", &$controls = null): string|bool {}
function ldap_exop_passwd(LDAP\Connection $ldap, string $user = "", string $old_password = "", string $new_password = "", &$controls = null): string|bool {}
#endif


#ifdef HAVE_LDAP_WHOAMI_S
function ldap_exop_whoami(LDAP $ldap): string|false {}
function ldap_exop_whoami(LDAP\Connection $ldap): string|false {}
#endif

#ifdef HAVE_LDAP_REFRESH_S
function ldap_exop_refresh(LDAP $ldap, string $dn, int $ttl): int|false {}
function ldap_exop_refresh(LDAP\Connection $ldap, string $dn, int $ttl): int|false {}
#endif

#ifdef HAVE_LDAP_PARSE_EXTENDED_RESULT
/**
* @param string $response_data
* @param string $response_oid
*/
function ldap_parse_exop(LDAP $ldap, LDAPResult $result, &$response_data = null, &$response_oid = null): bool {}
function ldap_parse_exop(LDAP\Connection $ldap, LDAP\Result $result, &$response_data = null, &$response_oid = null): bool {}
#endif

}
Loading