diff --git a/src/Mapper/Application/Service/Mapper.php b/src/Mapper/Application/Service/Mapper.php index 1c1f9d9..56199fd 100644 --- a/src/Mapper/Application/Service/Mapper.php +++ b/src/Mapper/Application/Service/Mapper.php @@ -84,11 +84,11 @@ protected function getMapper( foreach ($blueprints as $processUse => $blueprint) { do { - $hasExtended = $this->extender->extend($blueprint, $processType, $context); + $hasExtended = $this->extender->extend($blueprint, $processType, $context, $processUse); $hasModified = $this->modificator->modify($blueprint, $processType, $context, $processUse); } while ($hasExtended || $hasModified); - $this->checker->check($blueprint, $processType, $context); + $this->checker->check($blueprint, $processType, $context, $processUse); } $this->matcher->matchBlueprints($context, $processType, ...$blueprints); diff --git a/src/Mapper/Domain/Modules/Checker/Checker.php b/src/Mapper/Domain/Modules/Checker/Checker.php index bd56dd2..7272121 100644 --- a/src/Mapper/Domain/Modules/Checker/Checker.php +++ b/src/Mapper/Domain/Modules/Checker/Checker.php @@ -18,10 +18,10 @@ public function __construct( ) { } - public function check(Blueprint $blueprint, Process $process, Context $context): void + public function check(Blueprint $blueprint, Process $process, Context $context, string $processUse): void { foreach ($this->strategies as $strategy) { - $strategy->check($blueprint, $process, $context); + $strategy->check($blueprint, $process, $context, $processUse); } } } diff --git a/src/Mapper/Domain/Modules/Checker/Contract/CheckerInterface.php b/src/Mapper/Domain/Modules/Checker/Contract/CheckerInterface.php index 76ef5d6..675310a 100644 --- a/src/Mapper/Domain/Modules/Checker/Contract/CheckerInterface.php +++ b/src/Mapper/Domain/Modules/Checker/Contract/CheckerInterface.php @@ -22,5 +22,5 @@ interface CheckerInterface * * @throws CheckerException if the blueprint is invalid */ - public function check(Blueprint $blueprint, Process $process, Context $context): void; + public function check(Blueprint $blueprint, Process $process, Context $context, string $processUse): void; } diff --git a/src/Mapper/Domain/Modules/Checker/Contract/CheckerStrategyInterface.php b/src/Mapper/Domain/Modules/Checker/Contract/CheckerStrategyInterface.php index d9176a5..bef3330 100644 --- a/src/Mapper/Domain/Modules/Checker/Contract/CheckerStrategyInterface.php +++ b/src/Mapper/Domain/Modules/Checker/Contract/CheckerStrategyInterface.php @@ -16,5 +16,5 @@ interface CheckerStrategyInterface * * @throws CheckerException if the blueprint is invalid */ - public function check(Blueprint $blueprint, Process $process, Context $context): void; + public function check(Blueprint $blueprint, Process $process, Context $context, string $processUse): void; } diff --git a/src/Mapper/Domain/Modules/Checker/Strategy/RecursiveLoopChecker.php b/src/Mapper/Domain/Modules/Checker/Strategy/RecursiveLoopChecker.php index 08da52a..68582e0 100644 --- a/src/Mapper/Domain/Modules/Checker/Strategy/RecursiveLoopChecker.php +++ b/src/Mapper/Domain/Modules/Checker/Strategy/RecursiveLoopChecker.php @@ -19,7 +19,7 @@ class RecursiveLoopChecker implements CheckerStrategyInterface { private Blueprint $blueprint; - public function check(Blueprint $blueprint, Process $process, Context $context): void + public function check(Blueprint $blueprint, Process $process, Context $context, string $processUse): void { $this->blueprint = $blueprint; foreach ($blueprint->blueprints as $index => $classBlueprint) { diff --git a/src/Mapper/Domain/Modules/Extender/Contract/ExtenderInterface.php b/src/Mapper/Domain/Modules/Extender/Contract/ExtenderInterface.php index eb46c57..d1eb6b9 100644 --- a/src/Mapper/Domain/Modules/Extender/Contract/ExtenderInterface.php +++ b/src/Mapper/Domain/Modules/Extender/Contract/ExtenderInterface.php @@ -25,5 +25,5 @@ interface ExtenderInterface * * @throws ExtenderException if there was any problem with extending the blueprint */ - public function extend(Blueprint $blueprint, Process $process, Context $context): bool; + public function extend(Blueprint $blueprint, Process $process, Context $context, string $processUse): bool; } diff --git a/src/Mapper/Domain/Modules/Extender/Contract/ExtenderStrategyInterface.php b/src/Mapper/Domain/Modules/Extender/Contract/ExtenderStrategyInterface.php index fbe60d8..4c74ee2 100644 --- a/src/Mapper/Domain/Modules/Extender/Contract/ExtenderStrategyInterface.php +++ b/src/Mapper/Domain/Modules/Extender/Contract/ExtenderStrategyInterface.php @@ -16,5 +16,5 @@ interface ExtenderStrategyInterface * * @return bool `true` if the blueprint was extended, `false` otherwise */ - public function extend(Blueprint $blueprint, Process $process, Context $context): bool; + public function extend(Blueprint $blueprint, Process $process, Context $context, string $processUse): bool; } diff --git a/src/Mapper/Domain/Modules/Extender/Extender.php b/src/Mapper/Domain/Modules/Extender/Extender.php index 01f9f2f..3687de7 100644 --- a/src/Mapper/Domain/Modules/Extender/Extender.php +++ b/src/Mapper/Domain/Modules/Extender/Extender.php @@ -22,17 +22,17 @@ public function __construct( $this->recursionLevel = 0; } - public function extend(Blueprint $blueprint, Process $process, Context $context): bool + public function extend(Blueprint $blueprint, Process $process, Context $context, string $processUse): bool { $extended = false; foreach ($this->strategies as $strategy) { - $extended = $strategy->extend($blueprint, $process, $context) || $extended; + $extended = $strategy->extend($blueprint, $process, $context, $processUse) || $extended; } if ($extended) { ++$this->recursionLevel; - $this->extend($blueprint, $process, $context); + $this->extend($blueprint, $process, $context, $processUse); if ($this->recursionLevel > $this->maxRecursionLevel) { throw new Exception\ExtenderException(sprintf('Max recursion level of %d reached', $this->maxRecursionLevel), 'Extender recursion level can be increased by setting the maxRecursionLevel property in the constructor of the Extender class. The default value is 100. If you are sure that the recursion level is not a problem, you can increase the value. If you are not sure, you should check the blueprint and the strategies to see if there is a problem with the blueprint or the strategies.'); diff --git a/src/Mapper/Domain/Modules/Extender/Strategy/DiscriminatorExtender.php b/src/Mapper/Domain/Modules/Extender/Strategy/DiscriminatorExtender.php index e79c39b..442ddd0 100644 --- a/src/Mapper/Domain/Modules/Extender/Strategy/DiscriminatorExtender.php +++ b/src/Mapper/Domain/Modules/Extender/Strategy/DiscriminatorExtender.php @@ -16,7 +16,7 @@ class DiscriminatorExtender implements ExtenderStrategyInterface private Blueprint $blueprint; private bool $extended; - public function extend(Blueprint $blueprint, Process $process, Context $context): bool + public function extend(Blueprint $blueprint, Process $process, Context $context, string $processUse): bool { $this->extended = false; $this->blueprint = $blueprint; diff --git a/tests/Mapper/Unit/Domain/Modules/Checker/RecursiveLoopCheckerTest.php b/tests/Mapper/Unit/Domain/Modules/Checker/RecursiveLoopCheckerTest.php index 88b4553..ba8301e 100644 --- a/tests/Mapper/Unit/Domain/Modules/Checker/RecursiveLoopCheckerTest.php +++ b/tests/Mapper/Unit/Domain/Modules/Checker/RecursiveLoopCheckerTest.php @@ -30,7 +30,8 @@ public function shouldThrowExceptionOnLoopDetected(): void (new RecursiveLoopChecker())->check( Blueprint::create(get_class($class)), new Process([Process::DENORMALIZATION_PROCESS]), - new Context() + new Context(), + 'origin' ); } @@ -46,7 +47,8 @@ public function shouldThrowExceptionOnLoopDetectedInTheGroupContext(): void (new RecursiveLoopChecker())->check( Blueprint::create(get_class($class)), new Process([Process::DENORMALIZATION_PROCESS]), - new Context(['test']) + new Context(['test']), + 'origin' ); } @@ -61,7 +63,8 @@ public function shouldNotThrowExceptionBecauseOfIgnoreAttribute(): void (new RecursiveLoopChecker())->check( Blueprint::create(get_class($class)), new Process([Process::DENORMALIZATION_PROCESS]), - new Context() + new Context(), + 'origin' ); $this->expectNotToPerformAssertions(); @@ -78,7 +81,8 @@ public function shouldNotThrowExceptionBecauseOfMaxDepthAttribute(): void (new RecursiveLoopChecker())->check( Blueprint::create(get_class($class)), new Process([Process::DENORMALIZATION_PROCESS]), - new Context() + new Context(), + 'origin' ); $this->expectNotToPerformAssertions();