Resolve `@mixin` tags that name a template parameter, using concrete generic arguments provided at a call site. During [`PHPDocProvider::provide`], mixin names that are template parameters (e.g. `@mixin TWraps`) cannot be resolved because the concrete type arguments are not yet known — they are applied later by [`apply_generic_args`](crate::inheritance::apply_generic_args). This function fills th
(
original_class: &ClassInfo,
template_subs: &HashMap<String, PhpType>,
class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
)
| 808 | /// merged into the substituted class via |
| 809 | /// [`merge_virtual_members`](super::merge_virtual_members). |
| 810 | pub fn resolve_template_param_mixins( |
| 811 | original_class: &ClassInfo, |
| 812 | template_subs: &HashMap<String, PhpType>, |
| 813 | class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>, |
| 814 | ) -> super::VirtualMembers { |
| 815 | if template_subs.is_empty() || original_class.mixins.is_empty() { |
| 816 | return super::VirtualMembers { |
| 817 | methods: Vec::new(), |
| 818 | properties: Vec::new(), |
| 819 | constants: Vec::new(), |
| 820 | }; |
| 821 | } |
| 822 | |
| 823 | // Only process mixins whose name is a template parameter — the |
| 824 | // rest were already resolved during `PHPDocProvider::provide`. |
| 825 | let template_mixins: Vec<Atom> = original_class |
| 826 | .mixins |
| 827 | .iter() |
| 828 | .filter(|m| { |
| 829 | original_class |
| 830 | .template_params |
| 831 | .iter() |
| 832 | .any(|t| t.as_str() == m.as_str()) |
| 833 | }) |
| 834 | .copied() |
| 835 | .collect(); |
| 836 | |
| 837 | if template_mixins.is_empty() { |
| 838 | return super::VirtualMembers { |
| 839 | methods: Vec::new(), |
| 840 | properties: Vec::new(), |
| 841 | constants: Vec::new(), |
| 842 | }; |
| 843 | } |
| 844 | |
| 845 | let dedup = MixinDedup { |
| 846 | methods: HashSet::new(), |
| 847 | properties: HashSet::new(), |
| 848 | constants: HashSet::new(), |
| 849 | }; |
| 850 | |
| 851 | let mut collector = MixinCollector { |
| 852 | methods: Vec::new(), |
| 853 | properties: Vec::new(), |
| 854 | constants: Vec::new(), |
| 855 | dedup, |
| 856 | }; |
| 857 | |
| 858 | collect_mixin_members( |
| 859 | &template_mixins, |
| 860 | &original_class.mixin_generics, |
| 861 | class_loader, |
| 862 | &mut collector, |
| 863 | template_subs, |
| 864 | 0, |
| 865 | None, |
| 866 | ); |
| 867 |
no test coverage detected