Skip to content

Commit 921c034

Browse files
committed
Move resource-object classes of LDAP to \LDAP namespaces
Another change as per accepted [namespaces in bundled extensions RFC](https://wiki.php.net/rfc/namespaces_in_bundled_extensions). Related: php#6925, php#5945, php#6960
1 parent 68224f2 commit 921c034

35 files changed

+211
-205
lines changed

NEWS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ PHP NEWS
6464
. Implemented FR #73385 (Add xxHash support). (Anatol)
6565

6666
- LDAP:
67-
. Convert resource<ldap link> to object \LDAP. (Máté)
68-
. Convert resource<ldap result> to object \LDAPResult. (Máté)
69-
. Convert resource<ldap result entry> to object \LDAPResultEntry. (Máté)
67+
. Convert resource<ldap link> to object \LDAP\LDAP. (Máté)
68+
. Convert resource<ldap result> to object \LDAP\Result. (Máté)
69+
. Convert resource<ldap result entry> to object \LDAP\ResultEntry. (Máté)
7070

7171
- MySQLi:
7272
. Fixed bug #70372 (Emulate mysqli_fetch_all() for libmysqlclient). (Nikita)

UPGRADING

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ PHP 8.1 UPGRADE NOTES
7171
instead of resources.
7272

7373
- LDAP:
74-
. The LDAP functions now accept and return, respectively, LDAP objects
74+
. The LDAP functions now accept and return, respectively, LDAP\LDAP objects
7575
instead of "ldap link" resources. Return value checks using is_resource()
7676
should be replaced with checks for `false`.
77-
. The LDAP functions now accept and return, respectively, LDAPResult objects
77+
. The LDAP functions now accept and return, respectively, LDAP\Result objects
7878
instead of "ldap result" resources. Return value checks using is_resource()
7979
should be replaced with checks for `false`.
80-
. The LDAP functions now accept and return, respectively, LDAPResultEntry
80+
. The LDAP functions now accept and return, respectively, LDAP\ResultEntry
8181
objects instead of "ldap result entry" resources. Return value checks using
8282
is_resource() should be replaced with checks for `false`.
8383

ext/ldap/ldap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static zend_object *ldap_link_create_object(zend_class_entry *class_type) {
121121
}
122122

123123
static zend_function *ldap_link_get_constructor(zend_object *object) {
124-
zend_throw_error(NULL, "Cannot directly construct LDAP, use ldap_create() instead");
124+
zend_throw_error(NULL, "Cannot directly construct LDAP\\LDAP, use ldap_create() instead");
125125
return NULL;
126126
}
127127

@@ -167,7 +167,7 @@ static zend_object *ldap_result_create_object(zend_class_entry *class_type) {
167167
}
168168

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

@@ -205,7 +205,7 @@ static zend_object *ldap_result_entry_create_object(zend_class_entry *class_type
205205
}
206206

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

@@ -826,7 +826,7 @@ PHP_MINIT_FUNCTION(ldap)
826826
{
827827
REGISTER_INI_ENTRIES();
828828

829-
ldap_link_ce = register_class_LDAP();
829+
ldap_link_ce = register_class_LDAP_LDAP();
830830
ldap_link_ce->create_object = ldap_link_create_object;
831831
ldap_link_ce->serialize = zend_class_serialize_deny;
832832
ldap_link_ce->unserialize = zend_class_unserialize_deny;
@@ -838,7 +838,7 @@ PHP_MINIT_FUNCTION(ldap)
838838
ldap_link_object_handlers.clone_obj = NULL;
839839
ldap_link_object_handlers.compare = zend_objects_not_comparable;
840840

841-
ldap_result_ce = register_class_LDAPResult();
841+
ldap_result_ce = register_class_LDAP_Result();
842842
ldap_result_ce->create_object = ldap_result_create_object;
843843
ldap_result_ce->serialize = zend_class_serialize_deny;
844844
ldap_result_ce->unserialize = zend_class_unserialize_deny;
@@ -850,7 +850,7 @@ PHP_MINIT_FUNCTION(ldap)
850850
ldap_result_object_handlers.clone_obj = NULL;
851851
ldap_result_object_handlers.compare = zend_objects_not_comparable;
852852

853-
ldap_result_entry_ce = register_class_LDAPResultEntry();
853+
ldap_result_entry_ce = register_class_LDAP_ResultEntry();
854854
ldap_result_entry_ce->create_object = ldap_result_entry_create_object;
855855
ldap_result_entry_ce->serialize = zend_class_serialize_deny;
856856
ldap_result_entry_ce->unserialize = zend_class_unserialize_deny;

ext/ldap/ldap.stub.php

Lines changed: 73 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,131 +2,135 @@
22

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

5-
/** @strict-properties */
6-
final class LDAP
7-
{
5+
namespace LDAP {
6+
/** @strict-properties */
7+
final class LDAP
8+
{
9+
}
10+
11+
/** @strict-properties */
12+
final class Result
13+
{
14+
}
15+
16+
/** @strict-properties */
17+
final class ResultEntry
18+
{
19+
}
820
}
921

10-
/** @strict-properties */
11-
final class LDAPResult
12-
{
13-
}
14-
15-
/** @strict-properties */
16-
final class LDAPResultEntry
17-
{
18-
}
22+
namespace {
1923

2024
#ifdef HAVE_ORALDAP
21-
function ldap_connect(?string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $password = UNKNOWN, int $auth_mode = GSLC_SSL_NO_AUTH): LDAP|false {}
25+
function ldap_connect(?string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $password = UNKNOWN, int $auth_mode = GSLC_SSL_NO_AUTH): LDAP\LDAP|false {}
2226
#else
23-
function ldap_connect(?string $uri = null, int $port = 389): LDAP|false {}
27+
function ldap_connect(?string $uri = null, int $port = 389): LDAP\LDAP|false {}
2428
#endif
2529

26-
function ldap_unbind(LDAP $ldap): bool {}
30+
function ldap_unbind(LDAP\LDAP $ldap): bool {}
2731

2832
/** @alias ldap_unbind */
29-
function ldap_close(LDAP $ldap): bool {}
33+
function ldap_close(LDAP\LDAP $ldap): bool {}
3034

31-
function ldap_bind(LDAP $ldap, ?string $dn = null, ?string $password = null): bool {}
35+
function ldap_bind(LDAP\LDAP $ldap, ?string $dn = null, ?string $password = null): bool {}
3236

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

3539
#ifdef HAVE_LDAP_SASL
36-
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 {}
40+
function ldap_sasl_bind(LDAP\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 {}
3741
#endif
3842

39-
/** @param LDAP|array $ldap */
40-
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 {}
43+
/** @param LDAP\LDAP|array $ldap */
44+
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 {}
4145

42-
/** @param LDAP|array $ldap */
43-
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 {}
46+
/** @param LDAP\LDAP|array $ldap */
47+
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 {}
4448

45-
/** @param LDAP|array $ldap */
46-
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 {}
49+
/** @param LDAP\LDAP|array $ldap */
50+
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 {}
4751

48-
function ldap_free_result(LDAPResult $result): bool {}
52+
function ldap_free_result(LDAP\Result $result): bool {}
4953

50-
function ldap_count_entries(LDAP $ldap, LDAPResult $result): int {}
54+
function ldap_count_entries(LDAP\LDAP $ldap, LDAP\Result $result): int {}
5155

52-
function ldap_first_entry(LDAP $ldap, LDAPResult $result): LDAPResultEntry|false {}
56+
function ldap_first_entry(LDAP\LDAP $ldap, LDAP\Result $result): LDAP\ResultEntry|false {}
5357

54-
function ldap_next_entry(LDAP $ldap, LDAPResultEntry $entry): LDAPResultEntry|false {}
58+
function ldap_next_entry(LDAP\LDAP $ldap, LDAP\ResultEntry $entry): LDAP\ResultEntry|false {}
5559

56-
function ldap_get_entries(LDAP $ldap, LDAPResult $result): array|false {}
60+
function ldap_get_entries(LDAP\LDAP $ldap, LDAP\Result $result): array|false {}
5761

58-
function ldap_first_attribute(LDAP $ldap, LDAPResultEntry $entry): string|false {}
62+
function ldap_first_attribute(LDAP\LDAP $ldap, LDAP\ResultEntry $entry): string|false {}
5963

60-
function ldap_next_attribute(LDAP $ldap, LDAPResultEntry $entry): string|false {}
64+
function ldap_next_attribute(LDAP\LDAP $ldap, LDAP\ResultEntry $entry): string|false {}
6165

62-
function ldap_get_attributes(LDAP $ldap, LDAPResultEntry $entry): array {}
66+
function ldap_get_attributes(LDAP\LDAP $ldap, LDAP\ResultEntry $entry): array {}
6367

64-
function ldap_get_values_len(LDAP $ldap, LDAPResultEntry $entry, string $attribute): array|false {}
68+
function ldap_get_values_len(LDAP\LDAP $ldap, LDAP\ResultEntry $entry, string $attribute): array|false {}
6569

6670
/** @alias ldap_get_values_len */
67-
function ldap_get_values(LDAP $ldap, LDAPResultEntry $entry, string $attribute): array|false {}
71+
function ldap_get_values(LDAP\LDAP $ldap, LDAP\ResultEntry $entry, string $attribute): array|false {}
6872

69-
function ldap_get_dn(LDAP $ldap, LDAPResultEntry $entry): string|false {}
73+
function ldap_get_dn(LDAP\LDAP $ldap, LDAP\ResultEntry $entry): string|false {}
7074

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

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

75-
function ldap_add(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
79+
function ldap_add(LDAP\LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
7680

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

79-
function ldap_delete(LDAP $ldap, string $dn, ?array $controls = null): bool {}
83+
function ldap_delete(LDAP\LDAP $ldap, string $dn, ?array $controls = null): bool {}
8084

81-
function ldap_delete_ext(LDAP $ldap, string $dn, ?array $controls = null): LDAPResult|false {}
85+
function ldap_delete_ext(LDAP\LDAP $ldap, string $dn, ?array $controls = null): LDAP\Result|false {}
8286

83-
function ldap_modify_batch(LDAP $ldap, string $dn, array $modifications_info, ?array $controls = null): bool {}
87+
function ldap_modify_batch(LDAP\LDAP $ldap, string $dn, array $modifications_info, ?array $controls = null): bool {}
8488

85-
function ldap_mod_add(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
89+
function ldap_mod_add(LDAP\LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
8690

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

89-
function ldap_mod_replace(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
93+
function ldap_mod_replace(LDAP\LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
9094

9195
/** @alias ldap_mod_replace */
92-
function ldap_modify(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
96+
function ldap_modify(LDAP\LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
9397

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

96-
function ldap_mod_del(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
100+
function ldap_mod_del(LDAP\LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
97101

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

100-
function ldap_errno(LDAP $ldap): int {}
104+
function ldap_errno(LDAP\LDAP $ldap): int {}
101105

102-
function ldap_error(LDAP $ldap): string {}
106+
function ldap_error(LDAP\LDAP $ldap): string {}
103107

104108
function ldap_err2str(int $errno): string {}
105109

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

108112
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
109-
function ldap_rename(LDAP $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): bool {}
113+
function ldap_rename(LDAP\LDAP $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): bool {}
110114

111-
function ldap_rename_ext(LDAP $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): LDAPResult|false {}
115+
function ldap_rename_ext(LDAP\LDAP $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): LDAP\Result|false {}
112116

113117
/**
114118
* @param array|string|int $value
115119
*/
116-
function ldap_get_option(LDAP $ldap, int $option, &$value = null): bool {}
120+
function ldap_get_option(LDAP\LDAP $ldap, int $option, &$value = null): bool {}
117121

118122
/** @param array|string|int|bool $value */
119-
function ldap_set_option(?LDAP $ldap, int $option, $value): bool {}
123+
function ldap_set_option(?LDAP\LDAP $ldap, int $option, $value): bool {}
120124

121-
function ldap_count_references(LDAP $ldap, LDAPResult $result): int {}
125+
function ldap_count_references(LDAP\LDAP $ldap, LDAP\Result $result): int {}
122126

123-
function ldap_first_reference(LDAP $ldap, LDAPResult $result): LDAPResultEntry|false {}
127+
function ldap_first_reference(LDAP\LDAP $ldap, LDAP\Result $result): LDAP\ResultEntry|false {}
124128

125-
function ldap_next_reference(LDAP $ldap, LDAPResultEntry $entry): LDAPResultEntry|false {}
129+
function ldap_next_reference(LDAP\LDAP $ldap, LDAP\ResultEntry $entry): LDAP\ResultEntry|false {}
126130

127131
#ifdef HAVE_LDAP_PARSE_REFERENCE
128132
/** @param array $referrals */
129-
function ldap_parse_reference(LDAP $ldap, LDAPResultEntry $entry, &$referrals): bool {}
133+
function ldap_parse_reference(LDAP\LDAP $ldap, LDAP\ResultEntry $entry, &$referrals): bool {}
130134
#endif
131135

132136
#ifdef HAVE_LDAP_PARSE_RESULT
@@ -137,16 +141,16 @@ function ldap_parse_reference(LDAP $ldap, LDAPResultEntry $entry, &$referrals):
137141
* @param array $referrals
138142
* @param array $controls
139143
*/
140-
function ldap_parse_result(LDAP $ldap, LDAPResult $result, &$error_code, &$matched_dn = null, &$error_message = null, &$referrals = null, &$controls = null): bool {}
144+
function ldap_parse_result(LDAP\LDAP $ldap, LDAP\Result $result, &$error_code, &$matched_dn = null, &$error_message = null, &$referrals = null, &$controls = null): bool {}
141145
#endif
142146
#endif
143147

144148
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
145-
function ldap_set_rebind_proc(LDAP $ldap, ?callable $callback): bool {}
149+
function ldap_set_rebind_proc(LDAP\LDAP $ldap, ?callable $callback): bool {}
146150
#endif
147151

148152
#ifdef HAVE_LDAP_START_TLS_S
149-
function ldap_start_tls(LDAP $ldap): bool {}
153+
function ldap_start_tls(LDAP\LDAP $ldap): bool {}
150154
#endif
151155

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

169173
#ifdef HAVE_LDAP_PASSWD
170174
/**
171175
* @param array $controls
172176
*/
173-
function ldap_exop_passwd(LDAP $ldap, string $user = "", string $old_password = "", string $new_password = "", &$controls = null): string|bool {}
177+
function ldap_exop_passwd(LDAP\LDAP $ldap, string $user = "", string $old_password = "", string $new_password = "", &$controls = null): string|bool {}
174178
#endif
175179

176180

177181
#ifdef HAVE_LDAP_WHOAMI_S
178-
function ldap_exop_whoami(LDAP $ldap): string|false {}
182+
function ldap_exop_whoami(LDAP\LDAP $ldap): string|false {}
179183
#endif
180184

181185
#ifdef HAVE_LDAP_REFRESH_S
182-
function ldap_exop_refresh(LDAP $ldap, string $dn, int $ttl): int|false {}
186+
function ldap_exop_refresh(LDAP\LDAP $ldap, string $dn, int $ttl): int|false {}
183187
#endif
184188

185189
#ifdef HAVE_LDAP_PARSE_EXTENDED_RESULT
186190
/**
187191
* @param string $response_data
188192
* @param string $response_oid
189193
*/
190-
function ldap_parse_exop(LDAP $ldap, LDAPResult $result, &$response_data = null, &$response_oid = null): bool {}
194+
function ldap_parse_exop(LDAP\LDAP $ldap, LDAP\Result $result, &$response_data = null, &$response_oid = null): bool {}
191195
#endif
196+
197+
}

0 commit comments

Comments
 (0)