src/Context/FieldResolver.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Context/FieldResolver.php b/src/Context/FieldResolver.php index 96326d8..f8e27ec 100644 --- a/src/Context/FieldResolver.php +++ b/src/Context/FieldResolver.php @@ -214,19 +214,17 @@ class FieldResolver { : $previous_messages ); } + // Remove duplicates by converting to strings and then using array_unique(). + $resolved_as_strings = array_map(function ($possibility) use ($internal_field_name) { + return implode('.', $possibility); + }, $resolved); + $resolved_as_strings = array_unique($resolved_as_strings); + // The resolved internal paths do not include the current field name because - // resolution happens in a recursive process. - $resolved_unique = array_unique(array_map(function ($possibility) use ($internal_field_name) { - // Convert to strings so we can make uniqueness easier. - return implode('.', array_merge([$internal_field_name], $possibility)); - }, $resolved)); - - // Have the unique list converted back to what it needs to be. - $result = array_map(function ($string) { - return explode('.', $string); - }, $resolved_unique); - - return $result; + // resolution happens in a recursive process. Convert back from strings. + return array_map(function ($possibility) use ($internal_field_name) { + return array_merge([$internal_field_name], explode('.', $possibility)); + }, $resolved_as_strings); } /**