Check if a line contains the `function` keyword as a standalone word (not part of a larger identifier like `$functionality`).
(line: &str)
| 1890 | /// Check if a line contains the `function` keyword as a standalone word |
| 1891 | /// (not part of a larger identifier like `$functionality`). |
| 1892 | pub(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 | /// |
no test coverage detected