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

Function build_var_annotation

src/hover/formatting.rs:119–135  ·  view source on GitHub ↗

Build a `@var` docblock annotation when the effective type differs from the native type. Returns `None` when they are identical or when there is no effective type.

(
    effective: Option<&PhpType>,
    native: Option<&PhpType>,
)

Source from the content-addressed store, hash-verified

117/// the native type. Returns `None` when they are identical or when there
118/// is no effective type.
119pub(super) fn build_var_annotation(
120 effective: Option<&PhpType>,
121 native: Option<&PhpType>,
122) -> Option<String> {
123 let eff = effective?;
124 // When there is no native type hint, `mixed` is the implicit type
125 // in PHP — showing `@var mixed` would be noise.
126 if native.is_none() && eff.is_mixed() {
127 return None;
128 }
129 if let Some(n) = native
130 && eff.equivalent(n)
131 {
132 return None;
133 }
134 Some(format!("@var {}", shorten_php_type(eff)))
135}
136
137/// Build a readable markdown section showing parameter and return type
138/// information.

Callers 1

hover_for_propertyMethod · 0.85

Calls 2

is_mixedMethod · 0.80
equivalentMethod · 0.80

Tested by

no test coverage detected