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

Function resolve_phpcs

src/phpcs.rs:71–86  ·  view source on GitHub ↗

Attempt to resolve the PHPCS 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 ` /phpcs` under the workspace root, then search `$PATH`.

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

Source from the content-addressed store, hash-verified

69/// - Config value `None` → auto-detect: try `<bin_dir>/phpcs` under
70/// the workspace root, then search `$PATH`.
71pub(crate) fn resolve_phpcs(
72 workspace_root: Option<&Path>,
73 config: &PhpcsConfig,
74 bin_dir: Option<&str>,
75) -> Option<ResolvedPhpcs> {
76 match config.command.as_deref() {
77 // Explicitly disabled.
78 Some("") => None,
79 // User-provided command.
80 Some(cmd) => Some(ResolvedPhpcs {
81 path: PathBuf::from(cmd),
82 }),
83 // Auto-detect.
84 None => auto_detect(workspace_root, bin_dir),
85 }
86}
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> {

Callers 3

resolve_explicit_commandFunction · 0.85
phpcs_workerMethod · 0.85

Calls 1

auto_detectFunction · 0.70

Tested by 2

resolve_explicit_commandFunction · 0.68