Substitute the type parameters in `t` according to a parallel * (param_names, args) mapping, returning a new arena-allocated CBMType. */
| 3441 | /* Substitute the type parameters in `t` according to a parallel |
| 3442 | * (param_names, args) mapping, returning a new arena-allocated CBMType. */ |
| 3443 | static const CBMType *php_substitute_template(CBMArena *arena, const CBMType *t, |
| 3444 | const char *const *param_names, |
| 3445 | const CBMType *const *args) { |
| 3446 | if (!t || !param_names || !args) |
| 3447 | return t; |
| 3448 | if (t->kind == CBM_TYPE_NAMED && t->data.named.qualified_name) { |
| 3449 | const char *qn = t->data.named.qualified_name; |
| 3450 | for (int i = 0; param_names[i]; i++) { |
| 3451 | if (strcmp(qn, param_names[i]) == 0) { |
| 3452 | return args[i] ? args[i] : t; |
| 3453 | } |
| 3454 | } |
| 3455 | return t; |
| 3456 | } |
| 3457 | if (t->kind == CBM_TYPE_TEMPLATE) { |
| 3458 | /* Recurse into args. */ |
| 3459 | int n = t->data.template_type.arg_count; |
| 3460 | if (n <= 0 || !t->data.template_type.template_args) |
| 3461 | return t; |
| 3462 | const CBMType **new_args = |
| 3463 | (const CBMType **)cbm_arena_alloc(arena, (size_t)(n + 1) * sizeof(*new_args)); |
| 3464 | if (!new_args) |
| 3465 | return t; |
| 3466 | for (int i = 0; i < n; i++) { |
| 3467 | new_args[i] = php_substitute_template(arena, t->data.template_type.template_args[i], |
| 3468 | param_names, args); |
| 3469 | } |
| 3470 | new_args[n] = NULL; |
| 3471 | return cbm_type_template(arena, t->data.template_type.template_name, new_args, n); |
| 3472 | } |
| 3473 | return t; |
| 3474 | } |
| 3475 | |
| 3476 | static void apply_phpdoc_class_tags(PHPLSPContext *ctx, CBMTypeRegistry *reg, const char *class_qn, |
| 3477 | const char *docstring, php_class_fields_t *out_fields) { |
no test coverage detected