Build a substitution map for mixin generic resolution by zipping the parent class's `@template` parameters with the type arguments provided Build a substitution map for a directly implemented interface. Maps the interface's template parameters to the concrete types provided in the class's `@implements` generics.
(
class: &ClassInfo,
iface: &ClassInfo,
)
| 879 | /// Maps the interface's template parameters to the concrete types provided |
| 880 | /// in the class's `@implements` generics. |
| 881 | fn build_interface_substitution_map( |
| 882 | class: &ClassInfo, |
| 883 | iface: &ClassInfo, |
| 884 | ) -> HashMap<String, PhpType> { |
| 885 | if iface.template_params.is_empty() { |
| 886 | return HashMap::new(); |
| 887 | } |
| 888 | |
| 889 | let iface_short = short_name(&iface.name); |
| 890 | |
| 891 | let type_args = class |
| 892 | .implements_generics |
| 893 | .iter() |
| 894 | .find(|(name, _)| short_name(name) == iface_short) |
| 895 | .map(|(_, args)| args); |
| 896 | |
| 897 | let type_args = match type_args { |
| 898 | Some(args) => args, |
| 899 | None => return HashMap::new(), |
| 900 | }; |
| 901 | |
| 902 | let mut map = HashMap::new(); |
| 903 | for (i, param_name) in iface.template_params.iter().enumerate() { |
| 904 | if let Some(arg) = type_args.get(i) { |
| 905 | map.insert(param_name.to_string(), arg.clone()); |
| 906 | } |
| 907 | } |
| 908 | map |
| 909 | } |
| 910 | |
| 911 | /// Build a substitution map for an interface's parent interface (interface extends). |
| 912 | /// |