<?php

/**
 * Contract for deterministic static safety rules.
 *
 * @package LolaCore\Builder\Safety
 * @license GPL-2.0-or-later
 */

declare(strict_types=1);

namespace LolaCore\Builder\Safety;

if (! defined('ABSPATH')) {
	exit;
}

/**
 * A single static safety rule executed against generated PHP.
 */
interface SafetyRuleInterface {

	/**
	 * Stable machine-readable rule identifier.
	 */
	public function id(): string;

	/**
	 * Analyze PHP and return zero or more structured findings.
	 *
	 * @return array<int, array{
	 *   severity: 'fatal'|'error'|'warning',
	 *   code: string,
	 *   message: string,
	 *   line?: int
	 * }>
	 */
	public function analyze( string $php, SafetyContext $context ): array;
}
