Skip to content

Commit 63cab52

Browse files
committed
Makes services readonly
1 parent 723391d commit 63cab52

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

.php-cs-fixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
'remove_inheritdoc' => true,
2828
'allow_unused_params' => false,
2929
],
30-
'no_trailing_comma_in_singleline_array' => true,
30+
'no_trailing_comma_in_singleline' => true,
3131
'no_unused_imports' => true,
3232
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
3333
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],

src/Rules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class Rules implements PublicSuffixList
3232
/**
3333
* @param array{ICANN_DOMAINS: array<array>, PRIVATE_DOMAINS: array<array>} $rules
3434
*/
35-
private function __construct(private array $rules)
35+
private function __construct(private readonly array $rules)
3636
{
3737
}
3838

src/Suffix.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class Suffix implements EffectiveTopLevelDomain
1616

1717
private function __construct(
1818
private DomainName $domain,
19-
private string $section
19+
private readonly string $section
2020
) {
2121
}
2222

@@ -132,18 +132,12 @@ public function toString(): string
132132

133133
public function toAscii(): self
134134
{
135-
$clone = clone $this;
136-
$clone->domain = $this->domain->toAscii();
137-
138-
return $clone;
135+
return new self($this->domain->toAscii(), $this->section);
139136
}
140137

141138
public function toUnicode(): self
142139
{
143-
$clone = clone $this;
144-
$clone->domain = $this->domain->toUnicode();
145-
146-
return $clone;
140+
return new self($this->domain->toUnicode(), $this->section);
147141
}
148142

149143
public function normalize(DomainName $domain): self
@@ -153,9 +147,6 @@ public function normalize(DomainName $domain): self
153147
$newDomain = $newDomain->toAscii();
154148
}
155149

156-
$clone = clone $this;
157-
$clone->domain = $newDomain;
158-
159-
return $clone;
150+
return new self($newDomain, $this->section);
160151
}
161152
}

src/TopLevelDomains.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ final class TopLevelDomains implements TopLevelDomainList
2222
* @param array<string, int> $records
2323
*/
2424
private function __construct(
25-
private array $records,
26-
private string $version,
27-
private DateTimeImmutable $lastUpdated
25+
private readonly array $records,
26+
private readonly string $version,
27+
private readonly DateTimeImmutable $lastUpdated
2828
) {
2929
}
3030

0 commit comments

Comments
 (0)