- FormFieldBindingMergeStrategy::nullWinnerBehaviour() and isValidForScalarTargets() encode the per-strategy null-winner matrix (RFC Q7) and the collection-only restriction (RFC V1). - ResolvedBinding/BindingApplicationResult/BindingPassResult readonly DTOs for the binding pipeline. Construction-time validation for trust level. Apply-status derived from result aggregate. Note: the existing enum is named FormFieldBindingMergeStrategy (not MergeStrategy as the prompt sketched). Methods added to it directly. Refs: RFC-WS-6.md §3 (Q4, Q7), §4 (V1) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Enums\FormBuilder;
|
|
|
|
enum FormFieldBindingMergeStrategy: string
|
|
{
|
|
case Overwrite = 'overwrite';
|
|
case Append = 'append';
|
|
case Replace = 'replace';
|
|
case FirstWriteWins = 'first_write_wins';
|
|
|
|
/**
|
|
* RFC-WS-6 §3 (Q7) — what to do when the conflict-resolution winner
|
|
* has a null value. Returns one of:
|
|
* - 'write' write null to the target (intent: clear)
|
|
* - 'noop' leave the target untouched
|
|
* - 'conditional' write only when the target itself is null
|
|
*/
|
|
public function nullWinnerBehaviour(): string
|
|
{
|
|
return match ($this) {
|
|
self::Overwrite => 'write',
|
|
self::Append => 'noop',
|
|
self::Replace => 'noop',
|
|
self::FirstWriteWins => 'conditional',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* RFC-WS-6 §4 (V1) — Append is collection-only (idempotent retry only
|
|
* with set semantics; scalar-append demands fingerprinting which is
|
|
* an architectural smell).
|
|
*/
|
|
public function isValidForScalarTargets(): bool
|
|
{
|
|
return $this !== self::Append;
|
|
}
|
|
}
|