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

Function is_pure_output

src/code_actions/extract_function.rs:627–644  ·  view source on GitHub ↗

Check whether every statement in the body is a pure output statement (`echo`, `print`, `printf`, `var_dump`, `print_r`, `var_export`).

(body: &str)

Source from the content-addressed store, hash-verified

625/// Check whether every statement in the body is a pure output statement
626/// (`echo`, `print`, `printf`, `var_dump`, `print_r`, `var_export`).
627fn is_pure_output(body: &str) -> bool {
628 let trimmed = body.trim();
629 if trimmed.is_empty() {
630 return false;
631 }
632
633 for line in trimmed.lines() {
634 let line = line.trim().trim_end_matches(';').trim();
635 if line.is_empty() || line.starts_with("//") || line.starts_with('#') {
636 continue;
637 }
638 if !is_output_line(line) {
639 return false;
640 }
641 }
642
643 true
644}
645
646/// Check whether the body *ends* with one or more output statements
647/// but also contains non-output setup lines (assignments, calls, etc.).

Callers 1

derive_base_nameFunction · 0.85

Calls 2

is_output_lineFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected