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

Function is_docblock_adjacent

src/completion/variable/forward_walk.rs:788–807  ·  view source on GitHub ↗

Seed a closure/arrow function scope with parameter types, using inferred callable types as fallback for untyped parameters. This mirrors [`seed_params`] but additionally accepts `inferred_types` from the enclosing call's callable signature. When a parameter has no explicit type hint, the corresponding inferred type (matched by positional index) is used instead. Check whether a `/** … */` docbloc

(content: &str, fn_offset: usize)

Source from the content-addressed store, hash-verified

786/// sibling closures/arrow functions from leaking across statement
787/// boundaries.
788fn is_docblock_adjacent(content: &str, fn_offset: usize) -> bool {
789 let before = match content.get(..fn_offset) {
790 Some(s) => s,
791 None => return false,
792 };
793 // Walk backward over whitespace, then over optional keywords
794 // (`static`, visibility modifiers) that may sit between the
795 // docblock and `fn`.
796 let trimmed = before.trim_end();
797 if trimmed.ends_with("*/") {
798 return true;
799 }
800 // Allow `static` keyword between docblock and `fn(…)`:
801 // /** @param T $x */ static fn(T $x) => …
802 // Also allow the `function` keyword for regular closures.
803 let trimmed = trimmed
804 .trim_end_matches(|c: char| c.is_ascii_alphanumeric() || c == '_')
805 .trim_end();
806 trimmed.ends_with("*/")
807}
808
809fn seed_closure_params(
810 scope: &mut ScopeState,

Callers 1

seed_closure_paramsFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected