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

Function format_params_inner

src/hover/formatting.rs:68–101  ·  view source on GitHub ↗

Shared implementation for parameter formatting. When `use_native` is true, uses `native_type_hint` (falling back to `type_hint` when no native hint is stored — e.g. for virtual members synthesised from docblocks). Otherwise uses `type_hint` (effective).

(params: &[ParameterInfo], use_native: bool)

Source from the content-addressed store, hash-verified

66/// `type_hint` when no native hint is stored — e.g. for virtual members
67/// synthesised from docblocks). Otherwise uses `type_hint` (effective).
68fn format_params_inner(params: &[ParameterInfo], use_native: bool) -> String {
69 params
70 .iter()
71 .map(|p| {
72 let mut parts = Vec::new();
73 let hint: Option<String> = if use_native {
74 p.native_type_hint.as_ref().map(|t| t.to_string())
75 } else {
76 p.type_hint.as_ref().map(|t| t.to_string())
77 };
78 if let Some(th) = hint {
79 parts.push(th);
80 }
81 if p.is_variadic {
82 parts.push(format!("...{}", p.name));
83 } else if p.is_reference {
84 parts.push(format!("&{}", p.name));
85 } else {
86 parts.push(p.name.to_string());
87 }
88 let param_str = parts.join(" ");
89 if !p.is_required && !p.is_variadic {
90 if let Some(ref dv) = p.default_value {
91 format!("{} = {}", param_str, dv)
92 } else {
93 format!("{} = ...", param_str)
94 }
95 } else {
96 param_str
97 }
98 })
99 .collect::<Vec<_>>()
100 .join(", ")
101}
102
103/// Build a `namespace Foo;\n` line for use inside PHP code blocks.
104/// Returns an empty string when the namespace is global (None).

Callers 1

format_native_paramsFunction · 0.85

Calls 3

iterMethod · 0.80
pushMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected