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

Function is_variable_assignment

src/completion/phpdoc/context.rs:531–550  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

529/// semicolon yet). Returns `false` for method calls (`$foo->bar()`),
530/// comparisons (`$foo == bar`), and other non-assignment uses.
531fn 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).
553fn is_type_keyword(token: &str) -> bool {

Callers 2

classify_from_tokensFunction · 0.85
parse_symbol_infoFunction · 0.85

Calls 2

findMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected