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

Function contains_function_keyword

src/util.rs:1892–1903  ·  view source on GitHub ↗

Check if a line contains the `function` keyword as a standalone word (not part of a larger identifier like `$functionality`).

(line: &str)

Source from the content-addressed store, hash-verified

1890/// Check if a line contains the `function` keyword as a standalone word
1891/// (not part of a larger identifier like `$functionality`).
1892pub(crate) fn contains_function_keyword(line: &str) -> bool {
1893 let trimmed = line.trim();
1894 let Some(pos) = trimmed.find("function") else {
1895 return false;
1896 };
1897 let before_ok = pos == 0 || trimmed.as_bytes()[pos - 1].is_ascii_whitespace();
1898 let after_pos = pos + "function".len();
1899 let after_ok = after_pos >= trimmed.len()
1900 || !trimmed.as_bytes()[after_pos].is_ascii_alphanumeric()
1901 && trimmed.as_bytes()[after_pos] != b'_';
1902 before_ok && after_ok
1903}
1904
1905/// Check if a `#[...]` line contains a specific PHP attribute name.
1906///

Callers 3

enclosing_docblock_textFunction · 0.85

Calls 1

findMethod · 0.45

Tested by

no test coverage detected