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>,
)
| 117 | /// the native type. Returns `None` when they are identical or when there |
| 118 | /// is no effective type. |
| 119 | pub(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. |
no test coverage detected