pub struct Codebase {
pub classes: DashMap<Arc<str>, ClassStorage>,
pub interfaces: DashMap<Arc<str>, InterfaceStorage>,
pub traits: DashMap<Arc<str>, TraitStorage>,
pub enums: DashMap<Arc<str>, EnumStorage>,
pub functions: DashMap<Arc<str>, FunctionStorage>,
pub constants: DashMap<Arc<str>, Union>,
pub referenced_methods: DashSet<Arc<str>>,
pub referenced_properties: DashSet<Arc<str>>,
pub referenced_functions: DashSet<Arc<str>>,
pub file_imports: DashMap<Arc<str>, HashMap<String, String>>,
pub file_namespaces: DashMap<Arc<str>, String>,
/* private fields */
}Fields§
§classes: DashMap<Arc<str>, ClassStorage>§interfaces: DashMap<Arc<str>, InterfaceStorage>§traits: DashMap<Arc<str>, TraitStorage>§enums: DashMap<Arc<str>, EnumStorage>§functions: DashMap<Arc<str>, FunctionStorage>§constants: DashMap<Arc<str>, Union>§referenced_methods: DashSet<Arc<str>>Methods referenced during Pass 2 — key format: "ClassName::methodName".
Used by the dead-code detector (M18).
referenced_properties: DashSet<Arc<str>>Properties referenced during Pass 2 — key format: "ClassName::propName".
referenced_functions: DashSet<Arc<str>>Free functions referenced during Pass 2 — key: fully-qualified name.
file_imports: DashMap<Arc<str>, HashMap<String, String>>Per-file use alias maps: alias → FQCN. Populated during Pass 1.
file_namespaces: DashMap<Arc<str>, String>Per-file current namespace (if any). Populated during Pass 1.
Implementations§
Source§impl Codebase
impl Codebase
pub fn new() -> Self
Sourcepub fn get_property(
&self,
fqcn: &str,
prop_name: &str,
) -> Option<PropertyStorage>
pub fn get_property( &self, fqcn: &str, prop_name: &str, ) -> Option<PropertyStorage>
Resolve a property, walking up the inheritance chain (parent classes and traits).
Sourcepub fn get_method(&self, fqcn: &str, method_name: &str) -> Option<MethodStorage>
pub fn get_method(&self, fqcn: &str, method_name: &str) -> Option<MethodStorage>
Resolve a method, walking up the inheritance chain.
Sourcepub fn extends_or_implements(&self, child: &str, ancestor: &str) -> bool
pub fn extends_or_implements(&self, child: &str, ancestor: &str) -> bool
Returns true if child extends or implements ancestor (transitively).
Sourcepub fn type_exists(&self, fqcn: &str) -> bool
pub fn type_exists(&self, fqcn: &str) -> bool
Whether a class/interface/trait/enum with this FQCN exists.
pub fn function_exists(&self, fqn: &str) -> bool
Sourcepub fn has_magic_get(&self, fqcn: &str) -> bool
pub fn has_magic_get(&self, fqcn: &str) -> bool
Returns true if the class (or any ancestor/trait) defines a __get magic method.
Such classes allow arbitrary property access, suppressing UndefinedProperty.
Sourcepub fn has_unknown_ancestor(&self, fqcn: &str) -> bool
pub fn has_unknown_ancestor(&self, fqcn: &str) -> bool
Returns true if the class (or any of its ancestors) has a parent/interface/trait
that is NOT present in the codebase. Used to suppress UndefinedMethod false
positives: if a method might be inherited from an unscanned external class we
cannot confirm or deny its existence.
We use the pre-computed all_parents list (built during finalization) rather
than recursive DashMap lookups to avoid potential deadlocks.
Sourcepub fn resolve_class_name(&self, file: &str, name: &str) -> String
pub fn resolve_class_name(&self, file: &str, name: &str) -> String
Resolve a short class/function name to its FQCN using the import table
and namespace recorded for file during Pass 1.
- Names already containing
\(after stripping a leading\) are returned as-is (already fully qualified). self,parent,staticare returned unchanged (caller handles them).
Sourcepub fn mark_method_referenced(&self, fqcn: &str, method_name: &str)
pub fn mark_method_referenced(&self, fqcn: &str, method_name: &str)
Mark a method as referenced from user code.
Sourcepub fn mark_property_referenced(&self, fqcn: &str, prop_name: &str)
pub fn mark_property_referenced(&self, fqcn: &str, prop_name: &str)
Mark a property as referenced from user code.
Sourcepub fn mark_function_referenced(&self, fqn: &str)
pub fn mark_function_referenced(&self, fqn: &str)
Mark a free function as referenced from user code.