Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UndefinedAttributeClass errorLevel="suppress" />
</issueHandlers>
</psalm>
9 changes: 9 additions & 0 deletions src/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ private function __construct(
*
* @param Sequence<Node|Element|Custom>|null $children
*/
#[\NoDiscard]
public static function of(Type $type, ?Sequence $children = null): self
{
return new self($type, $children ?? Sequence::of());
}

#[\NoDiscard]
public function type(): Type
{
return $this->type;
Expand All @@ -49,11 +51,13 @@ public function type(): Type
/**
* @return Sequence<Node|Element|Custom>
*/
#[\NoDiscard]
public function children(): Sequence
{
return $this->children;
}

#[\NoDiscard]
public function hasChildren(): bool
{
return !$this->children->empty();
Expand All @@ -62,6 +66,7 @@ public function hasChildren(): bool
/**
* @param callable(Node|Element|Custom): bool $filter
*/
#[\NoDiscard]
public function filterChild(callable $filter): self
{
return new self(
Expand All @@ -73,6 +78,7 @@ public function filterChild(callable $filter): self
/**
* @param callable(Node|Element|Custom): (Node|Element|Custom) $map
*/
#[\NoDiscard]
public function mapChild(callable $map): self
{
return new self(
Expand All @@ -81,6 +87,7 @@ public function mapChild(callable $map): self
);
}

#[\NoDiscard]
public function prependChild(Node|Element|Custom $child): self
{
return new self(
Expand All @@ -89,6 +96,7 @@ public function prependChild(Node|Element|Custom $child): self
);
}

#[\NoDiscard]
public function appendChild(Node|Element|Custom $child): self
{
return new self(
Expand All @@ -97,6 +105,7 @@ public function appendChild(Node|Element|Custom $child): self
);
}

#[\NoDiscard]
public function asContent(Format $format = Format::pretty): Content
{
/** @var Maybe<XMLDocument\Encoding> */
Expand Down
3 changes: 3 additions & 0 deletions src/Element/A.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private function __construct(
* @param Sequence<Attribute>|null $attributes
* @param Sequence<Node|Element|Custom>|null $children
*/
#[\NoDiscard]
public static function of(
Url $href,
?Sequence $attributes = null,
Expand All @@ -45,12 +46,14 @@ public static function of(
);
}

#[\NoDiscard]
public function href(): Url
{
return $this->href;
}

#[\Override]
#[\NoDiscard]
public function normalize(): Element
{
return $this->element->addAttribute(
Expand Down
3 changes: 3 additions & 0 deletions src/Element/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private function __construct(
*
* @param Sequence<Attribute>|null $attributes
*/
#[\NoDiscard]
public static function of(Url $href, ?Sequence $attributes = null): self
{
return new self($href, Element::selfClosing(
Expand All @@ -36,12 +37,14 @@ public static function of(Url $href, ?Sequence $attributes = null): self
));
}

#[\NoDiscard]
public function href(): Url
{
return $this->href;
}

#[\Override]
#[\NoDiscard]
public function normalize(): Element
{
return $this->element->addAttribute(
Expand Down
3 changes: 3 additions & 0 deletions src/Element/Img.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private function __construct(
*
* @param Sequence<Attribute>|null $attributes
*/
#[\NoDiscard]
public static function of(Url $src, ?Sequence $attributes = null): self
{
return new self($src, Element::selfClosing(
Expand All @@ -36,12 +37,14 @@ public static function of(Url $src, ?Sequence $attributes = null): self
));
}

#[\NoDiscard]
public function src(): Url
{
return $this->src;
}

#[\Override]
#[\NoDiscard]
public function normalize(): Element
{
return $this->element->addAttribute(
Expand Down
4 changes: 4 additions & 0 deletions src/Element/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private function __construct(
* @param non-empty-string $relationship
* @param Sequence<Attribute>|null $attributes
*/
#[\NoDiscard]
public static function of(
Url $href,
string $relationship,
Expand All @@ -48,6 +49,7 @@ public static function of(
);
}

#[\NoDiscard]
public function href(): Url
{
return $this->href;
Expand All @@ -56,12 +58,14 @@ public function href(): Url
/**
* @return non-empty-string
*/
#[\NoDiscard]
public function relationship(): string
{
return $this->relationship;
}

#[\Override]
#[\NoDiscard]
public function normalize(): Element
{
return $this
Expand Down
2 changes: 2 additions & 0 deletions src/Element/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private function __construct(private Element $element)
*
* @param Sequence<Attribute>|null $attributes
*/
#[\NoDiscard]
public static function of(Node $text, ?Sequence $attributes = null): self
{
return new self(Element::of(
Expand All @@ -36,6 +37,7 @@ public static function of(Node $text, ?Sequence $attributes = null): self
}

#[\Override]
#[\NoDiscard]
public function normalize(): Element
{
return $this->element;
Expand Down
2 changes: 2 additions & 0 deletions src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private function __construct(private Translator $translate)
/**
* @return Attempt<Document|Node|Element|Custom>
*/
#[\NoDiscard]
public function __invoke(Content $html): Attempt
{
$content = $html->toString();
Expand All @@ -41,6 +42,7 @@ public function __invoke(Content $html): Attempt
}
}

#[\NoDiscard]
public static function new(): self
{
return new self(
Expand Down
2 changes: 2 additions & 0 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private function __construct(
/**
* @return Attempt<Document|Element|Custom|Node>
*/
#[\NoDiscard]
public function __invoke(\Dom\Node $node): Attempt
{
return $this
Expand All @@ -49,6 +50,7 @@ public function __invoke(\Dom\Node $node): Attempt
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function new(): self
{
return new self(XmlTranslator::of(
Expand Down
4 changes: 4 additions & 0 deletions src/Visitor/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private function __construct(private string $name)
/**
* @return Maybe<Model|Custom>
*/
#[\NoDiscard]
public function __invoke(Document|Node|Model|Custom $node): Maybe
{
return match (true) {
Expand All @@ -45,6 +46,7 @@ public function __invoke(Document|Node|Model|Custom $node): Maybe
*
* @param non-empty-string $name
*/
#[\NoDiscard]
public static function of(string $name): self
{
return new self($name);
Expand All @@ -53,6 +55,7 @@ public static function of(string $name): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function head(): self
{
return new self('head');
Expand All @@ -61,6 +64,7 @@ public static function head(): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function body(): self
{
return new self('body');
Expand Down
2 changes: 2 additions & 0 deletions src/Visitor/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private function __construct(private string $name)
/**
* @return Sequence<Element|Custom>
*/
#[\NoDiscard]
public function __invoke(Document|Node|Element|Custom $node): Sequence
{
return match (true) {
Expand All @@ -41,6 +42,7 @@ public function __invoke(Document|Node|Element|Custom $node): Sequence
*
* @param non-empty-string $name
*/
#[\NoDiscard]
public static function of(string $name): self
{
return new self($name);
Expand Down