Check whether a trimmed code line is a simple variable assignment. Returns `true` for lines like `$foo = expr;` or `$foo = expr` (no semicolon yet). Returns `false` for method calls (`$foo->bar()`), comparisons (`$foo == bar`), and other non-assignment uses.
(line: &str)
| 529 | /// semicolon yet). Returns `false` for method calls (`$foo->bar()`), |
| 530 | /// comparisons (`$foo == bar`), and other non-assignment uses. |
| 531 | fn is_variable_assignment(line: &str) -> bool { |
| 532 | // Find the first `$` — start of the variable name. |
| 533 | let Some(dollar) = line.find('$') else { |
| 534 | return false; |
| 535 | }; |
| 536 | // Skip past the variable name (alphanumeric, `_`, `$`). |
| 537 | let after_name = &line[dollar..]; |
| 538 | let name_len = after_name |
| 539 | .chars() |
| 540 | .take_while(|c| c.is_alphanumeric() || *c == '_' || *c == '$') |
| 541 | .count(); |
| 542 | let rest = after_name[name_len..].trim_start(); |
| 543 | |
| 544 | // Must start with `=` but not `==` or `=>`. |
| 545 | if let Some(stripped) = rest.strip_prefix('=') { |
| 546 | !stripped.starts_with('=') && !stripped.starts_with('>') |
| 547 | } else { |
| 548 | false |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | /// Check if a token is a PHP type keyword (used in property declarations). |
| 553 | fn is_type_keyword(token: &str) -> bool { |
no test coverage detected