MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / resolve_template_param_mixins

Function resolve_template_param_mixins

src/virtual_members/phpdoc.rs:810–873  ·  view source on GitHub ↗

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>>,
)

Source from the content-addressed store, hash-verified

808/// merged into the substituted class via
809/// [`merge_virtual_members`](super::merge_virtual_members).
810pub 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

Callers 2

resolve_named_typeFunction · 0.85

Calls 5

collect_mixin_membersFunction · 0.85
filterMethod · 0.80
iterMethod · 0.80
as_strMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected