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

Function auto_detect

src/phpcs.rs:89–105  ·  view source on GitHub ↗

Auto-detect PHPCS by checking ` /phpcs` then `$PATH`.

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

Source from the content-addressed store, hash-verified

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

Callers 1

resolve_phpcsFunction · 0.70

Calls 1

whichFunction · 0.70

Tested by

no test coverage detected