Skip to content

Commit 9c491fd

Browse files
committed
Convert resources to objects in ext/ldap
1 parent d5a15d2 commit 9c491fd

36 files changed

+690
-587
lines changed

ext/ldap/ldap.c

Lines changed: 393 additions & 271 deletions
Large diffs are not rendered by default.

ext/ldap/ldap.stub.php

Lines changed: 75 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -2,265 +2,151 @@
22

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

5+
/** @strict-properties */
6+
final class LDAP
7+
{
8+
}
9+
10+
/** @strict-properties */
11+
final class LDAPResult
12+
{
13+
}
14+
15+
/** @strict-properties */
16+
final class LDAPResultEntry
17+
{
18+
}
19+
520
#ifdef HAVE_ORALDAP
6-
/** @return resource|false */
7-
function ldap_connect(?string $uri = null, int $port = 389, string $wallet = UNKNOWN, string $password = UNKNOWN, int $auth_mode = GSLC_SSL_NO_AUTH) {}
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 {}
822
#else
9-
/** @return resource|false */
10-
function ldap_connect(?string $uri = null, int $port = 389) {}
23+
function ldap_connect(?string $uri = null, int $port = 389): LDAP|false {}
1124
#endif
1225

13-
/** @param resource $ldap */
14-
function ldap_unbind($ldap): bool {}
26+
function ldap_unbind(LDAP $ldap): bool {}
1527

16-
/**
17-
* @param resource $ldap
18-
* @alias ldap_unbind
19-
*/
20-
function ldap_close($ldap): bool {}
28+
/** @alias ldap_unbind */
29+
function ldap_close(LDAP $ldap): bool {}
2130

22-
/** @param resource $ldap */
23-
function ldap_bind($ldap, ?string $dn = null, ?string $password = null): bool {}
31+
function ldap_bind(LDAP $ldap, ?string $dn = null, ?string $password = null): bool {}
2432

25-
/**
26-
* @param resource $ldap
27-
* @return resource|false
28-
*/
29-
function ldap_bind_ext($ldap, ?string $dn = null, ?string $password = null, ?array $controls = null) {}
33+
function ldap_bind_ext(LDAP $ldap, ?string $dn = null, ?string $password = null, ?array $controls = null): LDAPResult|false {}
3034

3135
#ifdef HAVE_LDAP_SASL
32-
/** @param resource $ldap */
33-
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 {}
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 {}
3437
#endif
3538

36-
/**
37-
* @param resource|array $ldap
38-
* @return resource|array|false
39-
*/
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) {}
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 {}
4141

42-
/**
43-
* @param resource|array $ldap
44-
* @return resource|array|false
45-
*/
46-
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) {}
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 {}
4744

48-
/**
49-
* @param resource|array $ldap
50-
* @return resource|array|false
51-
*/
52-
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) {}
53-
54-
/** @param resource $ldap */
55-
function ldap_free_result($ldap): bool {}
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 {}
5647

48+
function ldap_free_result(LDAPResult $result): bool {}
5749

58-
/**
59-
* @param resource $ldap
60-
* @param resource $result
61-
*/
62-
function ldap_count_entries($ldap, $result): int {}
50+
function ldap_count_entries(LDAP $ldap, LDAPResult $result): int {}
6351

64-
/**
65-
* @param resource $ldap
66-
* @param resource $result
67-
* @return resource|false
68-
*/
69-
function ldap_first_entry($ldap, $result) {}
52+
function ldap_first_entry(LDAP $ldap, LDAPResult $result): LDAPResultEntry|false {}
7053

71-
/**
72-
* @param resource $ldap
73-
* @param resource $result
74-
* @return resource|false
75-
*/
76-
function ldap_next_entry($ldap, $result) {}
54+
function ldap_next_entry(LDAP $ldap, LDAPResultEntry $entry): LDAPResultEntry|false {}
7755

78-
/**
79-
* @param resource $ldap
80-
* @param resource $result
81-
*/
82-
function ldap_get_entries($ldap, $result): array|false {}
56+
function ldap_get_entries(LDAP $ldap, LDAPResult $result): array|false {}
8357

84-
/**
85-
* @param resource $ldap
86-
* @param resource $entry
87-
*/
88-
function ldap_first_attribute($ldap, $entry): string|false {}
58+
function ldap_first_attribute(LDAP $ldap, LDAPResultEntry $entry): string|false {}
8959

90-
/**
91-
* @param resource $ldap
92-
* @param resource $entry
93-
*/
94-
function ldap_next_attribute($ldap, $entry): string|false {}
60+
function ldap_next_attribute(LDAP $ldap, LDAPResultEntry $entry): string|false {}
9561

96-
/**
97-
* @param resource $ldap
98-
* @param resource $entry
99-
*/
100-
function ldap_get_attributes($ldap, $entry): array {}
62+
function ldap_get_attributes(LDAP $ldap, LDAPResultEntry $entry): array {}
10163

102-
/**
103-
* @param resource $ldap
104-
* @param resource $entry
105-
*/
106-
function ldap_get_values_len($ldap, $entry, string $attribute): array|false {}
64+
function ldap_get_values_len(LDAP $ldap, LDAPResultEntry $entry, string $attribute): array|false {}
10765

108-
/**
109-
* @param resource $ldap
110-
* @param resource $entry
111-
* @alias ldap_get_values_len
112-
*/
113-
function ldap_get_values($ldap, $entry, string $attribute): array|false {}
66+
/** @alias ldap_get_values_len */
67+
function ldap_get_values(LDAP $ldap, LDAPResultEntry $entry, string $attribute): array|false {}
11468

115-
/**
116-
* @param resource $ldap
117-
* @param resource $entry
118-
*/
119-
function ldap_get_dn($ldap, $entry): string|false {}
69+
function ldap_get_dn(LDAP $ldap, LDAPResultEntry $entry): string|false {}
12070

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

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

