refactor(compat): Freigabe-Bausteine generisch
ReleaseStore, CheckReportStore, CheckReport, CheckStep und CompatibilityCheck liegen im Kern und arbeiten je Profil (Optionen lit_mcp_<id>_releases|_check_report; Divi behält Namen und Schlüssel divi_version). Divi hängt Katalog-, Format- und Schreibtest über Profile::extraSteps an. Ein roter Prüfbericht für den aktuellen Stand sperrt LockOnFailure-Profile bis zur nächsten grünen Prüfung; Sperrgründe nennen nur Schritt-Labels, Ausnahmen gehen ins Error-Log. Profile bekommt testedVersions, stateKey, extraSteps, manifestCheck und reportVersionKey und wird mit benannten Argumenten gebaut. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c85131603b
commit
7d6a97a54e
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Compatibility;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* One step of the admin check (spec §6.2); skipped = not run. The label is stored with the step, so a report stays
|
||||
* readable without the profile that made it; an old report without one shows the raw key.
|
||||
*/
|
||||
final class CheckStep
|
||||
{
|
||||
public const MANIFEST = 'manifest';
|
||||
public const MIRRORS = 'mirrors';
|
||||
|
||||
/** The label of a generic step of the profile named $profileLabel; null for any other key. */
|
||||
public static function genericLabel(string $key, string $profileLabel): ?string
|
||||
{
|
||||
return match ($key) {
|
||||
self::MANIFEST => sprintf('%s-Funktionen, Klassen und Registrierungen', $profileLabel),
|
||||
self::MIRRORS => sprintf('Fingerabdrücke nachgebauter %s-Funktionen', $profileLabel),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
/** @param list<string> $problems */
|
||||
public function __construct(
|
||||
public readonly string $key,
|
||||
public readonly array $problems,
|
||||
public readonly bool $skipped = false,
|
||||
public readonly ?string $label = null
|
||||
) {
|
||||
}
|
||||
|
||||
public function green(): bool
|
||||
{
|
||||
return ! $this->skipped && $this->problems === [];
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->label ?? $this->key;
|
||||
}
|
||||
|
||||
/** @return array{key: string, problems: list<string>, skipped: bool, label?: string} */
|
||||
public function toArray(): array
|
||||
{
|
||||
$data = ['key' => $this->key, 'problems' => $this->problems, 'skipped' => $this->skipped];
|
||||
|
||||
return $this->label === null ? $data : $data + ['label' => $this->label];
|
||||
}
|
||||
|
||||
public static function fromArray(mixed $data): ?self
|
||||
{
|
||||
if (! is_array($data) || ! is_string($data['key'] ?? null) || ! is_array($data['problems'] ?? null)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new self(
|
||||
$data['key'],
|
||||
array_values(array_filter($data['problems'], 'is_string')),
|
||||
($data['skipped'] ?? false) === true,
|
||||
is_string($data['label'] ?? null) ? $data['label'] : null
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user