Resolve a class name from a parameter default (`Foo::class`) to its FQN using the file's use-map and namespace from [`DocblockCtx`].
(name: &str, doc_ctx: Option<&DocblockCtx<'_>>)
| 967 | /// Resolve a class name from a parameter default (`Foo::class`) to its FQN |
| 968 | /// using the file's use-map and namespace from [`DocblockCtx`]. |
| 969 | fn resolve_default_class_name(name: &str, doc_ctx: Option<&DocblockCtx<'_>>) -> String { |
| 970 | // Already fully-qualified. |
| 971 | if let Some(stripped) = name.strip_prefix('\\') { |
| 972 | return stripped.to_string(); |
| 973 | } |
| 974 | let Some(ctx) = doc_ctx else { |
| 975 | return name.to_string(); |
| 976 | }; |
| 977 | // Check use-map (handles `use App\Application;` → "Application" → "App\Application"). |
| 978 | if let Some(fqn) = ctx.use_map.get(name) { |
| 979 | return fqn.clone(); |
| 980 | } |
| 981 | // If the name has a namespace prefix (e.g. `Sub\Foo`), check the first segment. |
| 982 | if let Some(first_seg) = name.split('\\').next() |
| 983 | && first_seg != name |
| 984 | && let Some(base) = ctx.use_map.get(first_seg) |
| 985 | { |
| 986 | let rest = &name[first_seg.len() + 1..]; |
| 987 | return format!("{}\\{}", base, rest); |
| 988 | } |
| 989 | // Prepend file namespace if present. |
| 990 | if let Some(ref ns) = ctx.namespace { |
| 991 | return format!("{}\\{}", ns, name); |
| 992 | } |
| 993 | name.to_string() |
| 994 | } |
| 995 | |
| 996 | /// Extract visibility from a set of modifiers. |
| 997 | /// Defaults to `Public` if no visibility modifier is present. |
no test coverage detected