Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/XMLBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public function __construct(protected string $encoding = 'UTF-8', protected stri
/**
* Disable the root tag.
*
* @return self
* @return static
*/
public function disableRootTag(): self
public function disableRootTag(): static
{
return $this->setRootTag(false);
}
Expand All @@ -61,9 +61,9 @@ public function disableRootTag(): self
*
* @param string|bool $tag the name to use as the root tag. Set to `false` to disable.
*
* @return self
* @return static
*/
public function setRootTag(string | bool $tag): self
public function setRootTag(string | bool $tag): static
{
$this->rootTag = $tag;

Expand Down Expand Up @@ -150,7 +150,7 @@ protected function closeRootTag(): string

protected function getRootTag(): string
{
return is_string($this->rootTag) ? $this->rootTag : self::DEFAULT_ROOT;
return is_string($this->rootTag) ? $this->rootTag : static::DEFAULT_ROOT;
Comment on lines 152 to +153

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using static::DEFAULT_ROOT instead of self::DEFAULT_ROOT allows subclasses to override the default root tag. This is a good change to support inheritance.

        return is_string($this->rootTag) ? $this->rootTag : static::DEFAULT_ROOT;

}

/**
Expand All @@ -170,7 +170,7 @@ protected function getRootTag(): string
protected function getFieldName(string | int $field): string
{
if (! is_string($field)) {
$useItemName = $this->rootTag === self::DEFAULT_ROOT || $this->forceItemName;
$useItemName = $this->rootTag === static::DEFAULT_ROOT || $this->forceItemName;

return $useItemName ? $this->itemName : Str::singular($this->getRootTag());
}
Expand Down