Skip to content

Commit 58a25f3

Browse files
authored
Merge pull request #8 from KaririCode-Framework/develop
fix(validator): resolve processor state retention issues
2 parents 6bc3e74 + dfd371c commit 58a25f3

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

composer.lock

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ProcessorPipeline.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use KaririCode\Contract\Processor\Pipeline;
88
use KaririCode\Contract\Processor\Processor;
9+
use KaririCode\Contract\Processor\ValidatableProcessor;
910

1011
class ProcessorPipeline implements Pipeline
1112
{
@@ -22,7 +23,14 @@ public function process(mixed $input): mixed
2223
{
2324
return array_reduce(
2425
$this->processors,
25-
fn ($carry, Processor $processor) => $processor->process($carry),
26+
static function ($carry, Processor $processor): mixed {
27+
// Reset the processor's state if it's a ValidatableProcessor
28+
if ($processor instanceof ValidatableProcessor) {
29+
$processor->reset();
30+
}
31+
32+
return $processor->process($carry);
33+
},
2634
$input
2735
);
2836
}

0 commit comments

Comments
 (0)