@@ -192,18 +192,22 @@ impl FunctionEntry {
192
192
IS_OBJECT ,
193
193
return_type. allow_null ,
194
194
) ) ,
195
- ReturnTypeHint :: Callable => Some ( phper_zend_begin_arg_with_return_type_info_ex (
196
- return_type. ret_by_ref ,
197
- require_arg_count,
198
- IS_CALLABLE ,
199
- return_type. allow_null ,
200
- ) ) ,
201
- ReturnTypeHint :: Iterable => Some ( phper_zend_begin_arg_with_return_type_info_ex (
202
- return_type. ret_by_ref ,
203
- require_arg_count,
204
- IS_ITERABLE ,
205
- return_type. allow_null ,
206
- ) ) ,
195
+ ReturnTypeHint :: Callable => {
196
+ Some ( phper_zend_begin_arg_with_return_type_info_ex (
197
+ return_type. ret_by_ref ,
198
+ require_arg_count,
199
+ IS_CALLABLE ,
200
+ return_type. allow_null ,
201
+ ) )
202
+ }
203
+ ReturnTypeHint :: Iterable => {
204
+ Some ( phper_zend_begin_arg_with_return_type_info_ex (
205
+ return_type. ret_by_ref ,
206
+ require_arg_count,
207
+ IS_ITERABLE ,
208
+ return_type. allow_null ,
209
+ ) )
210
+ }
207
211
ReturnTypeHint :: Mixed => {
208
212
if PHP_MAJOR_VERSION < 8 {
209
213
None
@@ -217,7 +221,9 @@ impl FunctionEntry {
217
221
}
218
222
}
219
223
ReturnTypeHint :: Never => {
220
- if PHP_MAJOR_VERSION < 8 || ( PHP_MAJOR_VERSION == 8 && PHP_MINOR_VERSION <= 1 ) {
224
+ if PHP_MAJOR_VERSION < 8
225
+ || ( PHP_MAJOR_VERSION == 8 && PHP_MINOR_VERSION <= 1 )
226
+ {
221
227
None
222
228
} else {
223
229
Some ( phper_zend_begin_arg_with_return_type_info_ex (
@@ -249,10 +255,10 @@ impl FunctionEntry {
249
255
None
250
256
} ;
251
257
252
- infos. push ( return_info . unwrap_or_else ( || {
253
- phper_zend_begin_arg_info_ex ( false , require_arg_count )
254
- } ) ) ;
255
-
258
+ infos. push (
259
+ return_info
260
+ . unwrap_or_else ( || phper_zend_begin_arg_info_ex ( false , require_arg_count ) ) ,
261
+ ) ;
256
262
257
263
for arg in arguments {
258
264
let default_value_ptr = arg
@@ -262,57 +268,105 @@ impl FunctionEntry {
262
268
. unwrap_or ( std:: ptr:: null ( ) ) ;
263
269
let arg_info = if let Some ( ref type_hint) = arg. type_hint {
264
270
match type_hint {
265
- ArgumentTypeHint :: Null => Some (
266
- phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , IS_NULL , true , default_value_ptr)
267
- ) ,
268
- ArgumentTypeHint :: Bool => Some (
269
- phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , _IS_BOOL, arg. nullable , default_value_ptr)
270
- ) ,
271
- ArgumentTypeHint :: Int => Some (
272
- phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , IS_LONG , arg. nullable , default_value_ptr)
273
- ) ,
274
- ArgumentTypeHint :: Float => Some (
275
- phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , IS_DOUBLE , arg. nullable , default_value_ptr)
276
- ) ,
277
- ArgumentTypeHint :: String => Some (
278
- phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , IS_STRING , arg. nullable , default_value_ptr)
279
- ) ,
280
- ArgumentTypeHint :: Array => Some (
281
- phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , IS_ARRAY , arg. nullable , default_value_ptr)
282
- ) ,
271
+ ArgumentTypeHint :: Null => Some ( phper_zend_arg_info_with_type (
272
+ arg. pass_by_ref ,
273
+ arg. name . as_ptr ( ) ,
274
+ IS_NULL ,
275
+ true ,
276
+ default_value_ptr,
277
+ ) ) ,
278
+ ArgumentTypeHint :: Bool => Some ( phper_zend_arg_info_with_type (
279
+ arg. pass_by_ref ,
280
+ arg. name . as_ptr ( ) ,
281
+ _IS_BOOL,
282
+ arg. nullable ,
283
+ default_value_ptr,
284
+ ) ) ,
285
+ ArgumentTypeHint :: Int => Some ( phper_zend_arg_info_with_type (
286
+ arg. pass_by_ref ,
287
+ arg. name . as_ptr ( ) ,
288
+ IS_LONG ,
289
+ arg. nullable ,
290
+ default_value_ptr,
291
+ ) ) ,
292
+ ArgumentTypeHint :: Float => Some ( phper_zend_arg_info_with_type (
293
+ arg. pass_by_ref ,
294
+ arg. name . as_ptr ( ) ,
295
+ IS_DOUBLE ,
296
+ arg. nullable ,
297
+ default_value_ptr,
298
+ ) ) ,
299
+ ArgumentTypeHint :: String => Some ( phper_zend_arg_info_with_type (
300
+ arg. pass_by_ref ,
301
+ arg. name . as_ptr ( ) ,
302
+ IS_STRING ,
303
+ arg. nullable ,
304
+ default_value_ptr,
305
+ ) ) ,
306
+ ArgumentTypeHint :: Array => Some ( phper_zend_arg_info_with_type (
307
+ arg. pass_by_ref ,
308
+ arg. name . as_ptr ( ) ,
309
+ IS_ARRAY ,
310
+ arg. nullable ,
311
+ default_value_ptr,
312
+ ) ) ,
283
313
ArgumentTypeHint :: Object => Some (
284
- phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , IS_OBJECT , arg. nullable , std:: ptr:: null ( ) ) //default value not supported
314
+ phper_zend_arg_info_with_type (
315
+ arg. pass_by_ref ,
316
+ arg. name . as_ptr ( ) ,
317
+ IS_OBJECT ,
318
+ arg. nullable ,
319
+ std:: ptr:: null ( ) ,
320
+ ) , // default value not supported
285
321
) ,
286
322
ArgumentTypeHint :: Callable => Some (
287
- phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , IS_CALLABLE , arg. nullable , std:: ptr:: null ( ) ) //default value not supported
288
- ) ,
289
- ArgumentTypeHint :: Iterable => Some (
290
- phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , IS_ITERABLE , arg. nullable , default_value_ptr)
323
+ phper_zend_arg_info_with_type (
324
+ arg. pass_by_ref ,
325
+ arg. name . as_ptr ( ) ,
326
+ IS_CALLABLE ,
327
+ arg. nullable ,
328
+ std:: ptr:: null ( ) ,
329
+ ) , // default value not supported
291
330
) ,
331
+ ArgumentTypeHint :: Iterable => Some ( phper_zend_arg_info_with_type (
332
+ arg. pass_by_ref ,
333
+ arg. name . as_ptr ( ) ,
334
+ IS_ITERABLE ,
335
+ arg. nullable ,
336
+ default_value_ptr,
337
+ ) ) ,
292
338
ArgumentTypeHint :: Mixed => {
293
339
if PHP_MAJOR_VERSION < 8 {
294
340
None
295
341
} else {
296
- Some ( phper_zend_arg_info_with_type ( arg. pass_by_ref , arg. name . as_ptr ( ) , IS_MIXED , true , default_value_ptr) )
342
+ Some ( phper_zend_arg_info_with_type (
343
+ arg. pass_by_ref ,
344
+ arg. name . as_ptr ( ) ,
345
+ IS_MIXED ,
346
+ true ,
347
+ default_value_ptr,
348
+ ) )
297
349
}
298
- } ,
350
+ }
299
351
ArgumentTypeHint :: ClassEntry ( class_name) => {
300
- let c_class_name = CString :: new ( class_name. clone ( ) ) . expect ( "CString::new failed" ) ;
352
+ let c_class_name =
353
+ CString :: new ( class_name. clone ( ) ) . expect ( "CString::new failed" ) ;
301
354
Some ( phper_zend_arg_obj_info (
302
355
arg. pass_by_ref ,
303
356
arg. name . as_ptr ( ) ,
304
357
c_class_name. as_ptr ( ) ,
305
- arg. nullable
358
+ arg. nullable ,
306
359
) )
307
- } ,
360
+ }
308
361
}
309
362
} else {
310
363
None
311
364
} ;
312
365
313
- infos. push ( arg_info. unwrap_or_else ( || {
314
- phper_zend_arg_info ( arg. pass_by_ref , arg. name . as_ptr ( ) )
315
- } ) ) ;
366
+ infos
367
+ . push ( arg_info. unwrap_or_else ( || {
368
+ phper_zend_arg_info ( arg. pass_by_ref , arg. name . as_ptr ( ) )
369
+ } ) ) ;
316
370
}
317
371
318
372
infos. push ( zeroed :: < zend_internal_arg_info > ( ) ) ;
@@ -540,7 +594,8 @@ impl Argument {
540
594
self
541
595
}
542
596
543
- /// Argument default value. Example: "'a-string'", "A_CONST", "42", "[0=>'zero']"
597
+ /// Argument default value. Example: "'a-string'", "A_CONST", "42",
598
+ /// "[0=>'zero']"
544
599
pub fn with_default_value ( mut self , default_value : CString ) -> Self {
545
600
self . default_value = Some ( default_value) ;
546
601
self . required = false ; // arg with default value does not count towards required arg count
0 commit comments