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)
| 66 | /// `type_hint` when no native hint is stored — e.g. for virtual members |
| 67 | /// synthesised from docblocks). Otherwise uses `type_hint` (effective). |
| 68 | fn 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). |
no test coverage detected