125-
/** @param resource $ldap */
126-
function ldap_add($ldap, string $dn, array $entry, ?array $controls = null): bool {}
75+
function ldap_add(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
12776

128-
/**
129-
* @param resource $ldap
130-
* @return resource|false
131-
*/
132-
function ldap_add_ext($ldap, string $dn, array $entry, ?array $controls = null) {}
77+
function ldap_add_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
13378

134-
/** @param resource $ldap */
135-
function ldap_delete($ldap, string $dn, ?array $controls = null): bool {}
79+
function ldap_delete(LDAP $ldap, string $dn, ?array $controls = null): bool {}
13680

137-
/**
138-
* @param resource $ldap
139-
* @return resource|false
140-
*/
141-
function ldap_delete_ext($ldap, string $dn, ?array $controls = null) {}
81+
function ldap_delete_ext(LDAP $ldap, string $dn, ?array $controls = null): LDAPResult|false {}
14282

143-
/** @param resource $ldap */
144-
function ldap_modify_batch($ldap, string $dn, array $modifications_info, ?array $controls = null): bool {}
83+
function ldap_modify_batch(LDAP $ldap, string $dn, array $modifications_info, ?array $controls = null): bool {}
14584

146-
/** @param resource $ldap */
147-
function ldap_mod_add($ldap, string $dn, array $entry, ?array $controls = null): bool {}
85+
function ldap_mod_add(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
14886

149-
/**
150-
* @param resource $ldap
151-
* @return resource|false
152-
*/
153-
function ldap_mod_add_ext($ldap, string $dn, array $entry, ?array $controls = null) {}
87+
function ldap_mod_add_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
15488

155-
/** @param resource $ldap */
156-
function ldap_mod_replace($ldap, string $dn, array $entry, ?array $controls = null): bool {}
89+
function ldap_mod_replace(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
15790

158-
/**
159-
* @param resource $ldap
160-
* @alias ldap_mod_replace
161-
*/
162-
function ldap_modify($ldap, string $dn, array $entry, ?array $controls = null): bool {}
91+
/** @alias ldap_mod_replace */
92+
function ldap_modify(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
16393

164-
/**
165-
* @param resource $ldap
166-
* @return resource|false
167-
*/
168-
function ldap_mod_replace_ext($ldap, string $dn, array $entry, ?array $controls = null) {}
94+
function ldap_mod_replace_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
16995

170-
/** @param resource $ldap */
171-
function ldap_mod_del($ldap, string $dn, array $entry, ?array $controls = null): bool {}
96+
function ldap_mod_del(LDAP $ldap, string $dn, array $entry, ?array $controls = null): bool {}
17297

173-
/**
174-
* @param resource $ldap
175-
* @return resource|false
176-
*/
177-
function ldap_mod_del_ext($ldap, string $dn, array $entry, ?array $controls = null) {}
98+
function ldap_mod_del_ext(LDAP $ldap, string $dn, array $entry, ?array $controls = null): LDAPResult|false {}
17899

179-
/** @param resource $ldap */
180-
function ldap_errno($ldap): int {}
100+
function ldap_errno(LDAP $ldap): int {}
181101

182-
/** @param resource $ldap */
183-
function ldap_error($ldap): string {}
102+
function ldap_error(LDAP $ldap): string {}
184103

185104
function ldap_err2str(int $errno): string {}
186105

187-
/** @param resource $ldap */
188-
function ldap_compare($ldap, string $dn, string $attribute, string $value, ?array $controls = null): bool|int {}
106+
function ldap_compare(LDAP $ldap, string $dn, string $attribute, string $value, ?array $controls = null): bool|int {}
189107

190108
#if (LDAP_API_VERSION > 2000) || defined(HAVE_ORALDAP)
191-
/** @param resource $ldap */
192-
function ldap_rename($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): bool {}
193-
194-
/**
195-
* @param resource $ldap
196-
* @return resource|false
197-
*/
198-
function ldap_rename_ext($ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null) {}
109+
function ldap_rename(LDAP $ldap, string $dn, string $new_rdn, string $new_parent, bool $delete_old_rdn, ?array $controls = null): bool {}
199110

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

201113
/**
202-
* @param resource $ldap
203114
* @param array|string|int $value
204115
*/
205-
function ldap_get_option($ldap, int $option, &$value = null): bool {}
116+
function ldap_get_option(LDAP $ldap, int $option, &$value = null): bool {}
206117

207-
/**
208-
* @param resource|null $ldap
209-
* @param array|string|int|bool $value
210-
*/
211-
function ldap_set_option($ldap, int $option, $value): bool {}
118+
/** @param array|string|int|bool $value */
119+
function ldap_set_option(?LDAP $ldap, int $option, $value): bool {}
212120

213-
/**
214-
* @param resource $ldap
215-
* @param resource $result
216-
*/
217-
function ldap_count_references($ldap, $result): int {}
121+
function ldap_count_references(LDAP $ldap, LDAPResult $result): int {}
218122

219-
/**
220-
* @param resource $ldap
221-
* @param resource $result
222-
* @return resource|false
223-
*/
224-
function ldap_first_reference($ldap, $result) {}
123+
function ldap_first_reference(LDAP $ldap, LDAPResult $result): LDAPResultEntry|false {}
225124

226-
/**
227-
* @param resource $ldap
228-
* @param resource $entry
229-
* @return resource|false
230-
*/
231-
function ldap_next_reference($ldap, $entry) {}
125+
function ldap_next_reference(LDAP $ldap, LDAPResultEntry $entry): LDAPResultEntry|false {}
232126

233127
#ifdef HAVE_LDAP_PARSE_REFERENCE
234-
/**
235-
* @param resource $ldap
236-
* @param resource $entry
237-
* @param array $referrals
238-
*/
239-
function ldap_parse_reference($ldap, $entry, &$referrals): bool {}
128+
/** @param array $referrals */
129+
function ldap_parse_reference(LDAP $ldap, LDAPResultEntry $entry, &$referrals): bool {}
240130
#endif
241131

242132
#ifdef HAVE_LDAP_PARSE_RESULT
243133
/**
244-
* @param resource $ldap
245-
* @param resource $result
246134
* @param int $error_code
247135
* @param string $matched_dn
248136
* @param string $error_message
249137
* @param array $referrals
250138
* @param array $controls
251139
*/
252-
function ldap_parse_result($ldap, $result, &$error_code, &$matched_dn = null, &$error_message = null, &$referrals = null, &$controls = null): bool {}
140+
function ldap_parse_result(LDAP $ldap, LDAPResult $result, &$error_code, &$matched_dn = null, &$error_message = null, &$referrals = null, &$controls = null): bool {}
253141
#endif
254142
#endif
255143

256144
#if defined(LDAP_API_FEATURE_X_OPENLDAP) && defined(HAVE_3ARG_SETREBINDPROC)
257-
/** @param resource $ldap */
258-
function ldap_set_rebind_proc($ldap, ?callable $callback): bool {}
145+
function ldap_set_rebind_proc(LDAP $ldap, ?callable $callback): bool {}
259146
#endif
260147

261148
#ifdef HAVE_LDAP_START_TLS_S
262-
/** @param resource $ldap */
263-
function ldap_start_tls($ldap): bool {}
149+
function ldap_start_tls(LDAP $ldap): bool {}
264150
#endif
265151

266152
function ldap_escape(string $value, string $ignore = "", int $flags = 0): string {}
@@ -274,39 +160,32 @@ function ldap_8859_to_t61(string $value): string|false {}
274160

275161
#ifdef HAVE_LDAP_EXTENDED_OPERATION_S
276162
/**
277-
* @param resource $ldap
278163
* @param string $response_data
279164
* @param string $response_oid
280-
* @return resource|bool
281165
*/
282-
function ldap_exop($ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = UNKNOWN, &$response_oid = null) {}
166+
function ldap_exop(LDAP $ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = UNKNOWN, &$response_oid = null): LDAPResult|bool {}
283167
#endif
284168

285169
#ifdef HAVE_LDAP_PASSWD
286170
/**
287-
* @param resource $ldap
288171
* @param array $controls
289172
*/
290-
function ldap_exop_passwd($ldap, string $user = "", string $old_password = "", string $new_password = "", &$controls = null): string|bool {}
173+
function ldap_exop_passwd(LDAP $ldap, string $user = "", string $old_password = "", string $new_password = "", &$controls = null): string|bool {}
291174
#endif
292175

293176

294177
#ifdef HAVE_LDAP_WHOAMI_S
295-
/** @param resource $ldap */
296-
function ldap_exop_whoami($ldap): string|false {}
178+
function ldap_exop_whoami(LDAP $ldap): string|false {}
297179
#endif
298180

299181
#ifdef HAVE_LDAP_REFRESH_S
300-
/** @param resource $ldap */
301-
function ldap_exop_refresh($ldap, string $dn, int $ttl): int|false {}
182+
function ldap_exop_refresh(LDAP $ldap, string $dn, int $ttl): int|false {}
302183
#endif
303184

304185
#ifdef HAVE_LDAP_PARSE_EXTENDED_RESULT
305186
/**
306-
* @param resource $ldap
307-
* @param resource $result
308187
* @param string $response_data
309188
* @param string $response_oid
310189
*/
311-
function ldap_parse_exop($ldap, $result, &$response_data = null, &$response_oid = null): bool {}
190+
function ldap_parse_exop(LDAP $ldap, LDAPResult $result, &$response_data = null, &$response_oid = null): bool {}
312191
#endif

0 commit comments

Comments
 (0)