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

Function auto_detect

src/phpstan.rs:87–103  ·  view source on GitHub ↗

Auto-detect PHPStan by checking ` /phpstan` then `$PATH`.

(workspace_root: Option<&Path>, bin_dir: Option<&str>)

Source from the content-addressed store, hash-verified

85
86/// Auto-detect PHPStan by checking `<bin_dir>/phpstan` then `$PATH`.
87fn auto_detect(workspace_root: Option<&Path>, bin_dir: Option<&str>) -> Option<ResolvedPhpStan> {
88 // Check the Composer bin directory first.
89 if let Some(root) = workspace_root {
90 let bin = bin_dir.unwrap_or("vendor/bin");
91 let candidate = root.join(bin).join("phpstan");
92 if candidate.is_file() {
93 return Some(ResolvedPhpStan { path: candidate });
94 }
95 }
96
97 // Fall back to $PATH.
98 if let Ok(path) = which("phpstan") {
99 return Some(ResolvedPhpStan { path });
100 }
101
102 None
103}
104
105/// Simple `which`-like lookup: search `$PATH` for an executable with
106/// the given name.

Callers 1

resolve_phpstanFunction · 0.70

Calls 1

whichFunction · 0.70

Tested by

no test coverage detected