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