10
10
11
11
const CURL_DOC_FILE = 'https://curl.haxx.se/libcurl/c/symbols-in-versions.html ' ;
12
12
13
- const SOURCE_FILE = __DIR__ . '/interface.c ' ;
13
+ const SOURCE_FILE = __DIR__ . '/curl_arginfo.h ' ;
14
14
15
15
const MIN_SUPPORTED_CURL_VERSION = '7.29.0 ' ;
16
16
17
- const IGNORED_CONSTANTS = [
17
+ const IGNORED_CURL_CONSTANTS = [
18
18
'CURLOPT_PROGRESSDATA ' ,
19
- 'CURLOPT_XFERINFODATA '
19
+ 'CURLOPT_XFERINFODATA ' ,
20
+ ];
21
+
22
+ const IGNORED_PHP_CONSTANTS = [
23
+ 'CURLOPT_BINARYTRANSFER ' ,
24
+ 'CURLOPT_RETURNTRANSFER ' ,
25
+ 'CURLOPT_SAFE_UPLOAD ' ,
20
26
];
21
27
22
28
const CONSTANTS_REGEX_PATTERN = '~^CURL(?:OPT|_VERSION)_[A-Z0-9_]+$~ ' ;
23
29
30
+ /**
31
+ * A simple helper to create ASCII tables.
32
+ * It assumes that the same number of columns is always given to add().
33
+ */
34
+ class AsciiTable
35
+ {
36
+ /**
37
+ * @var array
38
+ */
39
+ private $ values = [];
40
+
41
+ /**
42
+ * @var array
43
+ */
44
+ private $ length = [];
45
+
46
+ /**
47
+ * @var int
48
+ */
49
+ private $ padding = 4 ;
50
+
51
+ /**
52
+ * @param string[] $values
53
+ *
54
+ * @return void
55
+ */
56
+ public function add (string ...$ values ) : void
57
+ {
58
+ $ this ->values [] = $ values ;
59
+
60
+ foreach ($ values as $ key => $ value ) {
61
+ $ length = strlen ($ value );
62
+
63
+ if (isset ($ this ->length [$ key ])) {
64
+ $ this ->length [$ key ] = max ($ this ->length [$ key ], $ length );
65
+ } else {
66
+ $ this ->length [$ key ] = $ length ;
67
+ }
68
+ }
69
+ }
70
+
71
+ /**
72
+ * @return string
73
+ */
74
+ public function __toString () : string
75
+ {
76
+ $ result = '' ;
77
+
78
+ foreach ($ this ->values as $ values ) {
79
+ foreach ($ values as $ key => $ value ) {
80
+ if ($ key !== 0 ) {
81
+ $ result .= str_repeat (' ' , $ this ->padding );
82
+ }
83
+
84
+ $ result .= str_pad ($ value , $ this ->length [$ key ]);
85
+ }
86
+
87
+ $ result .= "\n" ;
88
+ }
89
+
90
+ return $ result ;
91
+ }
92
+ }
93
+
24
94
$ curlConstants = getCurlConstants ();
25
95
$ sourceConstants = getSourceConstants ();
26
96
@@ -161,7 +231,7 @@ function getCurlConstants() : array
161
231
$ deprecated = $ match [3 ] ?? null ;
162
232
$ removed = $ match [4 ] ?? null ;
163
233
164
- if (in_array ($ name , IGNORED_CONSTANTS , true ) || !preg_match (CONSTANTS_REGEX_PATTERN , $ name )) {
234
+ if (in_array ($ name , IGNORED_CURL_CONSTANTS , true ) || !preg_match (CONSTANTS_REGEX_PATTERN , $ name )) {
165
235
// not a wanted constant
166
236
continue ;
167
237
}
@@ -187,7 +257,7 @@ function getSourceConstants() : array
187
257
{
188
258
$ source = file_get_contents (SOURCE_FILE );
189
259
190
- preg_match_all ('/REGISTER_CURL_CONSTANT\(([A-Za-z0-9_]+) \)/ ' , $ source , $ matches );
260
+ preg_match_all ('/REGISTER_LONG_CONSTANT\(\"\w+\", (\w+), .+ \)/ ' , $ source , $ matches );
191
261
192
262
$ constants = [];
193
263
@@ -196,7 +266,7 @@ function getSourceConstants() : array
196
266
continue ;
197
267
}
198
268
199
- if (!preg_match (CONSTANTS_REGEX_PATTERN , $ name )) {
269
+ if (in_array ( $ name , IGNORED_PHP_CONSTANTS , true ) || !preg_match (CONSTANTS_REGEX_PATTERN , $ name )) {
200
270
// not a wanted constant
201
271
continue ;
202
272
}
@@ -254,67 +324,3 @@ function getHexVersion(string $version) : string
254
324
255
325
return $ hex ;
256
326
}
257
-
258
- /**
259
- * A simple helper to create ASCII tables.
260
- * It assumes that the same number of columns is always given to add().
261
- */
262
- class AsciiTable
263
- {
264
- /**
265
- * @var array
266
- */
267
- private $ values = [];
268
-
269
- /**
270
- * @var array
271
- */
272
- private $ length = [];
273
-
274
- /**
275
- * @var int
276
- */
277
- private $ padding = 4 ;
278
-
279
- /**
280
- * @param string[] $values
281
- *
282
- * @return void
283
- */
284
- public function add (string ...$ values ) : void
285
- {
286
- $ this ->values [] = $ values ;
287
-
288
- foreach ($ values as $ key => $ value ) {
289
- $ length = strlen ($ value );
290
-
291
- if (isset ($ this ->length [$ key ])) {
292
- $ this ->length [$ key ] = max ($ this ->length [$ key ], $ length );
293
- } else {
294
- $ this ->length [$ key ] = $ length ;
295
- }
296
- }
297
- }
298
-
299
- /**
300
- * @return string
301
- */
302
- public function __toString () : string
303
- {
304
- $ result = '' ;
305
-
306
- foreach ($ this ->values as $ values ) {
307
- foreach ($ values as $ key => $ value ) {
308
- if ($ key !== 0 ) {
309
- $ result .= str_repeat (' ' , $ this ->padding );
310
- }
311
-
312
- $ result .= str_pad ($ value , $ this ->length [$ key ]);
313
- }
314
-
315
- $ result .= "\n" ;
316
- }
317
-
318
- return $ result ;
319
- }
320
- }
0 commit comments