Skip to content

Commit

Permalink
v2
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquemoody committed Dec 27, 2024
1 parent fb2ec79 commit fdf13fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/Message/StandardFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function main(Result $result, array $templates, Translator $translator):
$selectedTemplates = $this->selectTemplates($result, $templates);
if (!$this->isFinalTemplate($result, $selectedTemplates)) {
foreach ($this->extractDeduplicatedChildren($result) as $child) {
if ($result->path !== null && $child->path !== null) {
if ($result->path !== null && $child->path !== null && $child->path !== $result->path) {
$child = $child->withPath(sprintf('%s.%s', $result->path, $child->path));
} elseif ($result->path !== null && $child->path === null) {
$child = $child->withPath($result->path);
Expand Down
9 changes: 8 additions & 1 deletion library/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,14 @@ public function withIdFrom(Rule $rule): self

public function withPath(string|int $path): self
{
return $this->clone(adjacent: $this->adjacent?->withPath($path), path: $path);
if ($this->path === $path) {
return $this;
}

return $this->clone(
adjacent: $this->adjacent?->withPath($path),
path: $this->path === null ? $path : $path . '.' . $this->path,
);
}

public function withPrefix(string $prefix): self
Expand Down

0 comments on commit fdf13fd

Please sign in to comment.