-
Notifications
You must be signed in to change notification settings - Fork 20
/
hprose_common.c
793 lines (746 loc) · 23.2 KB
/
hprose_common.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* hprose_common.c *
* *
* hprose common for pecl source file. *
* *
* LastModified: Jun 10, 2016 *
* Author: Ma Bingyao <[email protected]> *
* *
\**********************************************************/
#include "hprose_common.h"
#if PHP_API_VERSION >= 20100412
#if PHP_MAJOR_VERSION < 7
HashTable *php_hprose_get_gc(zval *object, zval ***table, int *n TSRMLS_DC) {
*table = NULL;
*n = 0;
return zend_std_get_properties(object TSRMLS_CC);
}
#else
HashTable *php_hprose_get_gc(zval *object, zval **table, int *n) {
*table = NULL;
*n = 0;
return zend_std_get_properties(object);
}
#endif
#endif
zend_fcall_info_cache __get_fcall_info_cache(zval *obj, char *name, int32_t len TSRMLS_DC) {
zend_fcall_info_cache fcc = {0};
char *fname, *lcname = NULL;
zend_function *fptr;
#if PHP_VERSION_ID < 70100
zend_class_entry *scope = EG(scope);
#else
zend_class_entry *scope = EG(fake_scope) ? EG(fake_scope) : zend_get_executed_scope();
#endif
if (obj == NULL && (fname = strstr(name, "::")) == NULL) {
char *nsname;
lcname = zend_str_tolower_dup(name, len);
nsname = lcname;
if (lcname[0] == '\\') {
nsname = &lcname[1];
--len;
}
#if PHP_MAJOR_VERSION < 7
if (zend_hash_find(EG(function_table), nsname, len + 1, (void **)&fptr) == FAILURE) {
#else
if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, len)) == NULL) {
#endif
efree(lcname);
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Function %s() does not exist", name);
return fcc;
}
fcc.function_handler = fptr;
fcc.calling_scope = scope;
#if PHP_MAJOR_VERSION < 7
#if PHP_API_VERSION < 20090626
fcc.object_pp = NULL;
#else
fcc.called_scope = NULL;
fcc.object_ptr = NULL;
#endif
#else
fcc.called_scope = NULL;
fcc.object = NULL;
#endif
}
#if PHP_API_VERSION >= 20090626
else if (obj && Z_TYPE_P(obj) == IS_OBJECT &&
instanceof_function(Z_OBJCE_P(obj), zend_ce_closure TSRMLS_CC) &&
(fptr = (zend_function*)zend_get_closure_method_def(obj TSRMLS_CC)) != NULL) {
fcc.function_handler = fptr;
fcc.calling_scope = scope;
#if PHP_MAJOR_VERSION < 7
fcc.called_scope = NULL;
fcc.object_ptr = NULL;
#else
fcc.called_scope = NULL;
fcc.object = NULL;
#endif
}
#endif
else {
int32_t flen, clen;
zend_class_entry *ce;
#if PHP_MAJOR_VERSION < 7
char *cname;
zend_class_entry **pce;
#else
zend_string *cname;
#endif
if (obj == NULL) {
clen = fname - name;
#if PHP_MAJOR_VERSION < 7
cname = estrndup(name, clen);
#else
cname = zend_string_init(name, clen, 0);
#endif
flen = len - (clen + 2);
fname += 2;
}
else if (Z_TYPE_P(obj) == IS_STRING) {
clen = Z_STRLEN_P(obj);
#if PHP_MAJOR_VERSION < 7
cname = estrndup(Z_STRVAL_P(obj), clen);
#else
cname = zend_string_init(Z_STRVAL_P(obj), clen, 0);
#endif
flen = len;
fname = name;
obj = NULL;
}
else if (Z_TYPE_P(obj) != IS_OBJECT) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"The parameter obj is expected to be either a string or an object");
return fcc;
}
if (obj == NULL) {
#if PHP_MAJOR_VERSION < 7
if (zend_lookup_class(cname, clen, &pce TSRMLS_CC) == FAILURE) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Class %s does not exist", cname);
efree(cname);
return fcc;
}
efree(cname);
ce = *pce;
#else
if ((ce = zend_lookup_class(cname)) == NULL) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Class %s does not exist", cname->val);
zend_string_release(cname);
return fcc;
}
zend_string_release(cname);
#endif
}
else {
ce = Z_OBJCE_P(obj);
fname = name;
flen = len;
}
lcname = zend_str_tolower_dup(fname, flen);
#if PHP_MAJOR_VERSION < 7
if (zend_hash_find(&ce->function_table, lcname, flen + 1, (void **) &fptr) == FAILURE) {
efree(lcname);
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Method %s::%s() does not exist", ce->name, fname);
#else
if ((fptr = zend_hash_str_find_ptr(&ce->function_table, lcname, flen)) == NULL) {
efree(lcname);
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Method %s::%s() does not exist", ZSTR_VAL(ce->name), fname);
#endif
return fcc;
}
fcc.function_handler = fptr;
if ((fptr->common.fn_flags & ZEND_ACC_STATIC) || obj == NULL) {
#if PHP_API_VERSION < 20090626
fcc.calling_scope = NULL;
fcc.object_pp = NULL;
#else
fcc.calling_scope = fptr->common.scope;
fcc.called_scope = ce;
#if PHP_MAJOR_VERSION < 7
fcc.object_ptr = NULL;
#else
fcc.object = NULL;
#endif
#endif
}
else {
#if PHP_API_VERSION < 20090626
fcc.calling_scope = Z_OBJCE_P(obj);
fcc.object_pp = &obj;
#else
fcc.calling_scope = Z_OBJCE_P(obj);
fcc.called_scope = ce;
#if PHP_MAJOR_VERSION < 7
fcc.object_ptr = obj;
#else
fcc.object = Z_OBJ_P(obj);
#endif
#endif
}
}
if (lcname) {
efree(lcname);
}
#if PHP_VERSION_ID < 70300
fcc.initialized = 1;
#endif
return fcc;
}
void __function_invoke_args(zend_fcall_info_cache fcc, zval *obj, zval *return_value, zval *param_array TSRMLS_DC) {
#if PHP_MAJOR_VERSION < 7
zval *retval_ptr = NULL;
zval ***params = NULL;
#else
zval retval;
zval *params = NULL, *val;
int i;
#endif
int result;
int argc;
zend_fcall_info fci;
argc = (param_array) ? Z_ARRLEN_P(param_array) : 0;
if (argc) {
#if PHP_MAJOR_VERSION < 7
params = safe_emalloc(sizeof(zval **), argc, 0);
zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC);
params -= argc;
#else
params = safe_emalloc(sizeof(zval), argc, 0);
argc = 0;
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(param_array), val) {
ZVAL_COPY(¶ms[argc], val);
argc++;
} ZEND_HASH_FOREACH_END();
#endif
}
fci.size = sizeof(fci);
#if PHP_VERSION_ID < 70100
fci.function_table = NULL;
fci.symbol_table = NULL;
#endif
#if PHP_MAJOR_VERSION < 7
fci.function_name = NULL;
fci.retval_ptr_ptr = &retval_ptr;
#else
ZVAL_UNDEF(&fci.function_name);
fci.retval = &retval;
#endif
fci.param_count = argc;
fci.params = params;
fci.no_separation = 1;
if (obj != NULL && Z_TYPE_P(obj) == IS_OBJECT) {
#if PHP_API_VERSION < 20090626
fci.object_pp = &obj;
fcc.object_pp = &obj;
#elif PHP_MAJOR_VERSION < 7
fci.object_ptr = obj;
fcc.object_ptr = obj;
#else
fci.object = Z_OBJ_P(obj);
fcc.object = Z_OBJ_P(obj);
#endif
fcc.calling_scope = Z_OBJCE_P(obj);
}
else {
#if PHP_API_VERSION < 20090626
fci.object_pp = fcc.object_pp;
#elif PHP_MAJOR_VERSION < 7
fci.object_ptr = fcc.object_ptr;
#else
fci.object = fcc.object;
#endif
}
#if PHP_MAJOR_VERSION < 7
result = zend_call_function(&fci, &fcc TSRMLS_CC);
if (argc) {
efree(params);
}
if (result == FAILURE) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Invocation of function %s() failed",
fcc.function_handler->common.function_name);
return;
}
if (retval_ptr) {
if (return_value) {
COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
}
else {
zval_ptr_dtor(&retval_ptr);
}
}
#else
result = zend_call_function(&fci, &fcc);
for (i = 0; i < argc; i++) {
zval_ptr_dtor(¶ms[i]);
}
if (argc) {
efree(params);
}
if (result == FAILURE) {
zend_throw_exception_ex(NULL, 0,
"Invocation of function %s() failed",
fcc.function_handler->common.function_name->val);
return;
}
if (Z_TYPE(retval) != IS_UNDEF) {
if (return_value) {
ZVAL_COPY_VALUE(return_value, &retval);
}
else {
zval_ptr_dtor(&retval);
}
}
#endif
}
void __function_invoke(zend_fcall_info_cache fcc, zval *obj, zval *return_value, zend_bool dtor TSRMLS_DC, const char *params_format, ...) {
#if PHP_MAJOR_VERSION < 7
zval *retval_ptr = NULL;
zval ***params = NULL;
#else
zval retval;
zval *params = NULL;
#endif
uint32_t i, argc;
int result;
zend_fcall_info fci;
argc = strlen(params_format);
if (argc) {
#if PHP_MAJOR_VERSION < 7
va_list ap;
va_start(ap, params_format);
params = safe_emalloc(sizeof(zval **), argc, 0);
for (i = 0; i < argc; ++i) {
params[i] = emalloc(sizeof(zval *));
switch (params_format[i]) {
case 's': {
char *str = va_arg(ap, char *);
long len = va_arg(ap, long);
MAKE_STD_ZVAL(*params[i]);
ZVAL_STRINGL(*params[i], str, len, 0);
break;
}
case 'l': {
long l = va_arg(ap, long);
MAKE_STD_ZVAL(*params[i]);
ZVAL_LONG(*params[i], l);
break;
}
case 'd': {
double d = va_arg(ap, double);
MAKE_STD_ZVAL(*params[i]);
ZVAL_DOUBLE(*params[i], d);
break;
}
case 'n': {
MAKE_STD_ZVAL(*params[i]);
ZVAL_NULL(*params[i]);
break;
}
case 'b': {
zend_bool b = va_arg(ap, int);
MAKE_STD_ZVAL(*params[i]);
ZVAL_BOOL(*params[i], b);
break;
}
case 'z': {
zval *v = va_arg(ap, zval *);
if (v) {
Z_ADDREF_P(v);
*params[i] = v;
}
else {
MAKE_STD_ZVAL(*params[i]);
ZVAL_NULL(*params[i]);
}
break;
}
default:
zend_throw_exception_ex(
NULL, 0 TSRMLS_CC,
"Unsupported type:%c in function_invoke",
params_format[i]);
return;
}
}
va_end(ap);
#else
va_list ap;
va_start(ap, params_format);
params = safe_emalloc(sizeof(zval), argc, 0);
for (i = 0; i < argc; ++i) {
switch (params_format[i]) {
case 's': {
char *str = va_arg(ap, char *);
long len = va_arg(ap, long);
ZVAL_STRINGL(¶ms[i], str, len);
break;
}
case 'l': {
long l = va_arg(ap, long);
ZVAL_LONG(¶ms[i], l);
break;
}
case 'd': {
double d = va_arg(ap, double);
ZVAL_DOUBLE(¶ms[i], d);
break;
}
case 'n': {
ZVAL_NULL(¶ms[i]);
break;
}
case 'b': {
zend_bool b = va_arg(ap, int);
ZVAL_BOOL(¶ms[i], b);
break;
}
case 'z': {
zval *v = va_arg(ap, zval *);
if (v) {
ZVAL_COPY(¶ms[i], v);
}
else {
ZVAL_NULL(¶ms[i]);
}
break;
}
default:
zend_throw_exception_ex(
NULL, 0,
"Unsupported type:%c in function_invoke",
params_format[i]);
return;
}
}
va_end(ap);
#endif
}
fci.size = sizeof(fci);
#if PHP_VERSION_ID < 70100
fci.function_table = NULL;
fci.symbol_table = NULL;
#endif
#if PHP_MAJOR_VERSION < 7
fci.function_name = NULL;
fci.retval_ptr_ptr = &retval_ptr;
#else
ZVAL_UNDEF(&fci.function_name);
fci.retval = &retval;
#endif
fci.param_count = argc;
fci.params = params;
fci.no_separation = 1;
if (obj != NULL && Z_TYPE_P(obj) == IS_OBJECT) {
#if PHP_API_VERSION < 20090626
fci.object_pp = &obj;
fcc.object_pp = &obj;
#elif PHP_MAJOR_VERSION < 7
fci.object_ptr = obj;
fcc.object_ptr = obj;
#else
fci.object = Z_OBJ_P(obj);
fcc.object = Z_OBJ_P(obj);
#endif
fcc.calling_scope = Z_OBJCE_P(obj);
}
else {
#if PHP_API_VERSION < 20090626
fci.object_pp = fcc.object_pp;
#elif PHP_MAJOR_VERSION < 7
fci.object_ptr = fcc.object_ptr;
#else
fci.object = fcc.object;
#endif
}
#if PHP_MAJOR_VERSION < 7
result = zend_call_function(&fci, &fcc TSRMLS_CC);
for (i = 0; i < argc; i++) {
if (params_format[i] == 's') {
ZVAL_EMPTY_STRING(*params[i]);
}
zval_ptr_dtor(params[i]);
efree(params[i]);
}
if (argc) {
efree(params);
}
if (result == FAILURE) {
zend_throw_exception_ex(NULL, 0 TSRMLS_CC,
"Invocation of function %s() failed",
fcc.function_handler->common.function_name);
return;
}
if (retval_ptr) {
if (return_value) {
if (return_value != retval_ptr) {
if (dtor) {
zval_dtor(return_value);
}
COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
}
else {
if (dtor) {
zval_ptr_dtor(&retval_ptr);
}
}
}
else {
zval_ptr_dtor(&retval_ptr);
}
}
#else
result = zend_call_function(&fci, &fcc);
for (i = 0; i < argc; i++) {
zval_ptr_dtor(¶ms[i]);
}
if (argc) {
efree(params);
}
if (result == FAILURE) {
zend_throw_exception_ex(NULL, 0,
"Invocation of function %s() failed",
fcc.function_handler->common.function_name->val);
return;
}
if (Z_TYPE(retval) != IS_UNDEF) {
if (return_value) {
if (dtor) {
zval_ptr_dtor(return_value);
}
ZVAL_COPY_VALUE(return_value, &retval);
}
else {
zval_ptr_dtor(&retval);
}
}
#endif
}
zend_class_entry *__create_php_object(char *class_name, int32_t len, zval *return_value TSRMLS_DC, const char *params_format, ...) {
zend_function *constructor;
zend_class_entry *entry;
#if PHP_MAJOR_VERSION < 7
zval *retval_ptr = NULL;
zval ***params = NULL;
#else
zval retval;
zval *params = NULL;
zend_string *classname;
#endif
uint32_t i, argc;
zend_fcall_info fci;
zend_fcall_info_cache fcc;
#if PHP_VERSION_ID < 70100
zend_class_entry *scope = EG(scope);
#else
zend_class_entry *scope = EG(fake_scope) ? EG(fake_scope) : zend_get_executed_scope();
#endif
argc = strlen(params_format);
if (argc) {
#if PHP_MAJOR_VERSION < 7
va_list ap;
va_start(ap, params_format);
params = safe_emalloc(sizeof(zval **), argc, 0);
for (i = 0; i < argc; ++i) {
params[i] = emalloc(sizeof(zval *));
switch (params_format[i]) {
case 's': {
char *str = va_arg(ap, char *);
long len = va_arg(ap, long);
MAKE_STD_ZVAL(*params[i]);
ZVAL_STRINGL(*params[i], str, len, 0);
break;
}
case 'l': {
long l = va_arg(ap, long);
MAKE_STD_ZVAL(*params[i]);
ZVAL_LONG(*params[i], l);
break;
}
case 'd': {
double d = va_arg(ap, double);
MAKE_STD_ZVAL(*params[i]);
ZVAL_DOUBLE(*params[i], d);
break;
}
case 'n': {
MAKE_STD_ZVAL(*params[i]);
ZVAL_NULL(*params[i]);
break;
}
case 'b': {
zend_bool b = va_arg(ap, int);
MAKE_STD_ZVAL(*params[i]);
ZVAL_BOOL(*params[i], b);
break;
}
case 'z': {
zval *v = va_arg(ap, zval *);
if (v) {
Z_ADDREF_P(v);
*params[i] = v;
}
else {
MAKE_STD_ZVAL(*params[i]);
ZVAL_NULL(*params[i]);
}
break;
}
default:
zend_throw_exception_ex(
NULL, 0 TSRMLS_CC,
"Unsupported type:%c in create_php_object",
params_format[i]);
return NULL;
}
}
va_end(ap);
#else
va_list ap;
va_start(ap, params_format);
params = safe_emalloc(sizeof(zval), argc, 0);
for (i = 0; i < argc; ++i) {
switch (params_format[i]) {
case 's': {
char *str = va_arg(ap, char *);
long len = va_arg(ap, long);
ZVAL_STRINGL(¶ms[i], str, len);
break;
}
case 'l': {
long l = va_arg(ap, long);
ZVAL_LONG(¶ms[i], l);
break;
}
case 'd': {
double d = va_arg(ap, double);
ZVAL_DOUBLE(¶ms[i], d);
break;
}
case 'n': {
ZVAL_NULL(¶ms[i]);
break;
}
case 'b': {
zend_bool b = va_arg(ap, int);
ZVAL_BOOL(¶ms[i], b);
break;
}
case 'z': {
zval *v = va_arg(ap, zval *);
if (v) {
ZVAL_COPY(¶ms[i], v);
}
else {
ZVAL_NULL(¶ms[i]);
}
break;
}
default:
zend_throw_exception_ex(
NULL, 0,
"Unsupported type:%c in create_php_object",
params_format[i]);
return NULL;
}
}
va_end(ap);
#endif
}
#if PHP_MAJOR_VERSION < 7
entry = zend_fetch_class(class_name, len, ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC);
object_init_ex(return_value, entry);
constructor = Z_OBJ_HT_P(return_value)->get_constructor(return_value TSRMLS_CC);
if (constructor && constructor->common.num_args >= argc &&
argc >= constructor->common.required_num_args) {
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
fci.function_name = NULL;
fci.symbol_table = NULL;
#if PHP_API_VERSION < 20090626
fci.object_pp = &return_value;
#else
fci.object_ptr = return_value;
#endif
fci.retval_ptr_ptr = &retval_ptr;
fci.param_count = argc;
fci.params = params;
fci.no_separation = 1;
fcc.initialized = 1;
fcc.function_handler = constructor;
fcc.calling_scope = EG(scope);
#if PHP_API_VERSION < 20090626
fcc.object_pp = &return_value;
#else
fcc.called_scope = Z_OBJCE_P(return_value);
fcc.object_ptr = return_value;
#endif
zend_call_function(&fci, &fcc TSRMLS_CC);
for (i = 0; i < argc; i++) {
if (params_format[i] == 's') {
ZVAL_EMPTY_STRING(*params[i]);
}
zval_ptr_dtor(params[i]);
efree(params[i]);
}
if (argc) {
efree(params);
}
if (retval_ptr) {
zval_ptr_dtor(&retval_ptr);
}
}
#else
classname = zend_string_init(class_name, len, 0);
entry = zend_lookup_class(classname);
zend_string_release(classname);
object_init_ex(return_value, entry);
constructor = Z_OBJ_HT_P(return_value)->get_constructor(Z_OBJ_P(return_value));
if (constructor && constructor->common.num_args >= argc &&
argc >= constructor->common.required_num_args) {
fci.size = sizeof(fci);
ZVAL_UNDEF(&fci.function_name);
#if PHP_VERSION_ID < 70100
fci.function_table = EG(function_table);
fci.symbol_table = NULL;
#endif
fci.object = Z_OBJ_P(return_value);
fci.retval = &retval;
fci.param_count = argc;
fci.params = params;
fci.no_separation = 1;
#if PHP_VERSION_ID < 70300
fcc.initialized = 1;
#endif
fcc.function_handler = constructor;
fcc.calling_scope = scope;
fcc.called_scope = Z_OBJCE_P(return_value);
fcc.object = Z_OBJ_P(return_value);
zend_call_function(&fci, &fcc);
for (i = 0; i < argc; i++) {
zval_ptr_dtor(¶ms[i]);
}
if (argc) {
efree(params);
}
if (Z_TYPE(retval) != IS_UNDEF) {
zval_ptr_dtor(&retval);
}
}
#endif
return entry;
}