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

Function check_unresolvable_class_name

src/completion/resolver.rs:1205–1221  ·  view source on GitHub ↗

Check whether a raw type string refers to a class that cannot be loaded. Returns `Some(class_name)` when the type looks like a class name (not scalar, not a PHPDoc pseudo-type) but the class loader cannot find it. Returns `None` for scalars, unions, shapes, and types that resolve successfully.

(
    raw_type: &PhpType,
    class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
)

Source from the content-addressed store, hash-verified

1203/// find it. Returns `None` for scalars, unions, shapes, and types
1204/// that resolve successfully.
1205fn check_unresolvable_class_name(
1206 raw_type: &PhpType,
1207 class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
1208) -> Option<PhpType> {
1209 if raw_type.all_members_scalar() {
1210 return None;
1211 }
1212
1213 let effective = raw_type.non_null_type().unwrap_or_else(|| raw_type.clone());
1214 let base = effective.base_name()?;
1215
1216 if class_loader(base).is_none() {
1217 Some(PhpType::Named(base.to_string()))
1218 } else {
1219 None
1220 }
1221}
1222
1223/// Shared variable-resolution logic extracted from the former
1224/// bare-`$var` branch of `resolve_target_classes`.

Callers 1

resolve_subject_outcomeFunction · 0.85

Calls 4

all_members_scalarMethod · 0.80
non_null_typeMethod · 0.80
cloneMethod · 0.80
base_nameMethod · 0.80

Tested by

no test coverage detected