Generate a variable name (without `$` prefix) from the selected expression text. Heuristics: - Method call: `$user->getName()` → `name` - Property access: `$user->email` → `email` - Static call: `Carbon::now()` → `now` - Function call: `array_filter($items, ...)` → `arrayFilter` - Fallback: `variable`
(expression: &str)
| 253 | /// - Function call: `array_filter($items, ...)` → `arrayFilter` |
| 254 | /// - Fallback: `variable` |
| 255 | fn generate_variable_name(expression: &str) -> String { |
| 256 | let expr = expression.trim(); |
| 257 | |
| 258 | // Try method call: `...->name(...)` or `...?->name(...)` |
| 259 | if let Some(name) = extract_method_call_name(expr) { |
| 260 | return name; |
| 261 | } |
| 262 | |
| 263 | // Try property access: `...->name` or `...?->name` |
| 264 | if let Some(name) = extract_property_name(expr) { |
| 265 | return name; |
| 266 | } |
| 267 | |
| 268 | // Try static call: `Class::method(...)` |
| 269 | if let Some(name) = extract_static_call_name(expr) { |
| 270 | return name; |
| 271 | } |
| 272 | |
| 273 | // Try function call: `func_name(...)` |
| 274 | if let Some(name) = extract_function_call_name(expr) { |
| 275 | return name; |
| 276 | } |
| 277 | |
| 278 | "variable".to_string() |
| 279 | } |
| 280 | |
| 281 | /// Extract name from a method call like `$user->getName()`. |
| 282 | fn extract_method_call_name(expr: &str) -> Option<String> { |
no test coverage detected