mago-analyzer 1.18.1

A PHP static analyzer that can detect type errors in PHP code, and provide suggestions for fixing them.
Documentation
//! Statement hooks for intercepting statement analysis.

use mago_syntax::ast::Statement;

use crate::plugin::context::HookContext;
use crate::plugin::hook::HookAction;
use crate::plugin::hook::HookResult;
use crate::plugin::provider::Provider;

/// Hook trait for intercepting statement analysis.
///
/// This hook receives the real AST statement and full mutable context,
/// allowing hooks to inspect statements, report issues, and modify analysis state.
pub trait StatementHook: Provider {
    /// Called before a statement is analyzed.
    ///
    /// Return `HookAction::Continue` to proceed with normal analysis, or
    /// `HookAction::Skip` to skip analysis of this statement.
    fn before_statement(&self, _stmt: &Statement<'_>, _context: &mut HookContext<'_, '_>) -> HookResult<HookAction> {
        Ok(HookAction::Continue)
    }

    /// Called after a statement has been analyzed.
    fn after_statement(&self, _stmt: &Statement<'_>, _context: &mut HookContext<'_, '_>) -> HookResult<()> {
        Ok(())
    }
}