diff --git a/src/Document/Type.php b/src/Document/Type.php index 3eab7a1..e684899 100644 --- a/src/Document/Type.php +++ b/src/Document/Type.php @@ -11,22 +11,14 @@ */ final class Type { - /** @var non-empty-string */ - private string $name; - private string $publicId; - private string $systemId; - /** * @param non-empty-string $name */ private function __construct( - string $name, - string $publicId, - string $systemId, + private string $name, + private string $publicId, + private string $systemId, ) { - $this->name = $name; - $this->publicId = $publicId; - $this->systemId = $systemId; } /** diff --git a/src/Document/Version.php b/src/Document/Version.php index e4416cc..b1add98 100644 --- a/src/Document/Version.php +++ b/src/Document/Version.php @@ -11,26 +11,21 @@ */ final class Version { - /** @var 0|positive-int */ - private int $major; - /** @var 0|positive-int */ - private int $minor; - /** - * @param 0|positive-int $major - * @param 0|positive-int $minor + * @param int<0, max> $major + * @param int<0, max> $minor */ - private function __construct(int $major, int $minor) - { - $this->major = $major; - $this->minor = $minor; + private function __construct( + private int $major, + private int $minor, + ) { } /** * @psalm-pure * - * @param 0|positive-int $major - * @param 0|positive-int $minor + * @param int<0, max> $major + * @param int<0, max> $minor * * @throws DomainException */ @@ -58,7 +53,7 @@ public static function maybe(int $major, int $minor = 0): Maybe } /** - * @return 0|positive-int + * @return int<0, max> */ public function major(): int { @@ -66,7 +61,7 @@ public function major(): int } /** - * @return 0|positive-int + * @return int<0, max> */ public function minor(): int { diff --git a/src/Node/CharacterData.php b/src/Node/CharacterData.php index e301069..7ab78e8 100644 --- a/src/Node/CharacterData.php +++ b/src/Node/CharacterData.php @@ -9,11 +9,8 @@ */ final class CharacterData implements Implementation { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Node/Comment.php b/src/Node/Comment.php index 161a449..81ea6fd 100644 --- a/src/Node/Comment.php +++ b/src/Node/Comment.php @@ -9,11 +9,8 @@ */ final class Comment implements Implementation { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Node/EntityReference.php b/src/Node/EntityReference.php index 6e2dac0..e813069 100644 --- a/src/Node/EntityReference.php +++ b/src/Node/EntityReference.php @@ -9,11 +9,8 @@ */ final class EntityReference implements Implementation { - private string $data; - - private function __construct(string $data) + private function __construct(private string $data) { - $this->data = $data; } /** diff --git a/src/Node/ProcessingInstruction.php b/src/Node/ProcessingInstruction.php index 2f451bf..d682e38 100644 --- a/src/Node/ProcessingInstruction.php +++ b/src/Node/ProcessingInstruction.php @@ -10,13 +10,10 @@ */ final class ProcessingInstruction implements Implementation { - private string $kind; - private string $value; - - private function __construct(string $kind, string $value) - { - $this->kind = $kind; - $this->value = $value; + private function __construct( + private string $kind, + private string $value, + ) { } /** diff --git a/src/Node/Text.php b/src/Node/Text.php index 65301c9..342c618 100644 --- a/src/Node/Text.php +++ b/src/Node/Text.php @@ -9,11 +9,8 @@ */ final class Text implements Implementation { - private CharacterData $data; - - private function __construct(string $data) + private function __construct(private string $data) { - $this->data = CharacterData::of($data); } /** @@ -27,14 +24,14 @@ public static function of(string $data): self #[\Override] public function content(): string { - return $this->data->content(); + return $this->data; } #[\Override] public function render(\XMLWriter $writer): string { /** @psalm-suppress ImpureMethodCall */ - $writer->text($this->data->content()); + $writer->text($this->data); /** @psalm-suppress ImpureMethodCall */ return $writer->outputMemory();