File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public static function getEvaluationResult($context): EvaluationResult
4949 /** @var array<string, FlagResult> */
5050 $ evaluatedFlags = [];
5151
52- self ::enrichContext ($ context );
52+ $ context = self ::enrichContext ($ context );
5353
5454 foreach ($ context ->segments as $ segment ) {
5555 if (!self ::isContextInSegment ($ context , $ segment )) {
@@ -102,16 +102,21 @@ public static function getEvaluationResult($context): EvaluationResult
102102 }
103103
104104 /**
105- * Enrich the evaluation context with derived values:
105+ * Get an enriched evaluation context with derived values:
106106 * - `$.identity.key` if missing
107+ * Returns a cloned context if any enrichment is applied.
108+ * Returns the original context if no enrichment is needed.
107109 * @param EvaluationContext $context
108- * @return void
110+ * @return EvaluationContext
109111 */
110- private static function enrichContext (EvaluationContext $ context ): void
112+ private static function enrichContext (EvaluationContext $ context ): EvaluationContext
111113 {
112114 if ($ context ->identity !== null && $ context ->identity ->key === null ) {
115+ $ context = clone $ context ;
116+ $ context ->identity = clone $ context ->identity ;
113117 $ context ->identity ->key = "{$ context ->environment ->key }_ {$ context ->identity ->identifier }" ;
114118 }
119+ return $ context ;
115120 }
116121
117122 /**
You can’t perform that action at this time.
0 commit comments