Attempt to resolve the PHPStan binary from configuration and the workspace environment. Resolution rules: - Config value `Some("")` (empty string) → disabled (`None`). - Config value `Some(cmd)` → use `cmd` as-is (user override). - Config value `None` → auto-detect: try ` /phpstan` under the workspace root, then search `$PATH`.
(
workspace_root: Option<&Path>,
config: &PhpStanConfig,
bin_dir: Option<&str>,
)
| 67 | /// - Config value `None` → auto-detect: try `<bin_dir>/phpstan` under |
| 68 | /// the workspace root, then search `$PATH`. |
| 69 | pub(crate) fn resolve_phpstan( |
| 70 | workspace_root: Option<&Path>, |
| 71 | config: &PhpStanConfig, |
| 72 | bin_dir: Option<&str>, |
| 73 | ) -> Option<ResolvedPhpStan> { |
| 74 | match config.command.as_deref() { |
| 75 | // Explicitly disabled. |
| 76 | Some("") => None, |
| 77 | // User-provided command. |
| 78 | Some(cmd) => Some(ResolvedPhpStan { |
| 79 | path: PathBuf::from(cmd), |
| 80 | }), |
| 81 | // Auto-detect. |
| 82 | None => auto_detect(workspace_root, bin_dir), |
| 83 | } |
| 84 | } |
| 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> { |