php-lsp 0.28.0

A PHP Language Server Protocol implementation
Documentation
//! External static-analysis tool integration (PHPStan / PHPCS).
//!
//! These run as child processes against a single saved file and their
//! findings are merged into the diagnostics the built-in `mir`-backed
//! analyzer already produces — see [`crate::lang::config::ExternalToolsConfig`]
//! for why both default off.
#[cfg(not(target_family = "wasm"))]
pub mod phpcs;
#[cfg(not(target_family = "wasm"))]
pub mod phpstan;

#[cfg(not(target_family = "wasm"))]
use std::path::Path;

#[cfg(not(target_family = "wasm"))]
use tower_lsp_server::ls_types::Diagnostic;

#[cfg(not(target_family = "wasm"))]
use crate::lang::config::ExternalToolsConfig;

/// Run every enabled external tool against `path` and return their combined
/// diagnostics. Tools run one after another rather than concurrently so a
/// single caller gets one complete `Vec` back instead of having to merge two
/// independently-arriving results.
#[cfg(not(target_family = "wasm"))]
pub async fn run_external_diagnostics(
    cfg: &ExternalToolsConfig,
    path: &Path,
    workspace_root: Option<&Path>,
) -> Vec<Diagnostic> {
    let mut out = Vec::new();
    if cfg.phpstan.enabled {
        out.extend(phpstan::run(&cfg.phpstan, path, workspace_root).await);
    }
    if cfg.phpcs.enabled {
        out.extend(phpcs::run(&cfg.phpcs, path, workspace_root).await);
    }
    out
}