Auto-detect PHPCS by checking ` /phpcs` then `$PATH`.
(workspace_root: Option<&Path>, bin_dir: Option<&str>)
| 87 | |
| 88 | /// Auto-detect PHPCS by checking `<bin_dir>/phpcs` then `$PATH`. |
| 89 | fn 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. |
no test coverage detected