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

Function resolve_phpstan

src/phpstan.rs:69–84  ·  view source on GitHub ↗

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>,
)

Source from the content-addressed store, hash-verified

67/// - Config value `None` → auto-detect: try `<bin_dir>/phpstan` under
68/// the workspace root, then search `$PATH`.
69pub(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`.
87fn auto_detect(workspace_root: Option<&Path>, bin_dir: Option<&str>) -> Option<ResolvedPhpStan> {

Calls 1

auto_detectFunction · 0.70