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

Function class_dependencies

src/toposort.rs:27–65  ·  view source on GitHub ↗

Collect dependency edges for a single class. Returns the FQNs of all classes that `class` directly depends on for inheritance resolution: parent class, used traits, implemented interfaces, and class names referenced in `@extends`, `@implements`, and `@use` generic arguments.

(class: &ClassInfo)

Source from the content-addressed store, hash-verified

25/// interfaces, and class names referenced in `@extends`, `@implements`,
26/// and `@use` generic arguments.
27fn class_dependencies(class: &ClassInfo) -> Vec<String> {
28 let mut deps = Vec::new();
29
30 if let Some(parent) = class.parent_class {
31 deps.push(parent.to_string());
32 }
33
34 for trait_name in &class.used_traits {
35 deps.push(trait_name.to_string());
36 }
37
38 for iface in &class.interfaces {
39 deps.push(iface.to_string());
40 }
41
42 // Generic argument class names from @extends, @implements, @use.
43 // These reference classes whose template parameters need to be
44 // resolved before the current class can substitute them.
45 for (name, _) in &class.extends_generics {
46 deps.push(name.to_string());
47 }
48 for (name, _) in &class.implements_generics {
49 deps.push(name.to_string());
50 }
51 for (name, _) in &class.use_generics {
52 deps.push(name.to_string());
53 }
54
55 // Mixin classes (from @mixin tags). Needed for Phase 2 (ER3)
56 // so that mixin classes are populated before the classes that
57 // reference them. Including them here from the start means the
58 // sort order is correct for both inheritance and virtual-member
59 // passes.
60 for mixin in &class.mixins {
61 deps.push(mixin.to_string());
62 }
63
64 deps
65}
66
67/// State for a single frame in the iterative DFS stack.
68///

Callers 1

toposort_classesFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected