diff --git a/build/bootstrap.php b/build/bootstrap.php index 7b20021b..41f5e857 100644 --- a/build/bootstrap.php +++ b/build/bootstrap.php @@ -1,5 +1,5 @@ #!/usr/bin/env php -assert($node); + return instance_of(Attr::class)->assert($node); } diff --git a/src/Xml/Dom/Assert/assert_cdata.php b/src/Xml/Dom/Assert/assert_cdata.php index 9d3b426a..a216dc1b 100644 --- a/src/Xml/Dom/Assert/assert_cdata.php +++ b/src/Xml/Dom/Assert/assert_cdata.php @@ -4,15 +4,15 @@ namespace VeeWee\Xml\Dom\Assert; -use \Dom\CDATASection; +use Dom\CDATASection; use Psl\Type\Exception\AssertException; use function Psl\Type\instance_of; /** - * @psalm-assert \Dom\CDATASection $node + * @psalm-assert CDATASection $node * @throws AssertException */ -function assert_cdata(mixed $node): \Dom\CDATASection +function assert_cdata(mixed $node): CDATASection { - return instance_of(\Dom\CDATASection::class)->assert($node); + return instance_of(CDATASection::class)->assert($node); } diff --git a/src/Xml/Dom/Assert/assert_document.php b/src/Xml/Dom/Assert/assert_document.php index f4b272b9..e08c0269 100644 --- a/src/Xml/Dom/Assert/assert_document.php +++ b/src/Xml/Dom/Assert/assert_document.php @@ -4,15 +4,15 @@ namespace VeeWee\Xml\Dom\Assert; -use \Dom\XMLDocument; +use Dom\XMLDocument; use Psl\Type\Exception\AssertException; use function Psl\Type\instance_of; /** - * @psalm-assert \Dom\XMLDocument $node + * @psalm-assert XMLDocument $node * @throws AssertException */ -function assert_document(mixed $node): \Dom\XMLDocument +function assert_document(mixed $node): XMLDocument { - return instance_of(\Dom\XMLDocument::class)->assert($node); + return instance_of(XMLDocument::class)->assert($node); } diff --git a/src/Xml/Dom/Assert/assert_dom_node_list.php b/src/Xml/Dom/Assert/assert_dom_node_list.php index 164a5a09..3fa31a3f 100644 --- a/src/Xml/Dom/Assert/assert_dom_node_list.php +++ b/src/Xml/Dom/Assert/assert_dom_node_list.php @@ -4,15 +4,15 @@ namespace VeeWee\Xml\Dom\Assert; -use \Dom\NodeList; +use Dom\NodeList; use Psl\Type\Exception\AssertException; use function Psl\Type\instance_of; /** - * @psalm-assert \Dom\NodeList $node + * @psalm-assert NodeList $node * @throws AssertException */ -function assert_dom_node_list(mixed $node): \Dom\NodeList +function assert_dom_node_list(mixed $node): NodeList { - return instance_of(\Dom\NodeList::class)->assert($node); + return instance_of(NodeList::class)->assert($node); } diff --git a/src/Xml/Dom/Assert/assert_element.php b/src/Xml/Dom/Assert/assert_element.php index ba22edc4..ff33be9b 100644 --- a/src/Xml/Dom/Assert/assert_element.php +++ b/src/Xml/Dom/Assert/assert_element.php @@ -4,15 +4,15 @@ namespace VeeWee\Xml\Dom\Assert; -use \Dom\Element; +use Dom\Element; use Psl\Type\Exception\AssertException; use function Psl\Type\instance_of; /** - * @psalm-assert \Dom\Element $node + * @psalm-assert Element $node * @throws AssertException */ -function assert_element(mixed $node): \Dom\Element +function assert_element(mixed $node): Element { - return instance_of(\Dom\Element::class)->assert($node); + return instance_of(Element::class)->assert($node); } diff --git a/src/Xml/Dom/Builder/Builder.php b/src/Xml/Dom/Builder/Builder.php index 5bee80c7..5e3a0684 100644 --- a/src/Xml/Dom/Builder/Builder.php +++ b/src/Xml/Dom/Builder/Builder.php @@ -4,9 +4,9 @@ namespace VeeWee\Xml\Dom\Builder; -use \Dom\Node; +use Dom\Node; interface Builder { - public function __invoke(\Dom\Node $node): \Dom\Node; + public function __invoke(Node $node): Node; } diff --git a/src/Xml/Dom/Builder/attribute.php b/src/Xml/Dom/Builder/attribute.php index 6ff19ca2..28ed2213 100644 --- a/src/Xml/Dom/Builder/attribute.php +++ b/src/Xml/Dom/Builder/attribute.php @@ -5,14 +5,14 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Element; +use Dom\Element; /** - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ function attribute(string $name, string $value): Closure { - return static function (\Dom\Element $node) use ($name, $value): \Dom\Element { + return static function (Element $node) use ($name, $value): Element { $node->setAttribute($name, $value); return $node; diff --git a/src/Xml/Dom/Builder/attributes.php b/src/Xml/Dom/Builder/attributes.php index 4c7d1e5d..df14830e 100644 --- a/src/Xml/Dom/Builder/attributes.php +++ b/src/Xml/Dom/Builder/attributes.php @@ -5,19 +5,19 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Element; +use Dom\Element; use function Psl\Iter\reduce_with_keys; /** * @param array $attributes - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ function attributes(array $attributes): Closure { - return static function (\Dom\Element $node) use ($attributes): \Dom\Element { + return static function (Element $node) use ($attributes): Element { return reduce_with_keys( $attributes, - static fn (\Dom\Element $node, string $name, string $value) + static fn (Element $node, string $name, string $value) => attribute($name, $value)($node), $node ); diff --git a/src/Xml/Dom/Builder/cdata.php b/src/Xml/Dom/Builder/cdata.php index fa713805..2602a761 100644 --- a/src/Xml/Dom/Builder/cdata.php +++ b/src/Xml/Dom/Builder/cdata.php @@ -5,20 +5,20 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\CDATASection; -use \Dom\Node; +use Dom\CDATASection; +use Dom\Node; use function VeeWee\Xml\Dom\Assert\assert_cdata; use function VeeWee\Xml\Dom\Locator\Node\detect_document; use function VeeWee\Xml\Internal\configure; /** - * @param list $configurators + * @param list $configurators * - * @return Closure(\Dom\Node): \Dom\CDATASection + * @return Closure(Node): CDATASection */ function cdata(string $data, ...$configurators): Closure { - return static function (\Dom\Node $node) use ($data, $configurators): \Dom\CDATASection { + return static function (Node $node) use ($data, $configurators): CDATASection { $document = detect_document($node); return assert_cdata( diff --git a/src/Xml/Dom/Builder/children.php b/src/Xml/Dom/Builder/children.php index c30ec1e0..2b8115f4 100644 --- a/src/Xml/Dom/Builder/children.php +++ b/src/Xml/Dom/Builder/children.php @@ -5,18 +5,18 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Node; +use Dom\Node; /** - * @template T of \Dom\Node + * @template T of Node * - * @param list $builders + * @param list $builders * * @return Closure(T): T */ function children(callable ...$builders): Closure { - return static function (\Dom\Node $node) use ($builders): \Dom\Node { + return static function (Node $node) use ($builders): Node { foreach ($builders as $builder) { $node->appendChild($builder($node)); } diff --git a/src/Xml/Dom/Builder/element.php b/src/Xml/Dom/Builder/element.php index 7ccab1c7..e476e09f 100644 --- a/src/Xml/Dom/Builder/element.php +++ b/src/Xml/Dom/Builder/element.php @@ -5,20 +5,20 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Element; -use \Dom\Node; +use Dom\Element; +use Dom\Node; use function VeeWee\Xml\Dom\Assert\assert_element; use function VeeWee\Xml\Dom\Locator\Node\detect_document; use function VeeWee\Xml\Internal\configure; /** - * @param list $configurators + * @param list $configurators * - * @return Closure(\Dom\Node): \Dom\Element + * @return Closure(Node): Element */ function element(string $name, callable ...$configurators): Closure { - return static function (\Dom\Node $node) use ($name, $configurators): \Dom\Element { + return static function (Node $node) use ($name, $configurators): Element { $document = detect_document($node); return assert_element( diff --git a/src/Xml/Dom/Builder/escaped_value.php b/src/Xml/Dom/Builder/escaped_value.php index 7e4d4407..8eb81f81 100644 --- a/src/Xml/Dom/Builder/escaped_value.php +++ b/src/Xml/Dom/Builder/escaped_value.php @@ -5,13 +5,14 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; +use Dom\Element; /** - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ function escaped_value(string $value): Closure { - return static function (\Dom\Element $node) use ($value): \Dom\Element { + return static function (Element $node) use ($value): Element { return value(htmlspecialchars($value, ENT_XML1|ENT_QUOTES))($node); }; } diff --git a/src/Xml/Dom/Builder/namespaced_attribute.php b/src/Xml/Dom/Builder/namespaced_attribute.php index 0de1d6e2..c21b6db0 100644 --- a/src/Xml/Dom/Builder/namespaced_attribute.php +++ b/src/Xml/Dom/Builder/namespaced_attribute.php @@ -5,15 +5,15 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Element; +use Dom\Element; use function VeeWee\Xml\Assertion\assert_strict_prefixed_name; /** - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ function namespaced_attribute(string $namespace, string $qualifiedName, string $value): Closure { - return static function (\Dom\Element $node) use ($namespace, $qualifiedName, $value): \Dom\Element { + return static function (Element $node) use ($namespace, $qualifiedName, $value): Element { assert_strict_prefixed_name($qualifiedName); $node->setAttributeNS($namespace, $qualifiedName, $value); diff --git a/src/Xml/Dom/Builder/namespaced_attributes.php b/src/Xml/Dom/Builder/namespaced_attributes.php index fe3e2e44..67cdc791 100644 --- a/src/Xml/Dom/Builder/namespaced_attributes.php +++ b/src/Xml/Dom/Builder/namespaced_attributes.php @@ -5,19 +5,19 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Element; +use Dom\Element; use function Psl\Iter\reduce_with_keys; /** * @param array $attributes - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ function namespaced_attributes(string $namespace, array $attributes): Closure { - return static function (\Dom\Element $node) use ($namespace, $attributes): \Dom\Element { + return static function (Element $node) use ($namespace, $attributes): Element { return reduce_with_keys( $attributes, - static fn (\Dom\Element $node, string $name, string $value) + static fn (Element $node, string $name, string $value) => namespaced_attribute($namespace, $name, $value)($node), $node ); diff --git a/src/Xml/Dom/Builder/namespaced_element.php b/src/Xml/Dom/Builder/namespaced_element.php index ebd5f492..a0913d02 100644 --- a/src/Xml/Dom/Builder/namespaced_element.php +++ b/src/Xml/Dom/Builder/namespaced_element.php @@ -5,20 +5,20 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Element; -use \Dom\Node; +use Dom\Element; +use Dom\Node; use function VeeWee\Xml\Dom\Assert\assert_element; use function VeeWee\Xml\Dom\Locator\Node\detect_document; use function VeeWee\Xml\Internal\configure; /** - * @param list $configurators + * @param list $configurators * - * @return Closure(\Dom\Node): \Dom\Element + * @return Closure(Node): Element */ function namespaced_element(string $namespace, string $qualifiedName, callable ...$configurators): Closure { - return static function (\Dom\Node $node) use ($namespace, $qualifiedName, $configurators): \Dom\Element { + return static function (Node $node) use ($namespace, $qualifiedName, $configurators): Element { $document = detect_document($node); return assert_element( diff --git a/src/Xml/Dom/Builder/nodes.php b/src/Xml/Dom/Builder/nodes.php index 2904243c..82560964 100644 --- a/src/Xml/Dom/Builder/nodes.php +++ b/src/Xml/Dom/Builder/nodes.php @@ -5,30 +5,30 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\XMLDocument; -use \Dom\Node; +use Dom\Node; +use Dom\XMLDocument; use function is_array; use function Psl\Iter\reduce; use function VeeWee\Xml\Dom\Locator\Node\detect_document; /** - * @param list|\Dom\Node)> $builders + * @param list|Node)> $builders * - * @return Closure(\Dom\XMLDocument): list<\Dom\Node> + * @return Closure(XMLDocument): list */ function nodes(callable ... $builders): Closure { return /** - * @return list<\Dom\Node> + * @return list */ - static fn (\Dom\Node $node): array + static fn (Node $node): array => reduce( $builders, /** - * @param list<\Dom\Node> $builds - * @param callable(\Dom\XMLDocument): (\Dom\Node|list<\Dom\Node>) $builder - * @return list<\Dom\Node> + * @param list $builds + * @param callable(XMLDocument): (Node|list) $builder + * @return list */ static function (array $builds, callable $builder) use ($node): array { $result = $builder(detect_document($node)); diff --git a/src/Xml/Dom/Builder/value.php b/src/Xml/Dom/Builder/value.php index edde041e..8ee36dd5 100644 --- a/src/Xml/Dom/Builder/value.php +++ b/src/Xml/Dom/Builder/value.php @@ -5,14 +5,14 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Element; +use Dom\Element; /** - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ function value(string $value): Closure { - return static function (\Dom\Element $node) use ($value): \Dom\Element { + return static function (Element $node) use ($value): Element { $node->substitutedNodeValue = $value; return $node; diff --git a/src/Xml/Dom/Builder/xmlns_attribute.php b/src/Xml/Dom/Builder/xmlns_attribute.php index 9f37c2da..e3cb0d4a 100644 --- a/src/Xml/Dom/Builder/xmlns_attribute.php +++ b/src/Xml/Dom/Builder/xmlns_attribute.php @@ -5,16 +5,16 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Element; +use Dom\Element; use VeeWee\Xml\Xmlns\Xmlns; use function VeeWee\Xml\Assertion\assert_strict_prefixed_name; /** - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ function xmlns_attribute(string $prefix, string $namespaceURI): Closure { - return static function (\Dom\Element $node) use ($prefix, $namespaceURI): \Dom\Element { + return static function (Element $node) use ($prefix, $namespaceURI): Element { $prefixed = 'xmlns:'.$prefix; assert_strict_prefixed_name($prefixed); diff --git a/src/Xml/Dom/Builder/xmlns_attributes.php b/src/Xml/Dom/Builder/xmlns_attributes.php index a3e58951..734fdec5 100644 --- a/src/Xml/Dom/Builder/xmlns_attributes.php +++ b/src/Xml/Dom/Builder/xmlns_attributes.php @@ -5,19 +5,19 @@ namespace VeeWee\Xml\Dom\Builder; use Closure; -use \Dom\Element; +use Dom\Element; use function Psl\Iter\reduce_with_keys; /** * @param array $attributes - A map of namespace prefix with namespace URI - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ function xmlns_attributes(array $attributes): Closure { - return static function (\Dom\Element $node) use ($attributes): \Dom\Element { + return static function (Element $node) use ($attributes): Element { return reduce_with_keys( $attributes, - static fn (\Dom\Element $node, string $name, string $value) + static fn (Element $node, string $name, string $value) => xmlns_attribute($name, $value)($node), $node ); diff --git a/src/Xml/Dom/Collection/NodeList.php b/src/Xml/Dom/Collection/NodeList.php index 52de224a..1ef69126 100644 --- a/src/Xml/Dom/Collection/NodeList.php +++ b/src/Xml/Dom/Collection/NodeList.php @@ -5,10 +5,11 @@ namespace VeeWee\Xml\Dom\Collection; use Countable; -use \Dom\Element; -use \Dom\Node; -use \Dom\NodeList as DOMNodeList; -use \Dom\XPath as DOMXPath; +use Dom\Element; +use Dom\HTMLCollection; +use Dom\Node; +use Dom\NodeList as DOMNodeList; +use Dom\XPath as DOMXPath; use Generator; use InvalidArgumentException; use IteratorAggregate; @@ -29,7 +30,7 @@ use function VeeWee\Xml\Dom\Locator\Element\siblings; /** - * @template T of \Dom\Node + * @template T of Node * @implements IteratorAggregate */ final class NodeList implements Countable, IteratorAggregate @@ -49,7 +50,7 @@ public function __construct(...$nodes) } /** - * @template X of \Dom\Node + * @template X of Node * @return self * * @psalm-suppress InvalidReturnType, InvalidReturnStatement - It is empty alright! @@ -60,16 +61,15 @@ public static function empty(): self } /** - * @param \Dom\HTMLCollection $list - * @return NodeList<\Dom\Element> + * @return NodeList */ - public static function fromDOMHTMLCollection(\Dom\HTMLCollection $list): self + public static function fromDOMHTMLCollection(HTMLCollection $list): self { return new self(...values($list->getIterator())); } /** - * @template X of \Dom\Node + * @template X of Node * @param DOMNodeList $list * @return NodeList */ @@ -79,7 +79,7 @@ public static function fromDOMNodeList(DOMNodeList $list): self } /** - * @template X of \Dom\Node + * @template X of Node * @param class-string $type * @return NodeList * @throws InvalidArgumentException @@ -145,7 +145,7 @@ public function forEach(callable $mapper): void } /** - * @template X of \Dom\Node + * @template X of Node * @param callable(T): iterable $mapper * * @return NodeList @@ -194,17 +194,17 @@ public function reduce(callable $reducer, mixed $initial): mixed /** * @param list $configurators - * @throws RuntimeException - * @return NodeList<\Dom\Node> + * @return NodeList + *@throws RuntimeException */ public function query(string $xpath, callable ... $configurators): self { return $this->detect( /** * @param T $node - * @return NodeList<\Dom\Node> + * @return NodeList */ - static fn (\Dom\Node $node): NodeList + static fn (Node $node): NodeList => Xpath::fromUnsafeNode($node, ...$configurators)->query($xpath, $node) ); } @@ -218,7 +218,7 @@ public function query(string $xpath, callable ... $configurators): self public function evaluate(string $expression, TypeInterface $type, callable ... $configurators): array { return $this->map( - static fn (\Dom\Node $node): mixed + static fn (Node $node): mixed => Xpath::fromUnsafeNode($node, ...$configurators)->evaluate($expression, $type, $node) ); } @@ -272,46 +272,46 @@ public function expectLast(string $message = '') } /** - * @return NodeList<\Dom\Element> + * @return NodeList */ public function siblings(): self { return $this->detect( /** - * @return iterable<\Dom\Element> + * @return iterable */ - static fn (\Dom\Node $node): NodeList => siblings($node) + static fn (Node $node): NodeList => siblings($node) ); } /** - * @return NodeList<\Dom\Element> + * @return NodeList */ public function ancestors(): self { return $this->detect( /** - * @return iterable<\Dom\Element> + * @return iterable */ - static fn (\Dom\Node $node): NodeList => ancestors($node) + static fn (Node $node): NodeList => ancestors($node) ); } /** - * @return NodeList<\Dom\Element> + * @return NodeList */ public function children(): self { return $this->detect( /** - * @return iterable<\Dom\Element> + * @return iterable */ - static fn (\Dom\Node $node): NodeList => children($node) + static fn (Node $node): NodeList => children($node) ); } /** - * @template X of \Dom\Node + * @template X of Node * @param class-string $type * @return NodeList * @throws InvalidArgumentException diff --git a/src/Xml/Dom/Configurator/Configurator.php b/src/Xml/Dom/Configurator/Configurator.php index 1f0cc791..951dfdaa 100644 --- a/src/Xml/Dom/Configurator/Configurator.php +++ b/src/Xml/Dom/Configurator/Configurator.php @@ -4,9 +4,9 @@ namespace VeeWee\Xml\Dom\Configurator; -use \Dom\XMLDocument; +use Dom\XMLDocument; interface Configurator { - public function __invoke(\Dom\XMLDocument $document): \Dom\XMLDocument; + public function __invoke(XMLDocument $document): XMLDocument; } diff --git a/src/Xml/Dom/Configurator/canonicalize.php b/src/Xml/Dom/Configurator/canonicalize.php index cb4b1a25..22e872be 100644 --- a/src/Xml/Dom/Configurator/canonicalize.php +++ b/src/Xml/Dom/Configurator/canonicalize.php @@ -5,7 +5,7 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument as DOMDocument; +use Dom\XMLDocument as DOMDocument; use VeeWee\Xml\Dom\Document; use function Psl\Type\non_empty_string; use function VeeWee\Xml\Dom\Loader\xml_string_loader; diff --git a/src/Xml/Dom/Configurator/comparable.php b/src/Xml/Dom/Configurator/comparable.php index 5c24acab..92bb43a2 100644 --- a/src/Xml/Dom/Configurator/comparable.php +++ b/src/Xml/Dom/Configurator/comparable.php @@ -5,12 +5,12 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; use VeeWee\Xml\Dom\Traverser\Visitor\SortAttributes; use function VeeWee\Xml\Internal\configure; /** - * @return Closure(\Dom\XMLDocument): \Dom\XMLDocument + * @return Closure(XMLDocument): XMLDocument */ function comparable(): Closure { diff --git a/src/Xml/Dom/Configurator/document_uri.php b/src/Xml/Dom/Configurator/document_uri.php index 8c39e0e8..14d1e33f 100644 --- a/src/Xml/Dom/Configurator/document_uri.php +++ b/src/Xml/Dom/Configurator/document_uri.php @@ -5,15 +5,15 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; /** * @param non-empty-string $documentUri - * @return Closure(\Dom\XMLDocument): \Dom\XMLDocument + * @return Closure(XMLDocument): XMLDocument */ function document_uri(string $documentUri): Closure { - return static function (\Dom\XMLDocument $document) use ($documentUri) : \Dom\XMLDocument { + return static function (XMLDocument $document) use ($documentUri) : XMLDocument { $document->documentURI = $documentUri; return $document; diff --git a/src/Xml/Dom/Configurator/format_output.php b/src/Xml/Dom/Configurator/format_output.php index d0799d3e..10807c23 100644 --- a/src/Xml/Dom/Configurator/format_output.php +++ b/src/Xml/Dom/Configurator/format_output.php @@ -5,16 +5,16 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; /** * Consider using it together with LIBXML_NOEMPTYTAG in the XML loader. * - * @return Closure(\Dom\XMLDocument): \Dom\XMLDocument + * @return Closure(XMLDocument): XMLDocument */ function format_output(bool $formatOutput = true): Closure { - return static function (\Dom\XMLDocument $document) use ($formatOutput) : \Dom\XMLDocument { + return static function (XMLDocument $document) use ($formatOutput) : XMLDocument { $document->formatOutput = $formatOutput; return $document; diff --git a/src/Xml/Dom/Configurator/normalize.php b/src/Xml/Dom/Configurator/normalize.php index 25c41e1a..c25e9b4a 100644 --- a/src/Xml/Dom/Configurator/normalize.php +++ b/src/Xml/Dom/Configurator/normalize.php @@ -5,14 +5,14 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; /** - * @return Closure(\Dom\XMLDocument): \Dom\XMLDocument + * @return Closure(XMLDocument): XMLDocument */ function normalize(): Closure { - return static function (\Dom\XMLDocument $document): \Dom\XMLDocument { + return static function (XMLDocument $document): XMLDocument { $document->normalize(); return $document; diff --git a/src/Xml/Dom/Configurator/optimize_namespaces.php b/src/Xml/Dom/Configurator/optimize_namespaces.php index 9cba72d9..49f5f1a7 100644 --- a/src/Xml/Dom/Configurator/optimize_namespaces.php +++ b/src/Xml/Dom/Configurator/optimize_namespaces.php @@ -5,15 +5,15 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; use function VeeWee\Xml\Dom\Manipulator\Document\optimize_namespaces as optimize_namespaces_manipulator; /** - * @return Closure(\Dom\XMLDocument): \Dom\XMLDocument + * @return Closure(XMLDocument): XMLDocument */ function optimize_namespaces(string $prefix = 'ns'): Closure { - return static function (\Dom\XMLDocument $document) use ($prefix) : \Dom\XMLDocument { + return static function (XMLDocument $document) use ($prefix) : XMLDocument { optimize_namespaces_manipulator($document, $prefix); return $document; diff --git a/src/Xml/Dom/Configurator/pretty_print.php b/src/Xml/Dom/Configurator/pretty_print.php index 462c104f..88f2ec93 100644 --- a/src/Xml/Dom/Configurator/pretty_print.php +++ b/src/Xml/Dom/Configurator/pretty_print.php @@ -5,15 +5,16 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; +use Dom\XMLDocument; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Loader\xml_string_loader; /** - * @return Closure(\Dom\XMLDocument): \Dom\XMLDocument + * @return Closure(XMLDocument): XMLDocument */ function pretty_print(): Closure { - return static function (\Dom\XMLDocument $document): \Dom\XMLDocument { + return static function (XMLDocument $document): XMLDocument { $trimmed = Document::fromLoader( xml_string_loader( Document::fromUnsafeDocument($document)->toXmlString(), diff --git a/src/Xml/Dom/Configurator/traverse.php b/src/Xml/Dom/Configurator/traverse.php index 5abde59c..87b4b834 100644 --- a/src/Xml/Dom/Configurator/traverse.php +++ b/src/Xml/Dom/Configurator/traverse.php @@ -5,7 +5,7 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument as DOMDocument; +use Dom\XMLDocument as DOMDocument; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Dom\Traverser\Visitor; diff --git a/src/Xml/Dom/Configurator/trim_spaces.php b/src/Xml/Dom/Configurator/trim_spaces.php index e58d558c..0518055d 100644 --- a/src/Xml/Dom/Configurator/trim_spaces.php +++ b/src/Xml/Dom/Configurator/trim_spaces.php @@ -5,16 +5,16 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Loader\xml_string_loader; /** - * @return Closure(\Dom\XMLDocument): \Dom\XMLDocument + * @return Closure(XMLDocument): XMLDocument */ function trim_spaces(): Closure { - return static function (\Dom\XMLDocument $document): \Dom\XMLDocument { + return static function (XMLDocument $document): XMLDocument { $trimmed = Document::fromLoader( xml_string_loader( Document::fromUnsafeDocument($document)->toXmlString(), diff --git a/src/Xml/Dom/Configurator/utf8.php b/src/Xml/Dom/Configurator/utf8.php index 708f7c50..383b3e46 100644 --- a/src/Xml/Dom/Configurator/utf8.php +++ b/src/Xml/Dom/Configurator/utf8.php @@ -5,14 +5,14 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; /** - * @return Closure(\Dom\XMLDocument): \Dom\XMLDocument + * @return Closure(XMLDocument): XMLDocument */ function utf8(): Closure { - return static function (\Dom\XMLDocument $document): \Dom\XMLDocument { + return static function (XMLDocument $document): XMLDocument { $document->charset = 'UTF-8'; return $document; diff --git a/src/Xml/Dom/Configurator/validator.php b/src/Xml/Dom/Configurator/validator.php index 5eb59668..ed793507 100644 --- a/src/Xml/Dom/Configurator/validator.php +++ b/src/Xml/Dom/Configurator/validator.php @@ -5,16 +5,16 @@ namespace VeeWee\Xml\Dom\Configurator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; use VeeWee\Xml\ErrorHandling\Issue\Issue; use VeeWee\Xml\ErrorHandling\Issue\IssueCollection; use VeeWee\Xml\ErrorHandling\Issue\Level; use VeeWee\Xml\Exception\RuntimeException; /** - * @param callable(\Dom\XMLDocument): IssueCollection $validator + * @param callable(XMLDocument): IssueCollection $validator * - * @return Closure(\Dom\XMLDocument): \Dom\XMLDocument + * @return Closure(XMLDocument): XMLDocument */ function validator(callable $validator, ?Level $minimumLevel = null): Closure { @@ -24,7 +24,7 @@ function validator(callable $validator, ?Level $minimumLevel = null): Closure /** * @throws RuntimeException */ - static function (\Dom\XMLDocument $document) use ($validator, $minimumLevel): \Dom\XMLDocument { + static function (XMLDocument $document) use ($validator, $minimumLevel): XMLDocument { $issues = $validator($document) ->filter(static fn (Issue $issue): bool => $issue->level()->value() >= $minimumLevel->value()); diff --git a/src/Xml/Dom/Document.php b/src/Xml/Dom/Document.php index 9108f820..74b08c92 100644 --- a/src/Xml/Dom/Document.php +++ b/src/Xml/Dom/Document.php @@ -5,10 +5,10 @@ namespace VeeWee\Xml\Dom; use Closure; -use \Dom\XMLDocument; -use \Dom\Element; -use \Dom\Node; -use \Dom\XPath as DOMXPath; +use Dom\Element; +use Dom\Node; +use Dom\XMLDocument; +use Dom\XPath as DOMXPath; use VeeWee\Xml\Dom\Traverser\Traverser; use VeeWee\Xml\Dom\Traverser\Visitor; use VeeWee\Xml\ErrorHandling\Issue\IssueCollection; @@ -81,7 +81,7 @@ public static function fromXmlString(string $xml, callable ...$configurators): s * * @throws RuntimeException */ - public static function fromXmlNode(\Dom\Node $node, callable ...$configurators): self + public static function fromXmlNode(Node $node, callable ...$configurators): self { return self::fromLoader(Loader\xml_node_loader($node), ...$configurators); } @@ -112,7 +112,7 @@ public function locate(callable $locator) return $locator($this->document); } - public function locateDocumentElement(): \Dom\Element + public function locateDocumentElement(): Element { return $this->locate(Locator\document_element()); } @@ -130,9 +130,9 @@ public function manipulate(callable $manipulator): self } /** - * @param list|\Dom\Node)> $builders + * @param list|Node)> $builders * - * @return list<\Dom\Node> + * @return list */ public function build(callable ... $builders): array { @@ -182,7 +182,7 @@ public function reconfigure(callable ... $configurators): self /** * @no-named-arguments */ - public function traverse(Visitor ... $visitors): \Dom\Node + public function traverse(Visitor ... $visitors): Node { $traverser = new Traverser(...$visitors); return $traverser->traverse($this->map(document_element())); @@ -207,7 +207,7 @@ public function stringifyDocumentElement(): string /** * @return non-empty-string */ - public function stringifyNode(\Dom\Node $node): string + public function stringifyNode(Node $node): string { return xml_string()($node); } diff --git a/src/Xml/Dom/Loader/Loader.php b/src/Xml/Dom/Loader/Loader.php index 73e1eb78..0cbdac45 100644 --- a/src/Xml/Dom/Loader/Loader.php +++ b/src/Xml/Dom/Loader/Loader.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Loader; -use \Dom\XMLDocument; +use Dom\XMLDocument; interface Loader { diff --git a/src/Xml/Dom/Loader/xml_node_loader.php b/src/Xml/Dom/Loader/xml_node_loader.php index 760cf85d..4b202188 100644 --- a/src/Xml/Dom/Loader/xml_node_loader.php +++ b/src/Xml/Dom/Loader/xml_node_loader.php @@ -5,15 +5,15 @@ namespace VeeWee\Xml\Dom\Loader; use Closure; -use \Dom\XMLDocument; -use \Dom\Node; +use Dom\Node; +use Dom\XMLDocument; use function VeeWee\Xml\Dom\Manipulator\Node\append_external_node; use function VeeWee\Xml\ErrorHandling\disallow_issues; /** * @return Closure(): XMLDocument */ -function xml_node_loader(\Dom\Node $importedNode): Closure +function xml_node_loader(Node $importedNode): Closure { return static fn () => disallow_issues(static function () use ($importedNode): XMLDocument { $document = XMLDocument::createEmpty(); diff --git a/src/Xml/Dom/Loader/xml_string_loader.php b/src/Xml/Dom/Loader/xml_string_loader.php index e2669aaa..3ddd08ab 100644 --- a/src/Xml/Dom/Loader/xml_string_loader.php +++ b/src/Xml/Dom/Loader/xml_string_loader.php @@ -5,7 +5,7 @@ namespace VeeWee\Xml\Dom\Loader; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; use function VeeWee\Xml\ErrorHandling\disallow_issues; /** diff --git a/src/Xml/Dom/Locator/Attribute/attributes_list.php b/src/Xml/Dom/Locator/Attribute/attributes_list.php index 93788ecc..55bcb5cb 100644 --- a/src/Xml/Dom/Locator/Attribute/attributes_list.php +++ b/src/Xml/Dom/Locator/Attribute/attributes_list.php @@ -4,16 +4,16 @@ namespace VeeWee\Xml\Dom\Locator\Attribute; -use \Dom\Attr; -use \Dom\Node; +use Dom\Attr; +use Dom\Node; use VeeWee\Xml\Dom\Collection\NodeList; use function Psl\Vec\values; use function VeeWee\Xml\Dom\Predicate\is_element; /** - * @return NodeList<\Dom\Attr> + * @return NodeList */ -function attributes_list(\Dom\Node $node): NodeList +function attributes_list(Node $node): NodeList { if (!is_element($node)) { return NodeList::empty(); diff --git a/src/Xml/Dom/Locator/Attribute/xmlns_attributes_list.php b/src/Xml/Dom/Locator/Attribute/xmlns_attributes_list.php index 64ff4e2a..e3e0d2a0 100644 --- a/src/Xml/Dom/Locator/Attribute/xmlns_attributes_list.php +++ b/src/Xml/Dom/Locator/Attribute/xmlns_attributes_list.php @@ -4,16 +4,18 @@ namespace VeeWee\Xml\Dom\Locator\Attribute; +use Dom\Attr; +use Dom\Node; use VeeWee\Xml\Dom\Collection\NodeList; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Predicate\is_xmlns_attribute; /** - * @return NodeList<\Dom\Attr> + * @return NodeList * @throws RuntimeException */ -function xmlns_attributes_list(\Dom\Node $node): NodeList +function xmlns_attributes_list(Node $node): NodeList { return attributes_list($node) - ->filter(static fn (\Dom\Attr $attribute): bool => is_xmlns_attribute($attribute)); + ->filter(static fn (Attr $attribute): bool => is_xmlns_attribute($attribute)); } diff --git a/src/Xml/Dom/Locator/Element/ancestors.php b/src/Xml/Dom/Locator/Element/ancestors.php index 52922492..9c9f29d0 100644 --- a/src/Xml/Dom/Locator/Element/ancestors.php +++ b/src/Xml/Dom/Locator/Element/ancestors.php @@ -4,23 +4,23 @@ namespace VeeWee\Xml\Dom\Locator\Element; -use \Dom\Element; -use \Dom\Node; +use Dom\Element; +use Dom\Node; use Generator; use VeeWee\Xml\Dom\Collection\NodeList; use function VeeWee\Xml\Dom\Predicate\is_element; /** - * @return NodeList<\Dom\Element> + * @return NodeList */ -function ancestors(\Dom\Node $node): NodeList +function ancestors(Node $node): NodeList { return new NodeList( ...( /** - * @return Generator + * @return Generator */ - static function (\Dom\Node $next) { + static function (Node $next) { while (($parent = $next->parentNode) !== null) { if (is_element($parent)) { yield $parent; diff --git a/src/Xml/Dom/Locator/Element/children.php b/src/Xml/Dom/Locator/Element/children.php index e5e77152..f68ea780 100644 --- a/src/Xml/Dom/Locator/Element/children.php +++ b/src/Xml/Dom/Locator/Element/children.php @@ -4,21 +4,21 @@ namespace VeeWee\Xml\Dom\Locator\Element; -use \Dom\Element; -use \Dom\Node; +use Dom\Element; +use Dom\Node; use VeeWee\Xml\Dom\Collection\NodeList; use function Psl\Vec\filter; use function VeeWee\Xml\Dom\Predicate\is_element; /** - * @return NodeList<\Dom\Element> + * @return NodeList */ -function children(\Dom\Node $node): NodeList +function children(Node $node): NodeList { - /** @var list<\Dom\Element> $children */ + /** @var list $children */ $children = filter( $node->childNodes, - static fn (\Dom\Node $node): bool => is_element($node) + static fn (Node $node): bool => is_element($node) ); return new NodeList(...$children); diff --git a/src/Xml/Dom/Locator/Element/locate_by_namespaced_tag_name.php b/src/Xml/Dom/Locator/Element/locate_by_namespaced_tag_name.php index 0cf9c4e6..7a5ef765 100644 --- a/src/Xml/Dom/Locator/Element/locate_by_namespaced_tag_name.php +++ b/src/Xml/Dom/Locator/Element/locate_by_namespaced_tag_name.php @@ -4,13 +4,13 @@ namespace VeeWee\Xml\Dom\Locator\Element; -use \Dom\Element; +use Dom\Element; use VeeWee\Xml\Dom\Collection\NodeList; /** - * @return NodeList<\Dom\Element> + * @return NodeList */ -function locate_by_namespaced_tag_name(\Dom\Element $node, string $namespace, string $localTagName): NodeList +function locate_by_namespaced_tag_name(Element $node, string $namespace, string $localTagName): NodeList { return NodeList::fromDOMHTMLCollection($node->getElementsByTagNameNS($namespace, $localTagName)); } diff --git a/src/Xml/Dom/Locator/Element/locate_by_tag_name.php b/src/Xml/Dom/Locator/Element/locate_by_tag_name.php index d740f656..258c9b1b 100644 --- a/src/Xml/Dom/Locator/Element/locate_by_tag_name.php +++ b/src/Xml/Dom/Locator/Element/locate_by_tag_name.php @@ -4,13 +4,13 @@ namespace VeeWee\Xml\Dom\Locator\Element; -use \Dom\Element; +use Dom\Element; use VeeWee\Xml\Dom\Collection\NodeList; /** - * @return NodeList<\Dom\Element> + * @return NodeList */ -function locate_by_tag_name(\Dom\Element $node, string $tag): NodeList +function locate_by_tag_name(Element $node, string $tag): NodeList { return NodeList::fromDOMHTMLCollection($node->getElementsByTagName($tag)); } diff --git a/src/Xml/Dom/Locator/Element/parent_element.php b/src/Xml/Dom/Locator/Element/parent_element.php index fb9fbd7e..478b3bd4 100644 --- a/src/Xml/Dom/Locator/Element/parent_element.php +++ b/src/Xml/Dom/Locator/Element/parent_element.php @@ -4,15 +4,15 @@ namespace VeeWee\Xml\Dom\Locator\Element; -use \Dom\Element; -use \Dom\Node; +use Dom\Element; +use Dom\Node; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Predicate\is_element; /** * @throws RuntimeException */ -function parent_element(\Dom\Node $child): \Dom\Element +function parent_element(Node $child): Element { $parent = $child->parentNode; if (!$parent|| !is_element($parent)) { diff --git a/src/Xml/Dom/Locator/Element/siblings.php b/src/Xml/Dom/Locator/Element/siblings.php index 1b4c4790..cfe472f7 100644 --- a/src/Xml/Dom/Locator/Element/siblings.php +++ b/src/Xml/Dom/Locator/Element/siblings.php @@ -4,21 +4,21 @@ namespace VeeWee\Xml\Dom\Locator\Element; -use \Dom\Element; -use \Dom\Node; +use Dom\Element; +use Dom\Node; use VeeWee\Xml\Dom\Collection\NodeList; use function Psl\Vec\filter; use function VeeWee\Xml\Dom\Predicate\is_element; /** - * @return NodeList<\Dom\Element> + * @return NodeList */ -function siblings(\Dom\Node $node): NodeList +function siblings(Node $node): NodeList { - /** @var NodeList<\Dom\Element> $siblings */ + /** @var NodeList $siblings */ $siblings = new NodeList(...filter( $node->parentNode?->childNodes?->getIterator() ?? [], - static fn (\Dom\Node $sibling): bool => is_element($sibling) && $sibling !== $node + static fn (Node $sibling): bool => is_element($sibling) && $sibling !== $node )); return $siblings; diff --git a/src/Xml/Dom/Locator/Node/children.php b/src/Xml/Dom/Locator/Node/children.php index 87690e92..fa523221 100644 --- a/src/Xml/Dom/Locator/Node/children.php +++ b/src/Xml/Dom/Locator/Node/children.php @@ -4,13 +4,13 @@ namespace VeeWee\Xml\Dom\Locator\Node; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Dom\Collection\NodeList; /** - * @return NodeList<\Dom\Node> + * @return NodeList */ -function children(\Dom\Node $node): NodeList +function children(Node $node): NodeList { return NodeList::fromDOMNodeList($node->childNodes); } diff --git a/src/Xml/Dom/Locator/Node/detect_document.php b/src/Xml/Dom/Locator/Node/detect_document.php index 45be27d7..9073ea84 100644 --- a/src/Xml/Dom/Locator/Node/detect_document.php +++ b/src/Xml/Dom/Locator/Node/detect_document.php @@ -4,7 +4,8 @@ namespace VeeWee\Xml\Dom\Locator\Node; -use \Dom\XMLDocument; +use Dom\Node; +use Dom\XMLDocument; use InvalidArgumentException; use function VeeWee\Xml\Dom\Assert\assert_document; use function VeeWee\Xml\Dom\Predicate\is_document; @@ -12,7 +13,7 @@ /** * @throws InvalidArgumentException */ -function detect_document(\Dom\Node $node): \Dom\XMLDocument +function detect_document(Node $node): XMLDocument { return is_document($node) ? $node : assert_document($node->ownerDocument); } diff --git a/src/Xml/Dom/Locator/Node/value.php b/src/Xml/Dom/Locator/Node/value.php index ff3ed06a..9f87c8dc 100644 --- a/src/Xml/Dom/Locator/Node/value.php +++ b/src/Xml/Dom/Locator/Node/value.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Locator\Node; -use \Dom\Node; +use Dom\Node; use Psl\Type\Exception\CoercionException; use Psl\Type\TypeInterface; @@ -17,7 +17,7 @@ * * @throws CoercionException */ -function value(\Dom\Node $node, TypeInterface $type) +function value(Node $node, TypeInterface $type) { return $type->coerce($node->substitutedNodeValue ?? ''); } diff --git a/src/Xml/Dom/Locator/Xmlns/linked_namespaces.php b/src/Xml/Dom/Locator/Xmlns/linked_namespaces.php index 109d88d5..e6d243f6 100644 --- a/src/Xml/Dom/Locator/Xmlns/linked_namespaces.php +++ b/src/Xml/Dom/Locator/Xmlns/linked_namespaces.php @@ -4,10 +4,13 @@ namespace VeeWee\Xml\Dom\Locator\Xmlns; +use Dom\Element; +use Dom\NamespaceInfo; + /** - * @return list<\Dom\NamespaceInfo> + * @return list */ -function linked_namespaces(\Dom\Element $node): array +function linked_namespaces(Element $node): array { return $node->getInScopeNamespaces(); } diff --git a/src/Xml/Dom/Locator/Xmlns/recursive_linked_namespaces.php b/src/Xml/Dom/Locator/Xmlns/recursive_linked_namespaces.php index e77bf535..b7f4c369 100644 --- a/src/Xml/Dom/Locator/Xmlns/recursive_linked_namespaces.php +++ b/src/Xml/Dom/Locator/Xmlns/recursive_linked_namespaces.php @@ -4,10 +4,13 @@ namespace VeeWee\Xml\Dom\Locator\Xmlns; +use Dom\Element; +use Dom\NamespaceInfo; + /** - * @return list<\Dom\NamespaceInfo> + * @return list */ -function recursive_linked_namespaces(\Dom\Element $node): array +function recursive_linked_namespaces(Element $node): array { return $node->getDescendantNamespaces(); } diff --git a/src/Xml/Dom/Locator/Xsd/locate_all_xsd_schemas.php b/src/Xml/Dom/Locator/Xsd/locate_all_xsd_schemas.php index 32425a9a..9607d3ed 100644 --- a/src/Xml/Dom/Locator/Xsd/locate_all_xsd_schemas.php +++ b/src/Xml/Dom/Locator/Xsd/locate_all_xsd_schemas.php @@ -4,14 +4,14 @@ namespace VeeWee\Xml\Dom\Locator\Xsd; -use \Dom\XMLDocument; +use Dom\XMLDocument; use Psl\Regex\Exception\RuntimeException; use VeeWee\Xml\Xsd\Schema\SchemaCollection; /** * @throws RuntimeException */ -function locate_all_xsd_schemas(\Dom\XMLDocument $document): SchemaCollection +function locate_all_xsd_schemas(XMLDocument $document): SchemaCollection { return new SchemaCollection( ...iterator_to_array(locate_namespaced_xsd_schemas($document)), diff --git a/src/Xml/Dom/Locator/Xsd/locate_namespaced_xsd_schemas.php b/src/Xml/Dom/Locator/Xsd/locate_namespaced_xsd_schemas.php index 7511f30b..17335356 100644 --- a/src/Xml/Dom/Locator/Xsd/locate_namespaced_xsd_schemas.php +++ b/src/Xml/Dom/Locator/Xsd/locate_namespaced_xsd_schemas.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Locator\Xsd; -use \Dom\XMLDocument; +use Dom\XMLDocument; use Psl\Regex\Exception\RuntimeException; use VeeWee\Xml\Xmlns\Xmlns; use VeeWee\Xml\Xsd\Schema\Schema; @@ -15,7 +15,7 @@ /** * @throws RuntimeException */ -function locate_namespaced_xsd_schemas(\Dom\XMLDocument $document): SchemaCollection +function locate_namespaced_xsd_schemas(XMLDocument $document): SchemaCollection { $schemaNs = Xmlns::xsi()->value(); $documentElement = document_element()($document); diff --git a/src/Xml/Dom/Locator/Xsd/locate_no_namespaced_xsd_schemas.php b/src/Xml/Dom/Locator/Xsd/locate_no_namespaced_xsd_schemas.php index 195ab41c..8a4ea5d5 100644 --- a/src/Xml/Dom/Locator/Xsd/locate_no_namespaced_xsd_schemas.php +++ b/src/Xml/Dom/Locator/Xsd/locate_no_namespaced_xsd_schemas.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Locator\Xsd; -use \Dom\XMLDocument; +use Dom\XMLDocument; use Psl\Regex\Exception\RuntimeException; use VeeWee\Xml\Xmlns\Xmlns; use VeeWee\Xml\Xsd\Schema\Schema; @@ -16,7 +16,7 @@ /** * @throws RuntimeException */ -function locate_no_namespaced_xsd_schemas(\Dom\XMLDocument $document): SchemaCollection +function locate_no_namespaced_xsd_schemas(XMLDocument $document): SchemaCollection { $schemaNs = Xmlns::xsi()->value(); $documentElement = document_element()($document); diff --git a/src/Xml/Dom/Locator/document_element.php b/src/Xml/Dom/Locator/document_element.php index 0c259ab2..9134c1d3 100644 --- a/src/Xml/Dom/Locator/document_element.php +++ b/src/Xml/Dom/Locator/document_element.php @@ -5,14 +5,14 @@ namespace VeeWee\Xml\Dom\Locator; use Closure; -use \Dom\XMLDocument; -use \Dom\Element; +use Dom\Element; +use Dom\XMLDocument; use function VeeWee\Xml\Dom\Assert\assert_element; /** - * @return Closure(\Dom\XMLDocument): \Dom\Element + * @return Closure(XMLDocument): Element */ function document_element(): Closure { - return static fn (\Dom\XMLDocument $document): \Dom\Element => assert_element($document->documentElement); + return static fn (XMLDocument $document): Element => assert_element($document->documentElement); } diff --git a/src/Xml/Dom/Locator/elements_with_namespaced_tagname.php b/src/Xml/Dom/Locator/elements_with_namespaced_tagname.php index 35f7e3a1..93a2a249 100644 --- a/src/Xml/Dom/Locator/elements_with_namespaced_tagname.php +++ b/src/Xml/Dom/Locator/elements_with_namespaced_tagname.php @@ -5,21 +5,21 @@ namespace VeeWee\Xml\Dom\Locator; use Closure; -use \Dom\XMLDocument; -use \Dom\Element; +use Dom\Element; +use Dom\XMLDocument; use VeeWee\Xml\Dom\Collection\NodeList; use function VeeWee\Xml\Dom\Locator\Element\locate_by_namespaced_tag_name; /** - * @return Closure(\Dom\XMLDocument): NodeList<\Dom\Element> + * @return Closure(XMLDocument): NodeList */ function elements_with_namespaced_tagname(string $namespace, string $localTagName): Closure { return /** - * @return NodeList<\Dom\Element> + * @return NodeList */ - static fn (\Dom\XMLDocument $document): NodeList + static fn (XMLDocument $document): NodeList => locate_by_namespaced_tag_name( document_element()($document), $namespace, diff --git a/src/Xml/Dom/Locator/elements_with_tagname.php b/src/Xml/Dom/Locator/elements_with_tagname.php index 20daa908..37210abe 100644 --- a/src/Xml/Dom/Locator/elements_with_tagname.php +++ b/src/Xml/Dom/Locator/elements_with_tagname.php @@ -5,21 +5,21 @@ namespace VeeWee\Xml\Dom\Locator; use Closure; -use \Dom\XMLDocument; -use \Dom\Element; +use Dom\Element; +use Dom\XMLDocument; use VeeWee\Xml\Dom\Collection\NodeList; use function VeeWee\Xml\Dom\Locator\Element\locate_by_tag_name; /** - * @return Closure(\Dom\XMLDocument): NodeList<\Dom\Element> + * @return Closure(XMLDocument): NodeList */ function elements_with_tagname(string $tagName): Closure { return /** - * @return NodeList<\Dom\Element> + * @return NodeList */ - static fn (\Dom\XMLDocument $document): NodeList + static fn (XMLDocument $document): NodeList => locate_by_tag_name( document_element()($document), $tagName diff --git a/src/Xml/Dom/Locator/root_namespace.php b/src/Xml/Dom/Locator/root_namespace.php index 608d3dfd..6475e1f3 100644 --- a/src/Xml/Dom/Locator/root_namespace.php +++ b/src/Xml/Dom/Locator/root_namespace.php @@ -5,12 +5,12 @@ namespace VeeWee\Xml\Dom\Locator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; /** - * @return Closure(\Dom\XMLDocument): ?string + * @return Closure(XMLDocument): ?string */ function root_namespace_uri(): Closure { - return static fn (\Dom\XMLDocument $document): ?string => document_element()($document)->namespaceURI; + return static fn (XMLDocument $document): ?string => document_element()($document)->namespaceURI; } diff --git a/src/Xml/Dom/Manipulator/Attribute/rename.php b/src/Xml/Dom/Manipulator/Attribute/rename.php index 09058dc7..742e880f 100644 --- a/src/Xml/Dom/Manipulator/Attribute/rename.php +++ b/src/Xml/Dom/Manipulator/Attribute/rename.php @@ -4,9 +4,8 @@ namespace VeeWee\Xml\Dom\Manipulator\Attribute; -use \Dom\Attr; +use Dom\Attr; use VeeWee\Xml\Exception\RuntimeException; -use function Psl\Fun\tap; use function VeeWee\Xml\Dom\Manipulator\Xmlns\rename as rename_xmlns_attribute; use function VeeWee\Xml\Dom\Predicate\is_xmlns_attribute; use function VeeWee\Xml\ErrorHandling\disallow_issues; @@ -14,11 +13,11 @@ /** * @throws RuntimeException */ -function rename(\Dom\Attr $target, string $newQName, ?string $newNamespaceURI = null): \Dom\Attr +function rename(Attr $target, string $newQName, ?string $newNamespaceURI = null): Attr { - return disallow_issues(static fn (): \Dom\Attr => match(true) { + return disallow_issues(static fn (): Attr => match(true) { is_xmlns_attribute($target) => rename_xmlns_attribute($target, $newQName), - default => (function() use ($target, $newNamespaceURI, $newQName): \Dom\Attr { + default => (static function () use ($target, $newNamespaceURI, $newQName): Attr { $target->rename($newNamespaceURI, $newQName); return $target; })() diff --git a/src/Xml/Dom/Manipulator/Document/optimize_namespaces.php b/src/Xml/Dom/Manipulator/Document/optimize_namespaces.php index 33eeb185..b3957f74 100644 --- a/src/Xml/Dom/Manipulator/Document/optimize_namespaces.php +++ b/src/Xml/Dom/Manipulator/Document/optimize_namespaces.php @@ -4,6 +4,8 @@ namespace VeeWee\Xml\Dom\Manipulator\Document; +use Dom\NamespaceInfo; +use Dom\XMLDocument; use VeeWee\Xml\Exception\RuntimeException; use function Psl\Dict\unique; use function Psl\Vec\map; @@ -17,12 +19,12 @@ /** * @throws RuntimeException */ -function optimize_namespaces(\Dom\XMLDocument $document, string $prefix = 'ns'): void +function optimize_namespaces(XMLDocument $document, string $prefix = 'ns'): void { $documentElement = document_element()($document); $namespaceURIs = values(unique(map( recursive_linked_namespaces($documentElement), - static fn (\Dom\NamespaceInfo $info): string => $info->namespaceURI ?? '' + static fn (NamespaceInfo $info): string => $info->namespaceURI ?? '' ))); foreach (sort($namespaceURIs) as $index => $namespaceURI) { diff --git a/src/Xml/Dom/Manipulator/Element/copy_named_xmlns_attributes.php b/src/Xml/Dom/Manipulator/Element/copy_named_xmlns_attributes.php index c8524b9c..91879b93 100644 --- a/src/Xml/Dom/Manipulator/Element/copy_named_xmlns_attributes.php +++ b/src/Xml/Dom/Manipulator/Element/copy_named_xmlns_attributes.php @@ -4,6 +4,8 @@ namespace VeeWee\Xml\Dom\Manipulator\Element; +use Dom\Attr; +use Dom\Element; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Builder\xmlns_attribute; use function VeeWee\Xml\Dom\Locator\Attribute\xmlns_attributes_list; @@ -11,9 +13,9 @@ /** * @throws RuntimeException */ -function copy_named_xmlns_attributes(\Dom\Element $target, \Dom\Element $source): void +function copy_named_xmlns_attributes(Element $target, Element $source): void { - xmlns_attributes_list($source)->forEach(static function (\Dom\Attr $xmlns) use ($target) { + xmlns_attributes_list($source)->forEach(static function (Attr $xmlns) use ($target) { if ($xmlns->prefix !== null && !$target->hasAttribute($xmlns->nodeName)) { xmlns_attribute($xmlns->localName, $xmlns->value)($target); } diff --git a/src/Xml/Dom/Manipulator/Element/rename.php b/src/Xml/Dom/Manipulator/Element/rename.php index 743da4b3..d047bf02 100644 --- a/src/Xml/Dom/Manipulator/Element/rename.php +++ b/src/Xml/Dom/Manipulator/Element/rename.php @@ -4,13 +4,14 @@ namespace VeeWee\Xml\Dom\Manipulator\Element; +use Dom\Element; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\ErrorHandling\disallow_issues; /** * @throws RuntimeException */ -function rename(\Dom\Element $target, string $newQName, ?string $newNamespaceURI = null): \Dom\Element +function rename(Element $target, string $newQName, ?string $newNamespaceURI = null): Element { $parts = explode(':', $newQName, 2); $newPrefix = $parts[0] ?? ''; diff --git a/src/Xml/Dom/Manipulator/Node/append_external_node.php b/src/Xml/Dom/Manipulator/Node/append_external_node.php index f9764ca3..20e07e75 100644 --- a/src/Xml/Dom/Manipulator/Node/append_external_node.php +++ b/src/Xml/Dom/Manipulator/Node/append_external_node.php @@ -4,13 +4,13 @@ namespace VeeWee\Xml\Dom\Manipulator\Node; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Exception\RuntimeException; /** * @throws RuntimeException */ -function append_external_node(\Dom\Node $target, \Dom\Node $source): \Dom\Node +function append_external_node(Node $target, Node $source): Node { $copy = import_node_deeply($target, $source); $target->appendChild($copy); diff --git a/src/Xml/Dom/Manipulator/Node/import_node_deeply.php b/src/Xml/Dom/Manipulator/Node/import_node_deeply.php index 6e448287..69e57fd3 100644 --- a/src/Xml/Dom/Manipulator/Node/import_node_deeply.php +++ b/src/Xml/Dom/Manipulator/Node/import_node_deeply.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Manipulator\Node; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Locator\Node\detect_document; use function VeeWee\Xml\ErrorHandling\disallow_issues; @@ -13,10 +13,10 @@ /** * @throws RuntimeException */ -function import_node_deeply(\Dom\Node $target, \Dom\Node $source): \Dom\Node +function import_node_deeply(Node $target, Node $source): Node { return disallow_issues( - static function () use ($target, $source): \Dom\Node { + static function () use ($target, $source): Node { $document = detect_document($target); return disallow_libxml_false_returns( diff --git a/src/Xml/Dom/Manipulator/Node/remove.php b/src/Xml/Dom/Manipulator/Node/remove.php index 6e108ce2..52b11580 100644 --- a/src/Xml/Dom/Manipulator/Node/remove.php +++ b/src/Xml/Dom/Manipulator/Node/remove.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Manipulator\Node; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Locator\Element\parent_element; use function VeeWee\Xml\Dom\Predicate\is_attribute; @@ -14,13 +14,13 @@ /** * @throws RuntimeException */ -function remove(\Dom\Node $target): \Dom\Node +function remove(Node $target): Node { return disallow_issues( /** * @throws RuntimeException */ - static function () use ($target): \Dom\Node { + static function () use ($target): Node { $parent = parent_element($target); if (is_attribute($target)) { diff --git a/src/Xml/Dom/Manipulator/Node/remove_namespace.php b/src/Xml/Dom/Manipulator/Node/remove_namespace.php index 1bfce933..5d3f18da 100644 --- a/src/Xml/Dom/Manipulator/Node/remove_namespace.php +++ b/src/Xml/Dom/Manipulator/Node/remove_namespace.php @@ -4,6 +4,8 @@ namespace VeeWee\Xml\Dom\Manipulator\Node; +use Dom\Attr; +use Dom\Element; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\ErrorHandling\disallow_issues; use function VeeWee\Xml\ErrorHandling\disallow_libxml_false_returns; @@ -11,13 +13,13 @@ /** * @throws RuntimeException */ -function remove_namespace(\Dom\Attr $target, \Dom\Element $parent): \Dom\Attr +function remove_namespace(Attr $target, Element $parent): Attr { return disallow_issues( /** * @throws RuntimeException */ - static function () use ($target, $parent): \Dom\Attr { + static function () use ($target, $parent): Attr { disallow_libxml_false_returns( $parent->removeAttributeNode($target), 'Could not remove xmlns attribute from dom element' diff --git a/src/Xml/Dom/Manipulator/Node/rename.php b/src/Xml/Dom/Manipulator/Node/rename.php index a8cd3dec..31f709f0 100644 --- a/src/Xml/Dom/Manipulator/Node/rename.php +++ b/src/Xml/Dom/Manipulator/Node/rename.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Manipulator\Node; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Manipulator\Attribute\rename as rename_attribute; use function VeeWee\Xml\Dom\Manipulator\Element\rename as rename_element; @@ -16,7 +16,7 @@ * * @throws RuntimeException */ -function rename(\Dom\Node $target, string $newQName, ?string $newNamespaceURI = null): \Dom\Node +function rename(Node $target, string $newQName, ?string $newNamespaceURI = null): Node { return match(true) { is_attribute($target) => rename_attribute($target, $newQName, $newNamespaceURI), diff --git a/src/Xml/Dom/Manipulator/Node/replace_by_external_node.php b/src/Xml/Dom/Manipulator/Node/replace_by_external_node.php index f6f4e6fd..54f7c24d 100644 --- a/src/Xml/Dom/Manipulator/Node/replace_by_external_node.php +++ b/src/Xml/Dom/Manipulator/Node/replace_by_external_node.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Manipulator\Node; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Exception\RuntimeException; use Webmozart\Assert\Assert; use function get_class; @@ -14,10 +14,10 @@ /** * @throws RuntimeException */ -function replace_by_external_node(\Dom\Node $target, \Dom\Node $source): \Dom\Node +function replace_by_external_node(Node $target, Node $source): Node { return disallow_issues( - static function () use ($target, $source) : \Dom\Node { + static function () use ($target, $source) : Node { $parentNode = $target->parentNode; Assert::notNull($parentNode, 'Could not replace a node without parent node. ('.get_class($target).')'); $copy = import_node_deeply($target, $source); diff --git a/src/Xml/Dom/Manipulator/Node/replace_by_external_nodes.php b/src/Xml/Dom/Manipulator/Node/replace_by_external_nodes.php index faa61d47..446d2ae3 100644 --- a/src/Xml/Dom/Manipulator/Node/replace_by_external_nodes.php +++ b/src/Xml/Dom/Manipulator/Node/replace_by_external_nodes.php @@ -4,6 +4,7 @@ namespace VeeWee\Xml\Dom\Manipulator\Node; +use Dom\Node; use VeeWee\Xml\Exception\RuntimeException; use Webmozart\Assert\Assert; use function get_class; @@ -13,21 +14,21 @@ /** * @throws RuntimeException - * @param iterable $sources - * @return array + * @param iterable $sources + * @return array */ -function replace_by_external_nodes(\Dom\Node $target, iterable $sources): array +function replace_by_external_nodes(Node $target, iterable $sources): array { return disallow_issues( /** - * @return array + * @return array */ static function () use ($target, $sources) : array { $parentNode = $target->parentNode; Assert::notNull($parentNode, 'Could not replace a node without parent node. ('.get_class($target).')'); $copies = map( $sources, - static fn (\Dom\Node $source): \Dom\Node => import_node_deeply($target, $source) + static fn (Node $source): Node => import_node_deeply($target, $source) ); // Documents can only contain one element, so in case of documentElement, we remove it first to avoid errors. diff --git a/src/Xml/Dom/Manipulator/Xmlns/rename.php b/src/Xml/Dom/Manipulator/Xmlns/rename.php index f23004f4..e4d3037b 100644 --- a/src/Xml/Dom/Manipulator/Xmlns/rename.php +++ b/src/Xml/Dom/Manipulator/Xmlns/rename.php @@ -4,6 +4,7 @@ namespace VeeWee\Xml\Dom\Manipulator\Xmlns; +use Dom\Attr; use VeeWee\Xml\Exception\RuntimeException; use VeeWee\Xml\Xmlns\Xmlns; use function VeeWee\Xml\ErrorHandling\disallow_issues; @@ -11,7 +12,7 @@ /** * @throws RuntimeException */ -function rename(\Dom\Attr $target, string $newQName): \Dom\Attr +function rename(Attr $target, string $newQName): Attr { disallow_issues(static fn () => $target->rename(Xmlns::xmlns()->value(), $newQName)); diff --git a/src/Xml/Dom/Manipulator/Xmlns/rename_element_namespace.php b/src/Xml/Dom/Manipulator/Xmlns/rename_element_namespace.php index 6faf413f..1f8ed6d6 100644 --- a/src/Xml/Dom/Manipulator/Xmlns/rename_element_namespace.php +++ b/src/Xml/Dom/Manipulator/Xmlns/rename_element_namespace.php @@ -4,22 +4,26 @@ namespace VeeWee\Xml\Dom\Manipulator\Xmlns; +use Dom\Attr; +use Dom\Element; +use DOMException; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Locator\Attribute\attributes_list; use function VeeWee\Xml\Dom\Locator\Element\children; use function VeeWee\Xml\Dom\Predicate\is_xmlns_attribute; +use const Dom\INVALID_MODIFICATION_ERR; /** * @throws RuntimeException * @param non-empty-string $newPrefix */ -function rename_element_namespace(\Dom\Element $element, string $namespaceURI, string $newPrefix): void +function rename_element_namespace(Element $element, string $namespaceURI, string $newPrefix): void { children($element)->forEach( - static fn (\Dom\Element $child) => rename_element_namespace($child, $namespaceURI, $newPrefix) + static fn (Element $child) => rename_element_namespace($child, $namespaceURI, $newPrefix) ); - attributes_list($element)->forEach(static function (\Dom\Attr $attr) use ($namespaceURI, $newPrefix, $element) { + attributes_list($element)->forEach(static function (Attr $attr) use ($namespaceURI, $newPrefix, $element) { if ($attr->namespaceURI === $namespaceURI) { $attr->rename($namespaceURI, $newPrefix . ':' . $attr->localName); } @@ -28,8 +32,8 @@ function rename_element_namespace(\Dom\Element $element, string $namespaceURI, s try { $attr->rename($attr->namespaceURI, 'xmlns:' . $newPrefix); - } catch (\DOMException $e) { - if ($e->getCode() === \Dom\INVALID_MODIFICATION_ERR) { + } catch (DOMException $e) { + if ($e->getCode() === INVALID_MODIFICATION_ERR) { // Remove the attribute that would become a duplicate $element->removeAttributeNode($attr); } else { diff --git a/src/Xml/Dom/Manipulator/append.php b/src/Xml/Dom/Manipulator/append.php index b9db4472..60c1d6b1 100644 --- a/src/Xml/Dom/Manipulator/append.php +++ b/src/Xml/Dom/Manipulator/append.php @@ -5,21 +5,20 @@ namespace VeeWee\Xml\Dom\Manipulator; use Closure; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Predicate\is_attribute; use function VeeWee\Xml\Dom\Predicate\is_element; use function VeeWee\Xml\ErrorHandling\disallow_issues; -use function VeeWee\Xml\ErrorHandling\disallow_libxml_false_returns; /** * @no-named-arguments - * @throws RuntimeException - * @return Closure(\Dom\Node): \Dom\Node + * @return Closure(Node): Node + *@throws RuntimeException */ -function append(\Dom\Node ... $nodes): Closure +function append(Node ... $nodes): Closure { - return static fn (\Dom\Node $target): \Dom\Node => disallow_issues( + return static fn (Node $target): Node => disallow_issues( static function () use ($target, $nodes) { foreach ($nodes as $node) { // Attributes cannot be appended with appendChild. diff --git a/src/Xml/Dom/Mapper/Mapper.php b/src/Xml/Dom/Mapper/Mapper.php index 971f6be3..a20a048c 100644 --- a/src/Xml/Dom/Mapper/Mapper.php +++ b/src/Xml/Dom/Mapper/Mapper.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Mapper; -use \Dom\XMLDocument; +use Dom\XMLDocument; /** * @template R @@ -14,5 +14,5 @@ interface Mapper /** * @return R */ - public function __invoke(\Dom\XMLDocument $document): mixed; + public function __invoke(XMLDocument $document): mixed; } diff --git a/src/Xml/Dom/Mapper/xml_string.php b/src/Xml/Dom/Mapper/xml_string.php index b8c08c8f..4071cb86 100644 --- a/src/Xml/Dom/Mapper/xml_string.php +++ b/src/Xml/Dom/Mapper/xml_string.php @@ -5,7 +5,7 @@ namespace VeeWee\Xml\Dom\Mapper; use Closure; -use \Dom\Node; +use Dom\Node; use function Psl\Type\non_empty_string; use function VeeWee\Xml\Dom\Locator\Node\detect_document; use function VeeWee\Xml\Dom\Predicate\is_document; @@ -13,11 +13,11 @@ use function VeeWee\Xml\ErrorHandling\disallow_libxml_false_returns; /** - * @return Closure(\Dom\Node): non-empty-string + * @return Closure(Node): non-empty-string */ function xml_string(): Closure { - return static fn (\Dom\Node $node): string => disallow_issues( + return static fn (Node $node): string => disallow_issues( static function () use ($node): string { $document = detect_document($node); $node = is_document($node) ? null : $node; diff --git a/src/Xml/Dom/Mapper/xslt_template.php b/src/Xml/Dom/Mapper/xslt_template.php index a8d19f8d..0ecafe52 100644 --- a/src/Xml/Dom/Mapper/xslt_template.php +++ b/src/Xml/Dom/Mapper/xslt_template.php @@ -5,8 +5,8 @@ namespace VeeWee\Xml\Dom\Mapper; use Closure; -use VeeWee\Xml\Dom\Document; use Dom\XMLDocument; +use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Xslt\Processor; use XSLTProcessor; diff --git a/src/Xml/Dom/Predicate/is_attribute.php b/src/Xml/Dom/Predicate/is_attribute.php index 0ccb5378..06b50b82 100644 --- a/src/Xml/Dom/Predicate/is_attribute.php +++ b/src/Xml/Dom/Predicate/is_attribute.php @@ -4,13 +4,13 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\Attr; -use \Dom\Node; +use Dom\Attr; +use Dom\Node; /** - * @psalm-assert-if-true \Dom\Attr $node + * @psalm-assert-if-true Attr $node */ -function is_attribute(\Dom\Node $node): bool +function is_attribute(Node $node): bool { - return $node instanceof \Dom\Attr; + return $node instanceof Attr; } diff --git a/src/Xml/Dom/Predicate/is_cdata.php b/src/Xml/Dom/Predicate/is_cdata.php index df920d24..f22a31ef 100644 --- a/src/Xml/Dom/Predicate/is_cdata.php +++ b/src/Xml/Dom/Predicate/is_cdata.php @@ -4,13 +4,13 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\CDATASection; -use \Dom\Node; +use Dom\CDATASection; +use Dom\Node; /** - * @psalm-assert-if-true \Dom\CDATASection $node + * @psalm-assert-if-true CDATASection $node */ -function is_cdata(\Dom\Node $node): bool +function is_cdata(Node $node): bool { - return $node instanceof \Dom\CDATASection; + return $node instanceof CDATASection; } diff --git a/src/Xml/Dom/Predicate/is_default_xmlns_attribute.php b/src/Xml/Dom/Predicate/is_default_xmlns_attribute.php index 897a4591..c1096256 100644 --- a/src/Xml/Dom/Predicate/is_default_xmlns_attribute.php +++ b/src/Xml/Dom/Predicate/is_default_xmlns_attribute.php @@ -4,9 +4,9 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\Node; +use Dom\Node; -function is_default_xmlns_attribute(\Dom\Node $node): bool +function is_default_xmlns_attribute(Node $node): bool { return is_xmlns_attribute($node) && $node->prefix === null; } diff --git a/src/Xml/Dom/Predicate/is_document.php b/src/Xml/Dom/Predicate/is_document.php index 77f7159d..37cc0cef 100644 --- a/src/Xml/Dom/Predicate/is_document.php +++ b/src/Xml/Dom/Predicate/is_document.php @@ -4,13 +4,13 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\XMLDocument; -use \Dom\Node; +use Dom\Node; +use Dom\XMLDocument; /** - * @psalm-assert-if-true \Dom\XMLDocument $node + * @psalm-assert-if-true XMLDocument $node */ -function is_document(\Dom\Node $node): bool +function is_document(Node $node): bool { - return $node instanceof \Dom\XMLDocument; + return $node instanceof XMLDocument; } diff --git a/src/Xml/Dom/Predicate/is_document_element.php b/src/Xml/Dom/Predicate/is_document_element.php index eefeb4d5..85ddb499 100644 --- a/src/Xml/Dom/Predicate/is_document_element.php +++ b/src/Xml/Dom/Predicate/is_document_element.php @@ -4,10 +4,10 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\Node; +use Dom\Node; use function VeeWee\Xml\Dom\Locator\Node\detect_document; -function is_document_element(\Dom\Node $node): bool +function is_document_element(Node $node): bool { return is_element($node) && detect_document($node)->documentElement === $node; } diff --git a/src/Xml/Dom/Predicate/is_element.php b/src/Xml/Dom/Predicate/is_element.php index b038d1ac..e5e59a34 100644 --- a/src/Xml/Dom/Predicate/is_element.php +++ b/src/Xml/Dom/Predicate/is_element.php @@ -4,13 +4,13 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\Element; -use \Dom\Node; +use Dom\Element; +use Dom\Node; /** - * @psalm-assert-if-true \Dom\Element $node + * @psalm-assert-if-true Element $node */ -function is_element(\Dom\Node $node): bool +function is_element(Node $node): bool { - return $node instanceof \Dom\Element; + return $node instanceof Element; } diff --git a/src/Xml/Dom/Predicate/is_non_empty_text.php b/src/Xml/Dom/Predicate/is_non_empty_text.php index 9acf3b27..83ad3daa 100644 --- a/src/Xml/Dom/Predicate/is_non_empty_text.php +++ b/src/Xml/Dom/Predicate/is_non_empty_text.php @@ -4,9 +4,9 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\Node; +use Dom\Node; -function is_non_empty_text(\Dom\Node $node): bool +function is_non_empty_text(Node $node): bool { return is_text($node) && trim($node->nodeValue ?? '') !== ''; } diff --git a/src/Xml/Dom/Predicate/is_text.php b/src/Xml/Dom/Predicate/is_text.php index 5135a098..af94f4de 100644 --- a/src/Xml/Dom/Predicate/is_text.php +++ b/src/Xml/Dom/Predicate/is_text.php @@ -4,13 +4,13 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\Node; -use \Dom\Text; +use Dom\Node; +use Dom\Text; /** - * @psalm-assert-if-true \Dom\Text $node + * @psalm-assert-if-true Text $node */ -function is_text(\Dom\Node $node): bool +function is_text(Node $node): bool { - return $node instanceof \Dom\Text; + return $node instanceof Text; } diff --git a/src/Xml/Dom/Predicate/is_whitespace.php b/src/Xml/Dom/Predicate/is_whitespace.php index 9ece97cf..e18df29d 100644 --- a/src/Xml/Dom/Predicate/is_whitespace.php +++ b/src/Xml/Dom/Predicate/is_whitespace.php @@ -4,9 +4,9 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\Node; +use Dom\Node; -function is_whitespace(\Dom\Node $node): bool +function is_whitespace(Node $node): bool { return is_text($node) && trim($node->nodeValue ?? '') === ''; } diff --git a/src/Xml/Dom/Predicate/is_xmlns_attribute.php b/src/Xml/Dom/Predicate/is_xmlns_attribute.php index 09f6f0f4..aedc2ca4 100644 --- a/src/Xml/Dom/Predicate/is_xmlns_attribute.php +++ b/src/Xml/Dom/Predicate/is_xmlns_attribute.php @@ -4,13 +4,14 @@ namespace VeeWee\Xml\Dom\Predicate; -use \Dom\Node; +use Dom\Attr; +use Dom\Node; use VeeWee\Xml\Xmlns\Xmlns; /** - * @psalm-assert-if-true \Dom\Attr $node + * @psalm-assert-if-true Attr $node */ -function is_xmlns_attribute(\Dom\Node $node): bool +function is_xmlns_attribute(Node $node): bool { return is_attribute($node) && $node->namespaceURI === Xmlns::xmlns()->value(); } diff --git a/src/Xml/Dom/Traverser/Action.php b/src/Xml/Dom/Traverser/Action.php index ca24e33f..aeb2c2c1 100644 --- a/src/Xml/Dom/Traverser/Action.php +++ b/src/Xml/Dom/Traverser/Action.php @@ -4,9 +4,9 @@ namespace VeeWee\Xml\Dom\Traverser; -use \Dom\Node; +use Dom\Node; interface Action { - public function __invoke(\Dom\Node $currentNode): void; + public function __invoke(Node $currentNode): void; } diff --git a/src/Xml/Dom/Traverser/Action/Noop.php b/src/Xml/Dom/Traverser/Action/Noop.php index ec7f7e95..cf99ad05 100644 --- a/src/Xml/Dom/Traverser/Action/Noop.php +++ b/src/Xml/Dom/Traverser/Action/Noop.php @@ -4,12 +4,12 @@ namespace VeeWee\Xml\Dom\Traverser\Action; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Dom\Traverser\Action; final class Noop implements Action { - public function __invoke(\Dom\Node $currentNode): void + public function __invoke(Node $currentNode): void { } } diff --git a/src/Xml/Dom/Traverser/Action/RemoveNode.php b/src/Xml/Dom/Traverser/Action/RemoveNode.php index fd18b447..486b9c31 100644 --- a/src/Xml/Dom/Traverser/Action/RemoveNode.php +++ b/src/Xml/Dom/Traverser/Action/RemoveNode.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Traverser\Action; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Dom\Traverser\Action; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Manipulator\Node\remove; @@ -14,7 +14,7 @@ final class RemoveNode implements Action /** * @throws RuntimeException */ - public function __invoke(\Dom\Node $currentNode): void + public function __invoke(Node $currentNode): void { remove($currentNode); } diff --git a/src/Xml/Dom/Traverser/Action/RenameNode.php b/src/Xml/Dom/Traverser/Action/RenameNode.php index cb28f21c..e8872291 100644 --- a/src/Xml/Dom/Traverser/Action/RenameNode.php +++ b/src/Xml/Dom/Traverser/Action/RenameNode.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Traverser\Action; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Dom\Traverser\Action; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Manipulator\Node\rename; @@ -20,7 +20,7 @@ public function __construct( /** * @throws RuntimeException */ - public function __invoke(\Dom\Node $currentNode): void + public function __invoke(Node $currentNode): void { rename($currentNode, $this->newQName, $this->newNamespaceURI); } diff --git a/src/Xml/Dom/Traverser/Action/ReplaceNode.php b/src/Xml/Dom/Traverser/Action/ReplaceNode.php index bdaf96d5..f2a5620d 100644 --- a/src/Xml/Dom/Traverser/Action/ReplaceNode.php +++ b/src/Xml/Dom/Traverser/Action/ReplaceNode.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Traverser\Action; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Dom\Traverser\Action; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Manipulator\Node\replace_by_external_node; @@ -12,14 +12,14 @@ final class ReplaceNode implements Action { public function __construct( - private \Dom\Node $newNode + private Node $newNode ) { } /** * @throws RuntimeException */ - public function __invoke(\Dom\Node $currentNode): void + public function __invoke(Node $currentNode): void { replace_by_external_node($currentNode, $this->newNode); } diff --git a/src/Xml/Dom/Traverser/Traverser.php b/src/Xml/Dom/Traverser/Traverser.php index 2df73f84..5d091b76 100644 --- a/src/Xml/Dom/Traverser/Traverser.php +++ b/src/Xml/Dom/Traverser/Traverser.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Traverser; -use \Dom\Node; +use Dom\Node; use function VeeWee\Xml\Dom\Locator\Attribute\attributes_list; use function VeeWee\Xml\Dom\Locator\Node\children; @@ -23,7 +23,7 @@ public function __construct(Visitor ... $visitors) $this->visitors = $visitors; } - public function traverse(\Dom\Node $node): \Dom\Node + public function traverse(Node $node): Node { $this->enterNode($node); @@ -40,14 +40,14 @@ public function traverse(\Dom\Node $node): \Dom\Node return $node; } - private function enterNode(\Dom\Node $node): void + private function enterNode(Node $node): void { foreach ($this->visitors as $visitor) { $visitor->onNodeEnter($node)($node); } } - private function leaveNode(\Dom\Node $node): void + private function leaveNode(Node $node): void { foreach ($this->visitors as $visitor) { $visitor->onNodeLeave($node)($node); diff --git a/src/Xml/Dom/Traverser/Visitor.php b/src/Xml/Dom/Traverser/Visitor.php index 0f2b4402..2ee923a9 100644 --- a/src/Xml/Dom/Traverser/Visitor.php +++ b/src/Xml/Dom/Traverser/Visitor.php @@ -4,10 +4,10 @@ namespace VeeWee\Xml\Dom\Traverser; -use \Dom\Node; +use Dom\Node; interface Visitor { - public function onNodeEnter(\Dom\Node $node): Action; - public function onNodeLeave(\Dom\Node $node): Action; + public function onNodeEnter(Node $node): Action; + public function onNodeLeave(Node $node): Action; } diff --git a/src/Xml/Dom/Traverser/Visitor/AbstractVisitor.php b/src/Xml/Dom/Traverser/Visitor/AbstractVisitor.php index 606f2972..7cb472cb 100644 --- a/src/Xml/Dom/Traverser/Visitor/AbstractVisitor.php +++ b/src/Xml/Dom/Traverser/Visitor/AbstractVisitor.php @@ -4,18 +4,18 @@ namespace VeeWee\Xml\Dom\Traverser\Visitor; -use \Dom\Node; +use Dom\Node; use VeeWee\Xml\Dom\Traverser\Action; use VeeWee\Xml\Dom\Traverser\Visitor; abstract class AbstractVisitor implements Visitor { - public function onNodeEnter(\Dom\Node $node): Action + public function onNodeEnter(Node $node): Action { return new Action\Noop(); } - public function onNodeLeave(\Dom\Node $node): Action + public function onNodeLeave(Node $node): Action { return new Action\Noop(); } diff --git a/src/Xml/Dom/Traverser/Visitor/RemoveNamespaces.php b/src/Xml/Dom/Traverser/Visitor/RemoveNamespaces.php index fd734ba8..f3eb677a 100644 --- a/src/Xml/Dom/Traverser/Visitor/RemoveNamespaces.php +++ b/src/Xml/Dom/Traverser/Visitor/RemoveNamespaces.php @@ -3,6 +3,9 @@ namespace VeeWee\Xml\Dom\Traverser\Visitor; +use Dom\Attr; +use Dom\Element; +use Dom\Node; use VeeWee\Xml\Dom\Traverser\Action; use VeeWee\Xml\Exception\RuntimeException; use function Psl\Iter\contains; @@ -13,12 +16,12 @@ final class RemoveNamespaces extends AbstractVisitor { /** - * @var null | callable(\Dom\Attr | \Dom\Element): bool + * @var null | callable(Attr | Element): bool */ private $filter; /** - * @param null | callable(\Dom\Attr | \Dom\Element): bool $filter + * @param null | callable(Attr | Element): bool $filter */ public function __construct( ?callable $filter = null @@ -34,14 +37,14 @@ public static function all(): self public static function prefixed(): self { return new self( - static fn (\Dom\Attr | \Dom\Element $node): bool => $node->prefix !== null + static fn (Attr | Element $node): bool => $node->prefix !== null ); } public static function unprefixed(): self { return new self( - static fn (\Dom\Attr | \Dom\Element $node): bool => $node->prefix === null + static fn (Attr | Element $node): bool => $node->prefix === null ); } @@ -51,7 +54,7 @@ public static function unprefixed(): self public static function byPrefixNames(array $prefixes): self { return new self( - static fn (\Dom\Attr | \Dom\Element $node): bool => match(true) { + static fn (Attr | Element $node): bool => match(true) { is_xmlns_attribute($node) => contains($prefixes, $node->prefix !== null ? $node->localName : ''), default => contains($prefixes, $node->prefix ?? '') } @@ -64,14 +67,14 @@ public static function byPrefixNames(array $prefixes): self public static function byNamespaceURIs(array $URIs): self { return new self( - static fn (\Dom\Attr | \Dom\Element $node): bool => match(true) { + static fn (Attr | Element $node): bool => match(true) { is_xmlns_attribute($node) => contains($URIs, $node->value), default => contains($URIs, $node->namespaceURI), } ); } - public function onNodeEnter(\Dom\Node $node): Action + public function onNodeEnter(Node $node): Action { if (is_xmlns_attribute($node)) { return new Action\Noop(); @@ -81,14 +84,14 @@ public function onNodeEnter(\Dom\Node $node): Action return new Action\Noop(); } - /** @var \Dom\Element | \Dom\Attr $node */ + /** @var Element | Attr $node */ return new Action\RenameNode($node->localName, null); } /** * @throws RuntimeException */ - public function onNodeLeave(\Dom\Node $node): Action + public function onNodeLeave(Node $node): Action { if (!is_xmlns_attribute($node)) { return new Action\Noop(); @@ -101,7 +104,7 @@ public function onNodeLeave(\Dom\Node $node): Action return new Action\RemoveNode(); } - private function shouldDealWithNode(\Dom\Node $node): bool + private function shouldDealWithNode(Node $node): bool { if (!is_element($node) && !is_attribute($node)) { return false; diff --git a/src/Xml/Dom/Traverser/Visitor/SortAttributes.php b/src/Xml/Dom/Traverser/Visitor/SortAttributes.php index 4d729bf9..f7e133b5 100644 --- a/src/Xml/Dom/Traverser/Visitor/SortAttributes.php +++ b/src/Xml/Dom/Traverser/Visitor/SortAttributes.php @@ -4,6 +4,8 @@ namespace VeeWee\Xml\Dom\Traverser\Visitor; +use Dom\Attr; +use Dom\Node; use VeeWee\Xml\Dom\Traverser\Action; use function VeeWee\Xml\Dom\Locator\Attribute\attributes_list; use function VeeWee\Xml\Dom\Manipulator\append; @@ -13,16 +15,16 @@ final class SortAttributes extends AbstractVisitor { - public function onNodeEnter(\Dom\Node $node): Action + public function onNodeEnter(Node $node): Action { if (!is_element($node)) { return new Action\Noop(); } attributes_list($node) - ->sort(static fn (\Dom\Attr $a, \Dom\Attr $b): int => $a->nodeName <=> $b->nodeName) + ->sort(static fn (Attr $a, Attr $b): int => $a->nodeName <=> $b->nodeName) ->forEach( - static function (\Dom\Attr $attr) use ($node): void { + static function (Attr $attr) use ($node): void { disallow_issues(static function () use ($node, $attr) { remove($attr); append($attr)($node); diff --git a/src/Xml/Dom/Validator/Validator.php b/src/Xml/Dom/Validator/Validator.php index c31b26b5..b9aa97e1 100644 --- a/src/Xml/Dom/Validator/Validator.php +++ b/src/Xml/Dom/Validator/Validator.php @@ -4,10 +4,10 @@ namespace VeeWee\Xml\Dom\Validator; -use \Dom\XMLDocument; +use Dom\XMLDocument; use VeeWee\Xml\ErrorHandling\Issue\IssueCollection; interface Validator { - public function __invoke(\Dom\XMLDocument $document): IssueCollection; + public function __invoke(XMLDocument $document): IssueCollection; } diff --git a/src/Xml/Dom/Validator/internal_xsd_validator.php b/src/Xml/Dom/Validator/internal_xsd_validator.php index b3b8ef03..2990fcc7 100644 --- a/src/Xml/Dom/Validator/internal_xsd_validator.php +++ b/src/Xml/Dom/Validator/internal_xsd_validator.php @@ -5,7 +5,7 @@ namespace VeeWee\Xml\Dom\Validator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; use VeeWee\Xml\ErrorHandling\Issue\IssueCollection; use VeeWee\Xml\Xsd\Schema\Schema; use VeeWee\Xml\Xsd\Schema\SchemaCollection; @@ -14,17 +14,17 @@ /** * @param list $schemaManipulators - * @return Closure(\Dom\XMLDocument): IssueCollection + * @return Closure(XMLDocument): IssueCollection */ function internal_xsd_validator(callable ... $schemaManipulators): Closure { - return static function (\Dom\XMLDocument $document) use ($schemaManipulators) : IssueCollection { + return static function (XMLDocument $document) use ($schemaManipulators) : IssueCollection { $schemas = configure(...$schemaManipulators)(locate_all_xsd_schemas($document)); return validator_chain( ...$schemas->map( /** - * @return Closure(\Dom\XMLDocument): IssueCollection + * @return Closure(XMLDocument): IssueCollection */ static fn (Schema $schema): Closure => xsd_validator($schema->location()) ) diff --git a/src/Xml/Dom/Validator/validator_chain.php b/src/Xml/Dom/Validator/validator_chain.php index 773de1cf..d2ad8cfc 100644 --- a/src/Xml/Dom/Validator/validator_chain.php +++ b/src/Xml/Dom/Validator/validator_chain.php @@ -5,21 +5,21 @@ namespace VeeWee\Xml\Dom\Validator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; use VeeWee\Xml\ErrorHandling\Issue\IssueCollection; use function Psl\Iter\reduce; /** - * @param list $validators - * @return Closure(\Dom\XMLDocument): IssueCollection + * @param list $validators + * @return Closure(XMLDocument): IssueCollection */ function validator_chain(callable ... $validators): Closure { - return static fn (\Dom\XMLDocument $document): IssueCollection => + return static fn (XMLDocument $document): IssueCollection => reduce( $validators, /** - * @param callable(\Dom\XMLDocument): IssueCollection $validator + * @param callable(XMLDocument): IssueCollection $validator */ static fn (IssueCollection $issues, callable $validator): IssueCollection => new IssueCollection( diff --git a/src/Xml/Dom/Validator/xsd_validator.php b/src/Xml/Dom/Validator/xsd_validator.php index 6b87250e..e03d02ca 100644 --- a/src/Xml/Dom/Validator/xsd_validator.php +++ b/src/Xml/Dom/Validator/xsd_validator.php @@ -5,16 +5,16 @@ namespace VeeWee\Xml\Dom\Validator; use Closure; -use \Dom\XMLDocument; +use Dom\XMLDocument; use VeeWee\Xml\ErrorHandling\Issue\IssueCollection; use function VeeWee\Xml\ErrorHandling\detect_issues; /** - * @return Closure(\Dom\XMLDocument): IssueCollection + * @return Closure(XMLDocument): IssueCollection */ function xsd_validator(string $xsd): Closure { - return static function (\Dom\XMLDocument $document) use ($xsd): IssueCollection { + return static function (XMLDocument $document) use ($xsd): IssueCollection { [$_, $issues] = detect_issues(static fn () => $document->schemaValidate($xsd)); return $issues; diff --git a/src/Xml/Dom/Xpath.php b/src/Xml/Dom/Xpath.php index 6684181a..ae71b055 100644 --- a/src/Xml/Dom/Xpath.php +++ b/src/Xml/Dom/Xpath.php @@ -4,8 +4,8 @@ namespace VeeWee\Xml\Dom; -use \Dom\Node; -use \Dom\XPath as DOMXPath; +use Dom\Node; +use Dom\XPath as DOMXPath; use InvalidArgumentException; use Psl\Type\TypeInterface; use VeeWee\Xml\Dom\Collection\NodeList; @@ -38,7 +38,7 @@ public static function fromDocument(Document $document, callable ... $configurat * @throws RuntimeException * @throws InvalidArgumentException */ - public static function fromUnsafeNode(\Dom\Node $node, callable ... $configurators): self + public static function fromUnsafeNode(Node $node, callable ... $configurators): self { return self::fromDocument( Document::fromUnsafeDocument( @@ -61,10 +61,10 @@ public function locate(callable $locator) } /** - * @throws RuntimeException - * @return NodeList<\Dom\Node> + * @return NodeList + *@throws RuntimeException */ - public function query(string $expression, ?\Dom\Node $contextNode = null): NodeList + public function query(string $expression, ?Node $contextNode = null): NodeList { return $this->locate(query($expression, $contextNode)); } @@ -73,7 +73,7 @@ public function query(string $expression, ?\Dom\Node $contextNode = null): NodeL * @throws RuntimeException * @throws InvalidArgumentException */ - public function querySingle(string $expression, ?\Dom\Node $contextNode = null): \Dom\Node + public function querySingle(string $expression, ?Node $contextNode = null): Node { return $this->locate(query_single($expression, $contextNode)); } @@ -86,7 +86,7 @@ public function querySingle(string $expression, ?\Dom\Node $contextNode = null): * @return T * @throws RuntimeException */ - public function evaluate(string $expression, TypeInterface $type, ?\Dom\Node $contextNode = null) + public function evaluate(string $expression, TypeInterface $type, ?Node $contextNode = null) { return $this->locate(evaluate($expression, $type, $contextNode)); } diff --git a/src/Xml/Dom/Xpath/Configurator/Configurator.php b/src/Xml/Dom/Xpath/Configurator/Configurator.php index 704a9d3a..5d65dc1c 100644 --- a/src/Xml/Dom/Xpath/Configurator/Configurator.php +++ b/src/Xml/Dom/Xpath/Configurator/Configurator.php @@ -4,9 +4,9 @@ namespace VeeWee\Xml\Dom\Xpath\Configurator; -use \Dom\XPath; +use Dom\XPath; interface Configurator { - public function __invoke(\Dom\XPath $xpath): \Dom\XPath; + public function __invoke(XPath $xpath): XPath; } diff --git a/src/Xml/Dom/Xpath/Configurator/all_functions.php b/src/Xml/Dom/Xpath/Configurator/all_functions.php index b400a51a..9ed1817e 100644 --- a/src/Xml/Dom/Xpath/Configurator/all_functions.php +++ b/src/Xml/Dom/Xpath/Configurator/all_functions.php @@ -5,14 +5,14 @@ namespace VeeWee\Xml\Dom\Xpath\Configurator; use Closure; -use \Dom\XPath; +use Dom\XPath; /** - * @return Closure(\Dom\XPath): \Dom\XPath + * @return Closure(XPath): XPath */ function all_functions(): Closure { - return static function (\Dom\XPath $xpath): \Dom\XPath { + return static function (XPath $xpath): XPath { php_namespace()($xpath); $xpath->registerPhpFunctions(); diff --git a/src/Xml/Dom/Xpath/Configurator/functions.php b/src/Xml/Dom/Xpath/Configurator/functions.php index 9157bd29..cbc3ed7f 100644 --- a/src/Xml/Dom/Xpath/Configurator/functions.php +++ b/src/Xml/Dom/Xpath/Configurator/functions.php @@ -5,16 +5,16 @@ namespace VeeWee\Xml\Dom\Xpath\Configurator; use Closure; -use \Dom\XPath; +use Dom\XPath; /** * @param non-empty-list $functions * - * @return Closure(\Dom\XPath): \Dom\XPath + * @return Closure(XPath): XPath */ function functions(array $functions): Closure { - return static function (\Dom\XPath $xpath) use ($functions) : \Dom\XPath { + return static function (XPath $xpath) use ($functions) : XPath { php_namespace()($xpath); $xpath->registerPhpFunctions($functions); diff --git a/src/Xml/Dom/Xpath/Configurator/namespaces.php b/src/Xml/Dom/Xpath/Configurator/namespaces.php index 99f45001..e2293908 100644 --- a/src/Xml/Dom/Xpath/Configurator/namespaces.php +++ b/src/Xml/Dom/Xpath/Configurator/namespaces.php @@ -5,16 +5,16 @@ namespace VeeWee\Xml\Dom\Xpath\Configurator; use Closure; -use \Dom\XPath; +use Dom\XPath; /** * @param array $namespaces * - * @return Closure(\Dom\XPath): \Dom\XPath + * @return Closure(XPath): XPath */ function namespaces(array $namespaces): Closure { - return static function (\Dom\XPath $xpath) use ($namespaces) : \Dom\XPath { + return static function (XPath $xpath) use ($namespaces) : XPath { foreach ($namespaces as $prefix => $namespaceURI) { $xpath->registerNamespace($prefix, $namespaceURI); } diff --git a/src/Xml/Dom/Xpath/Configurator/php_namespace.php b/src/Xml/Dom/Xpath/Configurator/php_namespace.php index ed9d06d4..67c159a2 100644 --- a/src/Xml/Dom/Xpath/Configurator/php_namespace.php +++ b/src/Xml/Dom/Xpath/Configurator/php_namespace.php @@ -5,15 +5,15 @@ namespace VeeWee\Xml\Dom\Xpath\Configurator; use Closure; -use \Dom\XPath; +use Dom\XPath; use VeeWee\Xml\Xmlns\Xmlns; /** - * @return Closure(\Dom\XPath): \Dom\XPath + * @return Closure(XPath): XPath */ function php_namespace(): Closure { - return static function (\Dom\XPath $xpath): \Dom\XPath { + return static function (XPath $xpath): XPath { namespaces(['php' => Xmlns::phpXpath()->value()])($xpath); return $xpath; diff --git a/src/Xml/Dom/Xpath/Locator/Locator.php b/src/Xml/Dom/Xpath/Locator/Locator.php index 5590d2f7..3e1d8601 100644 --- a/src/Xml/Dom/Xpath/Locator/Locator.php +++ b/src/Xml/Dom/Xpath/Locator/Locator.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Dom\Xpath\Locator; -use \Dom\XPath; +use Dom\XPath; /** * @template T @@ -14,5 +14,5 @@ interface Locator /** * @return T */ - public function __invoke(\Dom\XPath $xpath): mixed; + public function __invoke(XPath $xpath): mixed; } diff --git a/src/Xml/Dom/Xpath/Locator/evaluate.php b/src/Xml/Dom/Xpath/Locator/evaluate.php index 91bf7029..26497c49 100644 --- a/src/Xml/Dom/Xpath/Locator/evaluate.php +++ b/src/Xml/Dom/Xpath/Locator/evaluate.php @@ -4,8 +4,8 @@ namespace VeeWee\Xml\Dom\Xpath\Locator; use Closure; -use \Dom\Node; -use \Dom\XPath; +use Dom\Node; +use Dom\XPath; use Psl\Type\TypeInterface; use function VeeWee\Xml\ErrorHandling\disallow_issues; use function VeeWee\Xml\ErrorHandling\disallow_libxml_false_returns; @@ -15,15 +15,15 @@ * * @param TypeInterface $type * - * @return Closure(\Dom\XPath): T + * @return Closure(XPath): T */ -function evaluate(string $query, TypeInterface $type, ?\Dom\Node $node = null): Closure +function evaluate(string $query, TypeInterface $type, ?Node $node = null): Closure { return /** * @return T */ - static function (\Dom\XPath $xpath) use ($query, $node, $type) { + static function (XPath $xpath) use ($query, $node, $type) { $node = $node ?? $xpath->document->documentElement; return disallow_issues( diff --git a/src/Xml/Dom/Xpath/Locator/query.php b/src/Xml/Dom/Xpath/Locator/query.php index 4fd8e499..7b1c5d71 100644 --- a/src/Xml/Dom/Xpath/Locator/query.php +++ b/src/Xml/Dom/Xpath/Locator/query.php @@ -4,20 +4,20 @@ namespace VeeWee\Xml\Dom\Xpath\Locator; use Closure; -use \Dom\Node; -use \Dom\NodeList as DOMNodeList; -use \Dom\XPath; +use Dom\Node; +use Dom\NodeList as DOMNodeList; +use Dom\XPath; use VeeWee\Xml\Dom\Collection\NodeList; use function VeeWee\Xml\Dom\Assert\assert_dom_node_list; use function VeeWee\Xml\ErrorHandling\disallow_issues; use function VeeWee\Xml\ErrorHandling\disallow_libxml_false_returns; /** - * @return Closure(\Dom\XPath): NodeList<\Dom\Node> + * @return Closure(XPath): NodeList */ -function query(string $query, ?\Dom\Node $node = null): Closure +function query(string $query, ?Node $node = null): Closure { - return static function (\Dom\XPath $xpath) use ($query, $node): NodeList { + return static function (XPath $xpath) use ($query, $node): NodeList { $node = $node ?? $xpath->document->documentElement; $list = disallow_issues( diff --git a/src/Xml/Dom/Xpath/Locator/query_single.php b/src/Xml/Dom/Xpath/Locator/query_single.php index 96657f3b..6cd19734 100644 --- a/src/Xml/Dom/Xpath/Locator/query_single.php +++ b/src/Xml/Dom/Xpath/Locator/query_single.php @@ -4,9 +4,9 @@ namespace VeeWee\Xml\Dom\Xpath\Locator; use Closure; -use \Dom\Node; -use \Dom\NodeList; -use \Dom\XPath; +use Dom\Node; +use Dom\NodeList; +use Dom\XPath; use InvalidArgumentException; use VeeWee\Xml\Exception\RuntimeException; use Webmozart\Assert\Assert; @@ -16,19 +16,19 @@ use function VeeWee\Xml\ErrorHandling\disallow_libxml_false_returns; /** - * @return Closure(\Dom\XPath): \Dom\Node + * @return Closure(XPath): Node */ -function query_single(string $query, ?\Dom\Node $node = null): Closure +function query_single(string $query, ?Node $node = null): Closure { return /** * @throws InvalidArgumentException * @throws RuntimeException */ - static function (\Dom\XPath $xpath) use ($query, $node): \Dom\Node { + static function (XPath $xpath) use ($query, $node): Node { $node = $node ?? $xpath->document->documentElement; $list = disallow_issues( - static fn (): \Dom\NodeList => assert_dom_node_list( + static fn (): NodeList => assert_dom_node_list( disallow_libxml_false_returns( $xpath->query($query, $node), 'Failed querying XPath query: '.$query diff --git a/src/Xml/Encoding/Internal/Decoder/Builder/attribute.php b/src/Xml/Encoding/Internal/Decoder/Builder/attribute.php index 9ce2aa0b..3ea56fba 100644 --- a/src/Xml/Encoding/Internal/Decoder/Builder/attribute.php +++ b/src/Xml/Encoding/Internal/Decoder/Builder/attribute.php @@ -4,12 +4,12 @@ namespace VeeWee\Xml\Encoding\Internal\Decoder\Builder; -use \Dom\Attr; +use Dom\Attr; /** * @psalm-internal VeeWee\Xml\Encoding */ -function attribute(\Dom\Attr $attribute): array +function attribute(Attr $attribute): array { return [ name($attribute) => $attribute->nodeValue, diff --git a/src/Xml/Encoding/Internal/Decoder/Builder/attributes.php b/src/Xml/Encoding/Internal/Decoder/Builder/attributes.php index 8c6fd3e0..fbbf4495 100644 --- a/src/Xml/Encoding/Internal/Decoder/Builder/attributes.php +++ b/src/Xml/Encoding/Internal/Decoder/Builder/attributes.php @@ -4,8 +4,8 @@ namespace VeeWee\Xml\Encoding\Internal\Decoder\Builder; -use \Dom\Attr; -use \Dom\Element; +use Dom\Attr; +use Dom\Element; use function Psl\Dict\filter; use function Psl\Dict\merge; use function Psl\Iter\reduce; @@ -15,12 +15,12 @@ /** * @psalm-internal VeeWee\Xml\Encoding */ -function attributes(\Dom\Element $element): array +function attributes(Element $element): array { return filter([ '@attributes' => reduce( - attributes_list($element)->filter(static fn(\Dom\Attr $attr): bool => !is_xmlns_attribute($attr)), - static fn (array $attributes, \Dom\Attr $attr): array + attributes_list($element)->filter(static fn (Attr $attr): bool => !is_xmlns_attribute($attr)), + static fn (array $attributes, Attr $attr): array => merge($attributes, attribute($attr)), [] ) diff --git a/src/Xml/Encoding/Internal/Decoder/Builder/element.php b/src/Xml/Encoding/Internal/Decoder/Builder/element.php index 557bb560..ab7fdca5 100644 --- a/src/Xml/Encoding/Internal/Decoder/Builder/element.php +++ b/src/Xml/Encoding/Internal/Decoder/Builder/element.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Encoding\Internal\Decoder\Builder; -use \Dom\Element; +use Dom\Element; use VeeWee\Xml\Exception\RuntimeException; use function Psl\Dict\filter; use function Psl\Dict\merge; @@ -14,7 +14,7 @@ * @return array * @throws RuntimeException */ -function element(\Dom\Element $element): array +function element(Element $element): array { $name = name($element); $children = grouped_children($element); diff --git a/src/Xml/Encoding/Internal/Decoder/Builder/group_child_elements.php b/src/Xml/Encoding/Internal/Decoder/Builder/group_child_elements.php index 2ad94deb..8c011215 100644 --- a/src/Xml/Encoding/Internal/Decoder/Builder/group_child_elements.php +++ b/src/Xml/Encoding/Internal/Decoder/Builder/group_child_elements.php @@ -4,15 +4,15 @@ namespace VeeWee\Xml\Encoding\Internal\Decoder\Builder; -use \Dom\Element; +use Dom\Element; use function VeeWee\Xml\Dom\Locator\Element\children; /** - * @psalm-type GroupedElements=array> + * @psalm-type GroupedElements=array> * @psalm-internal VeeWee\Xml\Encoding * @return GroupedElements */ -function group_child_elements(\Dom\Element $element): array +function group_child_elements(Element $element): array { /** @var GroupedElements $grouped */ $grouped = []; diff --git a/src/Xml/Encoding/Internal/Decoder/Builder/grouped_children.php b/src/Xml/Encoding/Internal/Decoder/Builder/grouped_children.php index cb083ba8..5f62bdda 100644 --- a/src/Xml/Encoding/Internal/Decoder/Builder/grouped_children.php +++ b/src/Xml/Encoding/Internal/Decoder/Builder/grouped_children.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Encoding\Internal\Decoder\Builder; -use \Dom\Element; +use Dom\Element; use function Psl\Dict\map; use function Psl\Dict\merge; use function Psl\Iter\reduce_with_keys; @@ -13,21 +13,19 @@ * @psalm-internal VeeWee\Xml\Encoding * */ -function grouped_children(\Dom\Element $element): array +function grouped_children(Element $element): array { return reduce_with_keys( group_child_elements($element), /** - * @param array $children - * @param \Dom\Element|list<\Dom\Element> $child - * @return array + * @param Element|list $child */ - static fn (array $children, string $name, \Dom\Element|array $child): array + static fn (array $children, string $name, Element|array $child): array => merge( $children, [ $name => is_array($child) - ? [...map($child, static fn (\Dom\Element $child): array|string + ? [...map($child, static fn (Element $child): array|string => unwrap_element(element($child)))] : unwrap_element(element($child)) ] diff --git a/src/Xml/Encoding/Internal/Decoder/Builder/name.php b/src/Xml/Encoding/Internal/Decoder/Builder/name.php index 3daa510a..5461e673 100644 --- a/src/Xml/Encoding/Internal/Decoder/Builder/name.php +++ b/src/Xml/Encoding/Internal/Decoder/Builder/name.php @@ -4,12 +4,12 @@ namespace VeeWee\Xml\Encoding\Internal\Decoder\Builder; -use \Dom\Node; +use Dom\Node; /** * @psalm-internal VeeWee\Xml\Encoding */ -function name(\Dom\Node $node): string +function name(Node $node): string { return $node->nodeName; } diff --git a/src/Xml/Encoding/Internal/Decoder/Builder/namespaces.php b/src/Xml/Encoding/Internal/Decoder/Builder/namespaces.php index d216d125..19d3a484 100644 --- a/src/Xml/Encoding/Internal/Decoder/Builder/namespaces.php +++ b/src/Xml/Encoding/Internal/Decoder/Builder/namespaces.php @@ -4,7 +4,8 @@ namespace VeeWee\Xml\Encoding\Internal\Decoder\Builder; -use \Dom\Element; +use Dom\Attr; +use Dom\Element; use VeeWee\Xml\Exception\RuntimeException; use function Psl\Dict\filter; use function Psl\Dict\merge; @@ -15,11 +16,11 @@ * @psalm-suppress RedundantCast * @throws RuntimeException */ -function namespaces(\Dom\Element $element): array +function namespaces(Element $element): array { return filter([ '@namespaces' => xmlns_attributes_list($element)->reduce( - static fn (array $namespaces, \Dom\Attr $node) + static fn (array $namespaces, Attr $node) => $node->value ? merge($namespaces, [ ($node->prefix !== null ? $node->localName : '') => $node->value diff --git a/src/Xml/Encoding/Internal/Encoder/Builder/children.php b/src/Xml/Encoding/Internal/Encoder/Builder/children.php index 0053ac99..96227bc1 100644 --- a/src/Xml/Encoding/Internal/Encoder/Builder/children.php +++ b/src/Xml/Encoding/Internal/Encoder/Builder/children.php @@ -5,7 +5,7 @@ namespace VeeWee\Xml\Encoding\Internal\Encoder\Builder; use Closure; -use \Dom\Element; +use Dom\Element; use function Psl\Dict\map; use function VeeWee\Xml\Dom\Builder\children as buildChildren; use function VeeWee\Xml\Dom\Builder\element as elementBuilder; @@ -16,7 +16,7 @@ * * @psalm-suppress LessSpecificReturnStatement, MoreSpecificReturnType * - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ function children(string $name, array $children): Closure { @@ -24,7 +24,7 @@ function children(string $name, array $children): Closure ...map( $children, /** - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ static fn (array|string $data): Closure => is_array($data) ? element($name, $data) diff --git a/src/Xml/Encoding/Internal/Encoder/Builder/element.php b/src/Xml/Encoding/Internal/Encoder/Builder/element.php index 40a29f28..901fa3f7 100644 --- a/src/Xml/Encoding/Internal/Encoder/Builder/element.php +++ b/src/Xml/Encoding/Internal/Encoder/Builder/element.php @@ -5,7 +5,7 @@ namespace VeeWee\Xml\Encoding\Internal\Encoder\Builder; use Closure; -use \Dom\Element; +use Dom\Element; use Psl\Exception\InvariantViolationException; use Psl\Type\Exception\AssertException; use function Psl\Dict\filter_keys; @@ -28,7 +28,7 @@ * @psalm-internal VeeWee\Xml\Encoding * @psalm-suppress LessSpecificReturnStatement, MoreSpecificReturnType * - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element * * @throws AssertException * @throws InvariantViolationException @@ -49,7 +49,7 @@ function element(string $name, array $data): Closure $currentNamespace = $namespaces[''] ?? null; $namedNamespaces = filter_keys($namespaces ?? []); - /** @var list $children */ + /** @var list $children */ $children = filter_nulls([ $attributes !== null ? attributes($attributes) : null, $namedNamespaces ? xmlns_attributes($namedNamespaces) : null, @@ -59,7 +59,7 @@ function element(string $name, array $data): Closure $element, /** * @param string|array $value - * @return Closure(\Dom\Element): \Dom\Element + * @return Closure(Element): Element */ static fn (string $name, string|array $value): Closure => parent_node($name, $value) diff --git a/src/Xml/Encoding/Internal/Encoder/Builder/parent_node.php b/src/Xml/Encoding/Internal/Encoder/Builder/parent_node.php index 58eb5fce..89b52364 100644 --- a/src/Xml/Encoding/Internal/Encoder/Builder/parent_node.php +++ b/src/Xml/Encoding/Internal/Encoder/Builder/parent_node.php @@ -5,8 +5,8 @@ namespace VeeWee\Xml\Encoding\Internal\Encoder\Builder; use Closure; -use \Dom\Element; -use \Dom\Node; +use Dom\Element; +use Dom\Node; use Psl\Exception\InvariantViolationException; use Psl\Type\Exception\AssertException; use function VeeWee\Xml\Dom\Builder\children as buildChildren; @@ -17,7 +17,7 @@ * @psalm-internal VeeWee\Xml\Encoding * @psalm-suppress LessSpecificReturnStatement, MoreSpecificReturnType * - * @return Closure(\Dom\Node): \Dom\Element + * @return Closure(Node): Element * * @throws AssertException * @throws InvariantViolationException diff --git a/src/Xml/Encoding/Internal/Encoder/Builder/root.php b/src/Xml/Encoding/Internal/Encoder/Builder/root.php index 4a8068a2..8d2b5596 100644 --- a/src/Xml/Encoding/Internal/Encoder/Builder/root.php +++ b/src/Xml/Encoding/Internal/Encoder/Builder/root.php @@ -5,8 +5,8 @@ namespace VeeWee\Xml\Encoding\Internal\Encoder\Builder; use Closure; -use \Dom\XMLDocument; -use \Dom\Node; +use Dom\Node; +use Dom\XMLDocument; use Psl\Exception\InvariantViolationException; use VeeWee\Xml\Encoding\Exception\EncodingException; use function Psl\Dict\map_with_key; @@ -14,7 +14,7 @@ /** * @psalm-internal VeeWee\Xml\Encoding - * @return Closure(\Dom\XMLDocument): list<\Dom\Node> + * @return Closure(XMLDocument): list * * @throws EncodingException * @throws InvariantViolationException diff --git a/src/Xml/Encoding/document_encode.php b/src/Xml/Encoding/document_encode.php index 17ed93bf..8535fe40 100644 --- a/src/Xml/Encoding/document_encode.php +++ b/src/Xml/Encoding/document_encode.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Encoding; -use \Dom\XMLDocument as DOMDocument; +use Dom\XMLDocument as DOMDocument; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Encoding\Exception\EncodingException; use function VeeWee\Xml\Encoding\Internal\Encoder\Builder\normalize_data; diff --git a/src/Xml/Encoding/element_decode.php b/src/Xml/Encoding/element_decode.php index 82af963d..feb2569b 100644 --- a/src/Xml/Encoding/element_decode.php +++ b/src/Xml/Encoding/element_decode.php @@ -4,8 +4,8 @@ namespace VeeWee\Xml\Encoding; -use \Dom\XMLDocument as DOMDocument; -use \Dom\Element; +use Dom\Element; +use Dom\XMLDocument as DOMDocument; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Encoding\Exception\EncodingException; use function VeeWee\Xml\Dom\Locator\document_element; @@ -17,7 +17,7 @@ * * @throws EncodingException */ -function element_decode(\Dom\Element $element, callable ... $configurators): array +function element_decode(Element $element, callable ... $configurators): array { return wrap_exception( static function () use ($element, $configurators): array { diff --git a/src/Xml/Encoding/element_encode.php b/src/Xml/Encoding/element_encode.php index 81866c51..9514ee44 100644 --- a/src/Xml/Encoding/element_encode.php +++ b/src/Xml/Encoding/element_encode.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Encoding; -use \Dom\XMLDocument as DOMDocument; +use Dom\XMLDocument as DOMDocument; use VeeWee\Xml\Encoding\Exception\EncodingException; use function VeeWee\Xml\Dom\Locator\document_element; use function VeeWee\Xml\Dom\Mapper\xml_string; diff --git a/src/Xml/Encoding/typed.php b/src/Xml/Encoding/typed.php index feefb7f3..0266de22 100644 --- a/src/Xml/Encoding/typed.php +++ b/src/Xml/Encoding/typed.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Encoding; -use \Dom\XMLDocument; +use Dom\XMLDocument; use Psl\Type\Exception\CoercionException; use Psl\Type\TypeInterface; use VeeWee\Xml\Encoding\Exception\EncodingException; @@ -14,7 +14,7 @@ * * @psalm-param non-empty-string $xml * @psalm-param TypeInterface $type - * @param list $configurators + * @param list $configurators * * @return T * diff --git a/src/Xml/Encoding/xml_decode.php b/src/Xml/Encoding/xml_decode.php index 937e3352..b4df4d05 100644 --- a/src/Xml/Encoding/xml_decode.php +++ b/src/Xml/Encoding/xml_decode.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Encoding; -use \Dom\XMLDocument as DOMDocument; +use Dom\XMLDocument as DOMDocument; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Encoding\Exception\EncodingException; use function VeeWee\Xml\Dom\Locator\document_element; diff --git a/src/Xml/Encoding/xml_encode.php b/src/Xml/Encoding/xml_encode.php index 8fe6a07f..9180262e 100644 --- a/src/Xml/Encoding/xml_encode.php +++ b/src/Xml/Encoding/xml_encode.php @@ -4,7 +4,7 @@ namespace VeeWee\Xml\Encoding; -use \Dom\XMLDocument as DOMDocument; +use Dom\XMLDocument as DOMDocument; use VeeWee\Xml\Encoding\Exception\EncodingException; use function VeeWee\Xml\Encoding\Internal\wrap_exception; diff --git a/src/Xml/ErrorHandling/detect_issues.php b/src/Xml/ErrorHandling/detect_issues.php index 37ad2e5c..b8fa0fc6 100644 --- a/src/Xml/ErrorHandling/detect_issues.php +++ b/src/Xml/ErrorHandling/detect_issues.php @@ -6,7 +6,6 @@ use Psl\Result; use Psl\Result\ResultInterface; - use VeeWee\Xml\ErrorHandling\Issue\IssueCollection; use function libxml_clear_errors; use function libxml_get_errors; diff --git a/src/Xml/ErrorHandling/stop_on_first_issue.php b/src/Xml/ErrorHandling/stop_on_first_issue.php index 1bbb5565..65ba4574 100644 --- a/src/Xml/ErrorHandling/stop_on_first_issue.php +++ b/src/Xml/ErrorHandling/stop_on_first_issue.php @@ -5,7 +5,6 @@ namespace VeeWee\Xml\ErrorHandling; use Generator; - use Psl\Vec; use VeeWee\Xml\Exception\RuntimeException; use function libxml_clear_errors; diff --git a/src/Xml/Internal/configure.php b/src/Xml/Internal/configure.php index c339e28d..230e938b 100644 --- a/src/Xml/Internal/configure.php +++ b/src/Xml/Internal/configure.php @@ -3,7 +3,6 @@ namespace VeeWee\Xml\Internal; use Closure; - use Psl\Iter; /** diff --git a/src/Xml/Reader/MatchingNode.php b/src/Xml/Reader/MatchingNode.php index c51b5c5a..fb0d17ac 100644 --- a/src/Xml/Reader/MatchingNode.php +++ b/src/Xml/Reader/MatchingNode.php @@ -3,7 +3,7 @@ namespace VeeWee\Xml\Reader; -use \Dom\XMLDocument as DOMDocument; +use Dom\XMLDocument as DOMDocument; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Encoding\Exception\EncodingException; use VeeWee\Xml\Exception\RuntimeException; diff --git a/src/Xml/Reader/Node/NodeSequence.php b/src/Xml/Reader/Node/NodeSequence.php index 924bd7ee..425cbbee 100644 --- a/src/Xml/Reader/Node/NodeSequence.php +++ b/src/Xml/Reader/Node/NodeSequence.php @@ -8,6 +8,7 @@ use Generator; use InvalidArgumentException; use Webmozart\Assert\Assert; +use function count; use function Psl\Vec\slice; final class NodeSequence implements Countable @@ -69,7 +70,7 @@ public function sequence(): array public function count(): int { - return \count($this->elementNodes); + return count($this->elementNodes); } /** diff --git a/tests/Xml/Dom/Assert/AssertAttributeTest.php b/tests/Xml/Dom/Assert/AssertAttributeTest.php index e94a26c0..ae96da78 100644 --- a/tests/Xml/Dom/Assert/AssertAttributeTest.php +++ b/tests/Xml/Dom/Assert/AssertAttributeTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Assert; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use Psl\Type\Exception\AssertException; use VeeWee\Xml\Dom\Document; @@ -16,7 +16,7 @@ final class AssertAttributeTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_attributes(?\DOM\Node $node, bool $expected): void + public function test_it_knows_attributes(?Node $node, bool $expected): void { if (!$expected) { $this->expectException(AssertException::class); diff --git a/tests/Xml/Dom/Assert/AssertCDataTest.php b/tests/Xml/Dom/Assert/AssertCDataTest.php index 2ff980a5..82ac916f 100644 --- a/tests/Xml/Dom/Assert/AssertCDataTest.php +++ b/tests/Xml/Dom/Assert/AssertCDataTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Assert; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use Psl\Type\Exception\AssertException; use VeeWee\Xml\Dom\Document; @@ -16,7 +16,7 @@ final class AssertCDataTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_cdata(?\DOM\Node $node, bool $expected): void + public function test_it_knows_cdata(?Node $node, bool $expected): void { if (!$expected) { $this->expectException(AssertException::class); diff --git a/tests/Xml/Dom/Assert/AssertDocumentTest.php b/tests/Xml/Dom/Assert/AssertDocumentTest.php index 1bb36745..303362ee 100644 --- a/tests/Xml/Dom/Assert/AssertDocumentTest.php +++ b/tests/Xml/Dom/Assert/AssertDocumentTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Assert; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use Psl\Type\Exception\AssertException; use VeeWee\Xml\Dom\Document; @@ -16,7 +16,7 @@ final class AssertDocumentTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_documents(?\DOM\Node $node, bool $expected): void + public function test_it_knows_documents(?Node $node, bool $expected): void { if (!$expected) { $this->expectException(AssertException::class); diff --git a/tests/Xml/Dom/Assert/AssertElementTest.php b/tests/Xml/Dom/Assert/AssertElementTest.php index 910c2f34..4c2bf504 100644 --- a/tests/Xml/Dom/Assert/AssertElementTest.php +++ b/tests/Xml/Dom/Assert/AssertElementTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Assert; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use Psl\Type\Exception\AssertException; use VeeWee\Xml\Dom\Document; @@ -16,7 +16,7 @@ final class AssertElementTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_elements(?\DOM\Node $node, bool $expected): void + public function test_it_knows_elements(?Node $node, bool $expected): void { if (!$expected) { $this->expectException(AssertException::class); diff --git a/tests/Xml/Dom/Builder/AttributesTest.php b/tests/Xml/Dom/Builder/AttributesTest.php index 3701fd28..36ac9ef8 100644 --- a/tests/Xml/Dom/Builder/AttributesTest.php +++ b/tests/Xml/Dom/Builder/AttributesTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Builder\attribute; diff --git a/tests/Xml/Dom/Builder/CdataTest.php b/tests/Xml/Dom/Builder/CdataTest.php index 00a0027a..596246c3 100644 --- a/tests/Xml/Dom/Builder/CdataTest.php +++ b/tests/Xml/Dom/Builder/CdataTest.php @@ -4,8 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\CDATASection; -use \DOM\XMLDocument; +use DOM\CDATASection; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function Psl\Fun\identity; @@ -19,7 +18,7 @@ public function test_it_can_build_cdata(): void $doc = Document::empty()->toUnsafeDocument(); $node = cdata($data = 'hello')($doc); - static::assertInstanceOf(\DOM\CDATASection::class, $node); + static::assertInstanceOf(CDATASection::class, $node); static::assertSame($data, $node->textContent); static::assertSame(xml_string()($node), ''); } @@ -29,7 +28,7 @@ public function test_it_can_build_cdata_with_configurators(): void $doc = Document::empty()->toUnsafeDocument(); $node = cdata($data = 'hello', identity())($doc); - static::assertInstanceOf(\DOM\CDATASection::class, $node); + static::assertInstanceOf(CDATASection::class, $node); static::assertSame($data, $node->textContent); } } diff --git a/tests/Xml/Dom/Builder/ChildrenTest.php b/tests/Xml/Dom/Builder/ChildrenTest.php index ef58f2fe..2e832342 100644 --- a/tests/Xml/Dom/Builder/ChildrenTest.php +++ b/tests/Xml/Dom/Builder/ChildrenTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Builder\cdata; diff --git a/tests/Xml/Dom/Builder/ElementTest.php b/tests/Xml/Dom/Builder/ElementTest.php index bd6d9c9a..4ffeb3f0 100644 --- a/tests/Xml/Dom/Builder/ElementTest.php +++ b/tests/Xml/Dom/Builder/ElementTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function Psl\Fun\identity; diff --git a/tests/Xml/Dom/Builder/EscapedValueTest.php b/tests/Xml/Dom/Builder/EscapedValueTest.php index c4efa448..c5e4c66e 100644 --- a/tests/Xml/Dom/Builder/EscapedValueTest.php +++ b/tests/Xml/Dom/Builder/EscapedValueTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Builder\element; diff --git a/tests/Xml/Dom/Builder/NamespacedAttributeTest.php b/tests/Xml/Dom/Builder/NamespacedAttributeTest.php index 6b788834..7d8da95b 100644 --- a/tests/Xml/Dom/Builder/NamespacedAttributeTest.php +++ b/tests/Xml/Dom/Builder/NamespacedAttributeTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\XMLDocument; use InvalidArgumentException; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; diff --git a/tests/Xml/Dom/Builder/NamespacedElementTest.php b/tests/Xml/Dom/Builder/NamespacedElementTest.php index 29be4bf2..2bd47fb5 100644 --- a/tests/Xml/Dom/Builder/NamespacedElementTest.php +++ b/tests/Xml/Dom/Builder/NamespacedElementTest.php @@ -4,8 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\XMLDocument; -use \DOM\Element; +use DOM\Element; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function Psl\Fun\identity; @@ -18,7 +17,7 @@ public function test_it_can_build_an_element_with_alias(): void { $doc = Document::empty()->toUnsafeDocument(); $ns = 'https://namespace.com'; - /** @var \DOM\Element $node */ + /** @var Element $node */ $node = namespaced_element($ns, 'ns:hello')($doc); static::assertSame($ns, $node->namespaceURI); @@ -33,7 +32,7 @@ public function test_it_can_build_an_element_without_alias(): void { $doc = Document::empty()->toUnsafeDocument(); $ns = 'https://namespace.com'; - /** @var \DOM\Element $node */ + /** @var Element $node */ $node = namespaced_element($ns, 'hello')($doc); static::assertSame($ns, $node->namespaceURI); diff --git a/tests/Xml/Dom/Builder/NodesTest.php b/tests/Xml/Dom/Builder/NodesTest.php index 98bc22f3..c97c16e4 100644 --- a/tests/Xml/Dom/Builder/NodesTest.php +++ b/tests/Xml/Dom/Builder/NodesTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\XMLDocument; +use DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Builder\element; @@ -18,7 +18,7 @@ public function test_it_can_build_nodes(): void $nodes = nodes( element('hello'), element('world'), - static fn (\DOM\XMLDocument $doc): array => [ + static fn (XMLDocument $doc): array => [ element('many1')($doc), element('many2')($doc), ], diff --git a/tests/Xml/Dom/Builder/ValueTest.php b/tests/Xml/Dom/Builder/ValueTest.php index 00453eaa..10693c74 100644 --- a/tests/Xml/Dom/Builder/ValueTest.php +++ b/tests/Xml/Dom/Builder/ValueTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Builder\element; diff --git a/tests/Xml/Dom/Builder/XmlnsAttributesTest.php b/tests/Xml/Dom/Builder/XmlnsAttributesTest.php index 27c90c1e..25736573 100644 --- a/tests/Xml/Dom/Builder/XmlnsAttributesTest.php +++ b/tests/Xml/Dom/Builder/XmlnsAttributesTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Builder; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Builder\element; diff --git a/tests/Xml/Dom/Collection/NodeListTest.php b/tests/Xml/Dom/Collection/NodeListTest.php index c1dd517d..0f0a442e 100644 --- a/tests/Xml/Dom/Collection/NodeListTest.php +++ b/tests/Xml/Dom/Collection/NodeListTest.php @@ -4,9 +4,9 @@ namespace VeeWee\Tests\Xml\Dom\Collection; -use \DOM\Attr; -use \DOM\Element; -use \DOM\Node; +use DOM\Attr; +use DOM\Element; +use DOM\Node; use InvalidArgumentException; use PHPUnit\Framework\TestCase; use Psl\Collection\MutableVector; @@ -66,20 +66,20 @@ public function test_it_can_be_iterated(): void static::assertCount(4, $items); static::assertIsIterable($items); foreach ($items as $item) { - static::assertInstanceOf(\DOM\Element::class, $item); + static::assertInstanceOf(Element::class, $item); } } public function test_it_can_be_created_typed(): void { $items = NodeList::typed( - \DOM\Element::class, + Element::class, $items = $this->loadProducts() ); static::assertCount(4, $items); foreach ($items as $item) { - static::assertInstanceOf(\DOM\Element::class, $item); + static::assertInstanceOf(Element::class, $item); } } @@ -87,7 +87,7 @@ public function test_it_will_trigger_error_when_created_with_invalid_type(): voi { $this->expectException(InvalidArgumentException::class); NodeList::typed( - \DOM\Element::class, + Element::class, $this->loadProducts()->eq(0)->first()->attributes ); } @@ -120,7 +120,7 @@ public function test_it_can_expect_items() public function test_it_can_map(): void { $items = $this->loadProducts()->map( - static fn (\DOM\Element $element): string => $element->textContent + static fn (Element $element): string => $element->textContent ); static::assertSame( @@ -138,7 +138,7 @@ public function test_it_can_loop_over_all_items(): void { $x = new MutableVector([]); $this->loadProducts()->forEach( - static function (\DOM\Element $element) use ($x) : void { + static function (Element $element) use ($x) : void { $x->add($element->textContent); } ); @@ -158,7 +158,7 @@ public function test_it_can_filter(): void { $all = $this->loadProducts(); $filtered = $all->filter( - static fn (\DOM\Element $element): bool => (bool) ((int)($element->getAttribute('id'))%2) + static fn (Element $element): bool => (bool) ((int)($element->getAttribute('id'))%2) ); static::assertCount(2, $filtered); @@ -170,7 +170,7 @@ public function test_it_can_filter(): void public function test_it_can_reduce(): void { $total = $this->loadPrices()->reduce( - static fn (int $total, \DOM\Element $element): int => $total + (int) $element->textContent, + static fn (int $total, Element $element): int => $total + (int) $element->textContent, 0 ); @@ -180,9 +180,9 @@ public function test_it_can_reduce(): void public function test_it_can_detect(): void { $list = $this->root()->detect( - static fn (\DOM\Element $element) => filter( + static fn (Element $element) => filter( $element->childNodes, - static fn (\DOM\Node $current) => is_element($current) + static fn (Node $current) => is_element($current) ) ); @@ -261,7 +261,7 @@ public function test_it_can_expect_single_on_a_two_item_list(): void $prices = $this->loadPrices(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Expected single element, got 2 elements.'); - $prices->filter(static fn (\DOM\Element $price): bool => (int)$price->textContent >= 2)->expectSingle('Expected single element, got %s elements.'); + $prices->filter(static fn (Element $price): bool => (int)$price->textContent >= 2)->expectSingle('Expected single element, got %s elements.'); } public function test_it_can_get_last(): void @@ -316,7 +316,7 @@ public function test_it_can_search_siblings(): void public function test_it_can_validate_types(): void { $prices = $this->loadPrices(); - $result = $prices->expectAllOfType(\DOM\Element::class); + $result = $prices->expectAllOfType(Element::class); static::assertSame([...$prices], [...$result]); } @@ -325,13 +325,13 @@ public function test_it_can_validate_types_and_fail(): void { $this->expectException(InvalidArgumentException::class); $prices = $this->loadPrices(); - $prices->expectAllOfType(\DOM\Attr::class); + $prices->expectAllOfType(Attr::class); } public function test_it_can_sort(): void { $prices = $this->loadPrices(); - $sorted = $prices->sort(static fn (\DOM\Node $a, \DOM\Node $b) => $b->textContent <=> $a->textContent); + $sorted = $prices->sort(static fn (Node $a, Node $b) => $b->textContent <=> $a->textContent); static::assertSame( [ diff --git a/tests/Xml/Dom/Configurator/DocumentUriTest.php b/tests/Xml/Dom/Configurator/DocumentUriTest.php index 492134a0..b8ae4cb9 100644 --- a/tests/Xml/Dom/Configurator/DocumentUriTest.php +++ b/tests/Xml/Dom/Configurator/DocumentUriTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Configurator; -use DOM\XMLDocument as DOMDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Configurator\document_uri; diff --git a/tests/Xml/Dom/Configurator/FormatOutputTest.php b/tests/Xml/Dom/Configurator/FormatOutputTest.php index 6cd1eeea..946351f7 100644 --- a/tests/Xml/Dom/Configurator/FormatOutputTest.php +++ b/tests/Xml/Dom/Configurator/FormatOutputTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Configurator; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Configurator\format_output; @@ -21,8 +20,7 @@ public function test_it_can_trim_contents( string $input, string $expected, ?int $flags - ): void - { + ): void { $configurator = $formatOutput === null ? format_output() : format_output($formatOutput); $doc = Document::fromLoader( diff --git a/tests/Xml/Dom/Configurator/PrettyPrintTest.php b/tests/Xml/Dom/Configurator/PrettyPrintTest.php index 05a87d66..a5d98ee3 100644 --- a/tests/Xml/Dom/Configurator/PrettyPrintTest.php +++ b/tests/Xml/Dom/Configurator/PrettyPrintTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Configurator; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Configurator\pretty_print; diff --git a/tests/Xml/Dom/Configurator/TraverseTest.php b/tests/Xml/Dom/Configurator/TraverseTest.php index aff13a62..d2f87194 100644 --- a/tests/Xml/Dom/Configurator/TraverseTest.php +++ b/tests/Xml/Dom/Configurator/TraverseTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Configurator; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Dom\Traverser\Action; @@ -18,7 +18,7 @@ public function test_it_can_traverse(): void { $doc = Document::fromXmlString('world', traverse( new class() extends AbstractVisitor { - public function onNodeLeave(\DOM\Node $node): Action + public function onNodeLeave(Node $node): Action { return is_text($node) ? new Action\RemoveNode() diff --git a/tests/Xml/Dom/Configurator/TrimSpacesTest.php b/tests/Xml/Dom/Configurator/TrimSpacesTest.php index 960e4373..db48ec97 100644 --- a/tests/Xml/Dom/Configurator/TrimSpacesTest.php +++ b/tests/Xml/Dom/Configurator/TrimSpacesTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Configurator; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Configurator\trim_spaces; diff --git a/tests/Xml/Dom/Configurator/Utf8Test.php b/tests/Xml/Dom/Configurator/Utf8Test.php index de470e6f..d7705f5e 100644 --- a/tests/Xml/Dom/Configurator/Utf8Test.php +++ b/tests/Xml/Dom/Configurator/Utf8Test.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Configurator; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Configurator\utf8; diff --git a/tests/Xml/Dom/Configurator/ValidatorTest.php b/tests/Xml/Dom/Configurator/ValidatorTest.php index eef307b7..958fa82b 100644 --- a/tests/Xml/Dom/Configurator/ValidatorTest.php +++ b/tests/Xml/Dom/Configurator/ValidatorTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Configurator; -use \DOM\XMLDocument; +use DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Tests\Xml\ErrorHandling\Issue\UseIssueTrait; use VeeWee\Xml\Dom\Document; @@ -21,7 +21,7 @@ final class ValidatorTest extends TestCase public function test_it_can_configure_xml_with_valid_validation_result(): void { $doc = Document::empty()->toUnsafeDocument(); - $validator = validator(static fn (\DOM\XMLDocument $doc): IssueCollection => new IssueCollection()); + $validator = validator(static fn (XMLDocument $doc): IssueCollection => new IssueCollection()); $result = $validator($doc); static::assertSame($doc, $result); @@ -31,7 +31,7 @@ public function test_it_can_configure_xml_with_valid_validation_result(): void public function test_it_can_configure_xml_with_invalid_validation_result(): void { $doc = Document::empty()->toUnsafeDocument(); - $validator = validator(fn (\DOM\XMLDocument $doc): IssueCollection => new IssueCollection( + $validator = validator(fn (XMLDocument $doc): IssueCollection => new IssueCollection( $this->createIssue(Level::fatal()) )); diff --git a/tests/Xml/Dom/DocumentTest.php b/tests/Xml/Dom/DocumentTest.php index ee4be471..045e656f 100644 --- a/tests/Xml/Dom/DocumentTest.php +++ b/tests/Xml/Dom/DocumentTest.php @@ -4,8 +4,8 @@ namespace VeeWee\Tests\Xml\Dom; -use \DOM\XMLDocument; -use \DOM\Node; +use DOM\Node; +use DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Tests\Xml\Helper\FillFileTrait; use VeeWee\Xml\Dom\Document; @@ -118,7 +118,7 @@ public function test_it_can_traverse(): void $doc = Document::fromXmlString('world'); $result = $doc->traverse( new class() extends AbstractVisitor { - public function onNodeLeave(\DOM\Node $node): Action + public function onNodeLeave(Node $node): Action { return is_text($node) ? new Action\RemoveNode() diff --git a/tests/Xml/Dom/Loader/XmlFileLoaderTest.php b/tests/Xml/Dom/Loader/XmlFileLoaderTest.php index 0d005b2a..6c52e1a5 100644 --- a/tests/Xml/Dom/Loader/XmlFileLoaderTest.php +++ b/tests/Xml/Dom/Loader/XmlFileLoaderTest.php @@ -4,12 +4,10 @@ namespace VeeWee\Tests\Xml\Dom\Loader; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Tests\Xml\Helper\FillFileTrait; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Loader\xml_file_loader; -use function VeeWee\Xml\Dom\Loader\xml_string_loader; final class XmlFileLoaderTest extends TestCase { diff --git a/tests/Xml/Dom/Loader/XmlNodeLoaderTest.php b/tests/Xml/Dom/Loader/XmlNodeLoaderTest.php index ca3cc5a4..ff27afbc 100644 --- a/tests/Xml/Dom/Loader/XmlNodeLoaderTest.php +++ b/tests/Xml/Dom/Loader/XmlNodeLoaderTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Loader; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Exception\RuntimeException; diff --git a/tests/Xml/Dom/Loader/XmlStringLoaderTest.php b/tests/Xml/Dom/Loader/XmlStringLoaderTest.php index 73a6fca0..72235af7 100644 --- a/tests/Xml/Dom/Loader/XmlStringLoaderTest.php +++ b/tests/Xml/Dom/Loader/XmlStringLoaderTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Loader; -use \DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Loader\xml_string_loader; diff --git a/tests/Xml/Dom/Locator/Attribute/AttributesListTest.php b/tests/Xml/Dom/Locator/Attribute/AttributesListTest.php index be1b2e2a..5dc9c308 100644 --- a/tests/Xml/Dom/Locator/Attribute/AttributesListTest.php +++ b/tests/Xml/Dom/Locator/Attribute/AttributesListTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Locator\Attribute; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Locator\Attribute\attributes_list; @@ -14,7 +14,7 @@ final class AttributesListTest extends TestCase /** * @dataProvider provideTestCases */ - public function test_it_can_fetch_xmlns_attribute_list_from_node(\DOM\Node $node, array $expected): void + public function test_it_can_fetch_xmlns_attribute_list_from_node(Node $node, array $expected): void { $actual = attributes_list($node); diff --git a/tests/Xml/Dom/Locator/Attribute/XmlnsAttributesListTest.php b/tests/Xml/Dom/Locator/Attribute/XmlnsAttributesListTest.php index a63aa0da..a8e78686 100644 --- a/tests/Xml/Dom/Locator/Attribute/XmlnsAttributesListTest.php +++ b/tests/Xml/Dom/Locator/Attribute/XmlnsAttributesListTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Locator\Attribute; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Locator\Attribute\xmlns_attributes_list; @@ -14,7 +14,7 @@ final class XmlnsAttributesListTest extends TestCase /** * @dataProvider provideTestCases */ - public function test_it_can_fetch_xmlns_attribute_list_from_node(\DOM\Node $node, array $expected): void + public function test_it_can_fetch_xmlns_attribute_list_from_node(Node $node, array $expected): void { $actual = xmlns_attributes_list($node); diff --git a/tests/Xml/Dom/Locator/Node/DetectDocumentTest.php b/tests/Xml/Dom/Locator/Node/DetectDocumentTest.php index 2d5ef0d4..d7c88127 100644 --- a/tests/Xml/Dom/Locator/Node/DetectDocumentTest.php +++ b/tests/Xml/Dom/Locator/Node/DetectDocumentTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom\Locator\Node; -use \DOM\Element; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Locator\Node\detect_document; diff --git a/tests/Xml/Dom/Locator/Xmlns/LinkedNamespacesTest.php b/tests/Xml/Dom/Locator/Xmlns/LinkedNamespacesTest.php index 5523e001..057d6e9f 100644 --- a/tests/Xml/Dom/Locator/Xmlns/LinkedNamespacesTest.php +++ b/tests/Xml/Dom/Locator/Xmlns/LinkedNamespacesTest.php @@ -4,7 +4,8 @@ namespace VeeWee\Tests\Xml\Dom\Locator\Xmlns; -use \DOM\NameSpaceNode; +use DOM\Element; +use DOM\NamespaceInfo; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function Psl\Dict\merge; @@ -41,11 +42,11 @@ public function test_it_can_detect_linked_namespaces(): void /** * @return array - Key : prefix, Value : namespace */ - private function parseLinkedNamespaces(\DOM\Element $element): array + private function parseLinkedNamespaces(Element $element): array { return reduce( linked_namespaces($element), - static fn (array $result, \DOM\NamespaceInfo $info) => merge( + static fn (array $result, NamespaceInfo $info) => merge( $result, [(string) $info->prefix => $info->namespaceURI] ), diff --git a/tests/Xml/Dom/Locator/Xmlns/RecursiveLinkedNamespacesTest.php b/tests/Xml/Dom/Locator/Xmlns/RecursiveLinkedNamespacesTest.php index 536e56a3..383d7072 100644 --- a/tests/Xml/Dom/Locator/Xmlns/RecursiveLinkedNamespacesTest.php +++ b/tests/Xml/Dom/Locator/Xmlns/RecursiveLinkedNamespacesTest.php @@ -4,14 +4,12 @@ namespace VeeWee\Tests\Xml\Dom\Locator\Xmlns; -use \DOM\NameSpaceNode; +use DOM\Element; +use DOM\NamespaceInfo; use PHPUnit\Framework\TestCase; -use VeeWee\Xml\Dom\Collection\NodeList; use VeeWee\Xml\Dom\Document; use function Psl\Dict\merge; use function Psl\Iter\reduce; -use function VeeWee\Xml\Dom\Locator\document_element; -use function VeeWee\Xml\Dom\Locator\Xmlns\linked_namespaces; use function VeeWee\Xml\Dom\Locator\Xmlns\recursive_linked_namespaces; final class RecursiveLinkedNamespacesTest extends TestCase @@ -44,11 +42,11 @@ public function test_it_can_detect_recursively_linked_namespaces(): void /** * @return array - Key : prefix, Value : namespace */ - private function parseRecursiveLinkedNamespaces(\DOM\Element $element): array + private function parseRecursiveLinkedNamespaces(Element $element): array { return reduce( recursive_linked_namespaces($element), - static fn (array $result, \DOM\NamespaceInfo $info) => merge( + static fn (array $result, NamespaceInfo $info) => merge( $result, [(string) $info->prefix => $info->namespaceURI] ), diff --git a/tests/Xml/Dom/Locator/Xsd/LocateXsdSchemasTest.php b/tests/Xml/Dom/Locator/Xsd/LocateXsdSchemasTest.php index 3289e5d2..9af3f31b 100644 --- a/tests/Xml/Dom/Locator/Xsd/LocateXsdSchemasTest.php +++ b/tests/Xml/Dom/Locator/Xsd/LocateXsdSchemasTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Locator\Xsd; -use \DOM\XMLDocument; +use DOM\XMLDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Xsd\Schema\Schema; @@ -60,7 +60,7 @@ public function test_it_can_locate_all_xsd_schemas(): void ); } - private function loadXsdContainer(): \DOM\XMLDocument + private function loadXsdContainer(): XMLDocument { $file = FIXTURE_DIR.'/dom/locator/xsd/xsdcontainer.xml'; static::assertFileExists($file); diff --git a/tests/Xml/Dom/Manipulator/Node/AppendExternalNodeTest.php b/tests/Xml/Dom/Manipulator/Node/AppendExternalNodeTest.php index b3f6bf25..0ab84301 100644 --- a/tests/Xml/Dom/Manipulator/Node/AppendExternalNodeTest.php +++ b/tests/Xml/Dom/Manipulator/Node/AppendExternalNodeTest.php @@ -4,9 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Manipulator\Node; -use \DOM\XMLDocument; -use \DOM\Element; -use Infected\PhpParser\Comment\Doc; +use DOM\Element; use PHPUnit\Framework\TestCase; use RuntimeException; use VeeWee\Xml\Dom\Document; @@ -21,7 +19,7 @@ public function test_it_can_import_a_node_into_a_document_root(): void $result = append_external_node($target, $source->documentElement); - static::assertInstanceOf(\DOM\Element::class, $result); + static::assertInstanceOf(Element::class, $result); static::assertSame('hello', $result->nodeName); static::assertXmlStringEqualsXmlString($source->saveXML(), $target->saveXML()); } @@ -45,7 +43,7 @@ public function test_it_can_recursively_import_a_node_into_another_document_node $result = append_external_node($target->documentElement, $source->documentElement->firstChild); - static::assertInstanceOf(\DOM\Element::class, $result); + static::assertInstanceOf(Element::class, $result); static::assertSame('world', $result->nodeName); static::assertXmlStringEqualsXmlString($source->saveXML(), $target->saveXML()); } diff --git a/tests/Xml/Dom/Manipulator/Node/ImportNodeDeeplyTest.php b/tests/Xml/Dom/Manipulator/Node/ImportNodeDeeplyTest.php index 43978713..9d0785ad 100644 --- a/tests/Xml/Dom/Manipulator/Node/ImportNodeDeeplyTest.php +++ b/tests/Xml/Dom/Manipulator/Node/ImportNodeDeeplyTest.php @@ -4,8 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Manipulator\Node; -use \DOM\XMLDocument; -use \DOM\Element; +use DOM\Element; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Exception\RuntimeException; @@ -20,7 +19,7 @@ public function test_it_can_import_a_node(): void $result = import_node_deeply($target, $source->documentElement); - static::assertInstanceOf(\DOM\Element::class, $result); + static::assertInstanceOf(Element::class, $result); static::assertSame('hello', $result->nodeName); } @@ -32,7 +31,7 @@ public function test_it_can_import_a_node_into_a_nodes_document(): void $result = import_node_deeply($target->documentElement, $source->documentElement); - static::assertInstanceOf(\DOM\Element::class, $result); + static::assertInstanceOf(Element::class, $result); static::assertSame('hello', $result->nodeName); } @@ -55,7 +54,7 @@ public function test_it_can_recursively_import_a_node_based_on_a_target_document $result = import_node_deeply($target, $source->documentElement->firstChild); - static::assertInstanceOf(\DOM\Element::class, $result); + static::assertInstanceOf(Element::class, $result); static::assertSame('world', $result->nodeName); static::assertSame('myvalue', $result->attributes->getNamedItem('myattrib')->textContent); static::assertSame('name', $result->firstChild->nodeName); diff --git a/tests/Xml/Dom/Manipulator/Node/RemoveTest.php b/tests/Xml/Dom/Manipulator/Node/RemoveTest.php index f6e68d49..5b8a6503 100644 --- a/tests/Xml/Dom/Manipulator/Node/RemoveTest.php +++ b/tests/Xml/Dom/Manipulator/Node/RemoveTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Manipulator\Node; -use \DOM\XMLDocument as DOMDocument; +use DOM\XMLDocument as DOMDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Exception\RuntimeException; diff --git a/tests/Xml/Dom/Manipulator/Node/RenameTest.php b/tests/Xml/Dom/Manipulator/Node/RenameTest.php index bf3d017d..a9baaf0f 100644 --- a/tests/Xml/Dom/Manipulator/Node/RenameTest.php +++ b/tests/Xml/Dom/Manipulator/Node/RenameTest.php @@ -4,14 +4,11 @@ namespace VeeWee\Tests\Xml\Dom\Manipulator\Node; -use \DOM\XMLDocument as DOMDocument; +use DOM\XMLDocument as DOMDocument; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Exception\RuntimeException; -use function VeeWee\Xml\Dom\Builder\xmlns_attribute; -use function VeeWee\Xml\Dom\Configurator\comparable; use function VeeWee\Xml\Dom\Locator\document_element; -use function VeeWee\Xml\Dom\Manipulator\Node\remove_namespace; use function VeeWee\Xml\Dom\Manipulator\Node\rename; use function VeeWee\Xml\Dom\Xpath\Configurator\namespaces; diff --git a/tests/Xml/Dom/Manipulator/Node/ReplaceByExternalNodeTest.php b/tests/Xml/Dom/Manipulator/Node/ReplaceByExternalNodeTest.php index c13d6946..01f4da19 100644 --- a/tests/Xml/Dom/Manipulator/Node/ReplaceByExternalNodeTest.php +++ b/tests/Xml/Dom/Manipulator/Node/ReplaceByExternalNodeTest.php @@ -4,8 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Manipulator\Node; -use \DOM\XMLDocument; -use \DOM\Element; +use DOM\Element; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Exception\RuntimeException; @@ -20,7 +19,7 @@ public function test_it_can_replace_a_node(): void $result = replace_by_external_node($target->documentElement, $source->documentElement); - static::assertInstanceOf(\DOM\Element::class, $result); + static::assertInstanceOf(Element::class, $result); static::assertSame('hello', $result->nodeName); static::assertXmlStringEqualsXmlString($target->saveXML(), $source->saveXML()); } @@ -45,7 +44,7 @@ public function test_it_can_recursively_replace_a_node_with_another_external_nod $result = replace_by_external_node($target->documentElement, $source->documentElement->firstChild); - static::assertInstanceOf(\DOM\Element::class, $result); + static::assertInstanceOf(Element::class, $result); static::assertSame('world', $result->nodeName); static::assertXmlStringEqualsXmlString($expected->saveXML(), $target->saveXML()); } diff --git a/tests/Xml/Dom/Manipulator/Node/ReplaceByExternalNodesTest.php b/tests/Xml/Dom/Manipulator/Node/ReplaceByExternalNodesTest.php index 3c1036e0..f14f6280 100644 --- a/tests/Xml/Dom/Manipulator/Node/ReplaceByExternalNodesTest.php +++ b/tests/Xml/Dom/Manipulator/Node/ReplaceByExternalNodesTest.php @@ -4,8 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Manipulator\Node; -use \DOM\XMLDocument; -use \DOM\Element; +use DOM\Element; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Exception\RuntimeException; @@ -22,7 +21,7 @@ public function test_it_can_replace_a_node(): void $results = replace_by_external_nodes($target->locateDocumentElement(), [$source->locateDocumentElement()]); $result = $results[0]; - static::assertInstanceOf(\DOM\Element::class, $result); + static::assertInstanceOf(Element::class, $result); static::assertSame('hello', $result->nodeName); static::assertXmlStringEqualsXmlString($target->toXmlString(), $source->toXmlString()); } @@ -35,9 +34,9 @@ public function test_it_can_replace_many_nodes(): void $results = replace_by_external_nodes($target->locateDocumentElement()->childNodes->item(0), $items); - static::assertInstanceOf(\DOM\Element::class, $results[0]); + static::assertInstanceOf(Element::class, $results[0]); static::assertSame('world', $results[0]->nodeName); - static::assertInstanceOf(\DOM\Element::class, $results[1]); + static::assertInstanceOf(Element::class, $results[1]); static::assertSame('toon', $results[1]->nodeName); static::assertXmlStringEqualsXmlString($target->toXmlString(), $source->toXmlString()); @@ -63,7 +62,7 @@ public function test_it_can_recursively_replace_a_node_with_another_external_nod $results = replace_by_external_nodes($target->locateDocumentElement(), [$source->locateDocumentElement()->firstChild]); $result = $results[0]; - static::assertInstanceOf(\DOM\Element::class, $result); + static::assertInstanceOf(Element::class, $result); static::assertSame('world', $result->nodeName); static::assertXmlStringEqualsXmlString($expected->toXmlString(), $target->toXmlString()); } diff --git a/tests/Xml/Dom/Manipulator/Xmlns/RenameTest.php b/tests/Xml/Dom/Manipulator/Xmlns/RenameTest.php index 07b35625..a3bb98c5 100644 --- a/tests/Xml/Dom/Manipulator/Xmlns/RenameTest.php +++ b/tests/Xml/Dom/Manipulator/Xmlns/RenameTest.php @@ -12,7 +12,6 @@ final class RenameTest extends TestCase { /** * @dataProvider provideXmls - * @param callable(): \Dom\Attr $targetLocator */ public function test_it_can_rename_namespaces(string $input, string $expected): void { diff --git a/tests/Xml/Dom/Mapper/XmlStringTest.php b/tests/Xml/Dom/Mapper/XmlStringTest.php index d1c6f82f..139e76c3 100644 --- a/tests/Xml/Dom/Mapper/XmlStringTest.php +++ b/tests/Xml/Dom/Mapper/XmlStringTest.php @@ -4,10 +4,8 @@ namespace VeeWee\Tests\Xml\Mapper; -use \DOM\Element; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; -use VeeWee\Xml\Exception\RuntimeException; use function VeeWee\Xml\Dom\Mapper\xml_string; final class XmlStringTest extends TestCase diff --git a/tests/Xml/Dom/Predicate/IsAttributeTest.php b/tests/Xml/Dom/Predicate/IsAttributeTest.php index 476646db..645bd18b 100644 --- a/tests/Xml/Dom/Predicate/IsAttributeTest.php +++ b/tests/Xml/Dom/Predicate/IsAttributeTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_attribute; @@ -15,7 +15,7 @@ final class IsAttributeTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_attributes(\DOM\Node $node, bool $expected): void + public function test_it_knows_attributes(Node $node, bool $expected): void { static::assertSame($expected, is_attribute($node)); } diff --git a/tests/Xml/Dom/Predicate/IsCDataTest.php b/tests/Xml/Dom/Predicate/IsCDataTest.php index d8f818af..72bdaa6e 100644 --- a/tests/Xml/Dom/Predicate/IsCDataTest.php +++ b/tests/Xml/Dom/Predicate/IsCDataTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_cdata; @@ -15,7 +15,7 @@ final class IsCDataTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_cdata(?\DOM\Node $node, bool $expected): void + public function test_it_knows_cdata(?Node $node, bool $expected): void { $actual = is_cdata($node); static::assertSame($expected, $actual); diff --git a/tests/Xml/Dom/Predicate/IsDefaultXmlnsAttributeTest.php b/tests/Xml/Dom/Predicate/IsDefaultXmlnsAttributeTest.php index d1ff5b84..c80b6e2b 100644 --- a/tests/Xml/Dom/Predicate/IsDefaultXmlnsAttributeTest.php +++ b/tests/Xml/Dom/Predicate/IsDefaultXmlnsAttributeTest.php @@ -4,8 +4,8 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\NameSpaceNode; -use \DOM\Node; +use DOM\NameSpaceNode; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_default_xmlns_attribute; @@ -16,7 +16,7 @@ final class IsDefaultXmlnsAttributeTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_default_xmlns_attribute(\DOM\Node|\DOM\NameSpaceNode $node, bool $expected): void + public function test_it_knows_default_xmlns_attribute(Node|NameSpaceNode $node, bool $expected): void { static::assertSame($expected, is_default_xmlns_attribute($node)); } diff --git a/tests/Xml/Dom/Predicate/IsDocumentElementTest.php b/tests/Xml/Dom/Predicate/IsDocumentElementTest.php index db73fbcd..e15a22cb 100644 --- a/tests/Xml/Dom/Predicate/IsDocumentElementTest.php +++ b/tests/Xml/Dom/Predicate/IsDocumentElementTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_document_element; @@ -15,7 +15,7 @@ final class IsDocumentElementTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_document_elements(\DOM\Node $node, bool $expected): void + public function test_it_knows_document_elements(Node $node, bool $expected): void { static::assertSame($expected, is_document_element($node)); } diff --git a/tests/Xml/Dom/Predicate/IsDocumentTest.php b/tests/Xml/Dom/Predicate/IsDocumentTest.php index da92faf1..3cb92b9d 100644 --- a/tests/Xml/Dom/Predicate/IsDocumentTest.php +++ b/tests/Xml/Dom/Predicate/IsDocumentTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_document; @@ -15,7 +15,7 @@ final class IsDocumentTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_documents(\DOM\Node $node, bool $expected): void + public function test_it_knows_documents(Node $node, bool $expected): void { static::assertSame($expected, is_document($node)); } diff --git a/tests/Xml/Dom/Predicate/IsElementTest.php b/tests/Xml/Dom/Predicate/IsElementTest.php index 85daf437..9660e26e 100644 --- a/tests/Xml/Dom/Predicate/IsElementTest.php +++ b/tests/Xml/Dom/Predicate/IsElementTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_element; @@ -15,7 +15,7 @@ final class IsElementTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_elements(\DOM\Node $node, bool $expected): void + public function test_it_knows_elements(Node $node, bool $expected): void { static::assertSame($expected, is_element($node)); } diff --git a/tests/Xml/Dom/Predicate/IsNonEmptyTextTest.php b/tests/Xml/Dom/Predicate/IsNonEmptyTextTest.php index ad69f442..d9d4bc2c 100644 --- a/tests/Xml/Dom/Predicate/IsNonEmptyTextTest.php +++ b/tests/Xml/Dom/Predicate/IsNonEmptyTextTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_non_empty_text; @@ -15,7 +15,7 @@ final class IsNonEmptyTextTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_text(\DOM\Node $node, bool $expected): void + public function test_it_knows_text(Node $node, bool $expected): void { static::assertSame($expected, is_non_empty_text($node)); } diff --git a/tests/Xml/Dom/Predicate/IsTextTest.php b/tests/Xml/Dom/Predicate/IsTextTest.php index 0e6d484d..4315daaf 100644 --- a/tests/Xml/Dom/Predicate/IsTextTest.php +++ b/tests/Xml/Dom/Predicate/IsTextTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_text; @@ -15,7 +15,7 @@ final class IsTextTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_text(\DOM\Node $node, bool $expected): void + public function test_it_knows_text(Node $node, bool $expected): void { static::assertSame($expected, is_text($node)); } diff --git a/tests/Xml/Dom/Predicate/IsWhitespaceTest.php b/tests/Xml/Dom/Predicate/IsWhitespaceTest.php index b6f22d51..ec4ab242 100644 --- a/tests/Xml/Dom/Predicate/IsWhitespaceTest.php +++ b/tests/Xml/Dom/Predicate/IsWhitespaceTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_whitespace; @@ -15,7 +15,7 @@ final class IsWhitespaceTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_whitespaces(\DOM\Node $node, bool $expected): void + public function test_it_knows_whitespaces(Node $node, bool $expected): void { static::assertSame($expected, is_whitespace($node)); } diff --git a/tests/Xml/Dom/Predicate/IsXmlnsAttributeTest.php b/tests/Xml/Dom/Predicate/IsXmlnsAttributeTest.php index bca3a82d..e799d2b7 100644 --- a/tests/Xml/Dom/Predicate/IsXmlnsAttributeTest.php +++ b/tests/Xml/Dom/Predicate/IsXmlnsAttributeTest.php @@ -4,8 +4,8 @@ namespace VeeWee\Tests\Xml\Dom\Predicate; -use \DOM\NameSpaceNode; -use \DOM\Node; +use DOM\NameSpaceNode; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use function VeeWee\Xml\Dom\Predicate\is_xmlns_attribute; @@ -16,7 +16,7 @@ final class IsXmlnsAttributeTest extends TestCase * * @dataProvider provideTestCases */ - public function test_it_knows_xmlns_attributes(\DOM\Node|\DOM\NameSpaceNode $node, bool $expected): void + public function test_it_knows_xmlns_attributes(Node|NameSpaceNode $node, bool $expected): void { static::assertSame($expected, is_xmlns_attribute($node)); } diff --git a/tests/Xml/Dom/Traverser/TraverserTest.php b/tests/Xml/Dom/Traverser/TraverserTest.php index 5367c968..12ac0e0c 100644 --- a/tests/Xml/Dom/Traverser/TraverserTest.php +++ b/tests/Xml/Dom/Traverser/TraverserTest.php @@ -4,7 +4,7 @@ namespace VeeWee\Tests\Xml\Dom\Traverser; -use \DOM\Node; +use DOM\Node; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Dom\Traverser\Action; @@ -37,7 +37,7 @@ public function test_it_can_traverse_single_node(): void $traverser = new Traverser( new class() extends AbstractVisitor { - public function onNodeLeave(\DOM\Node $node): Action + public function onNodeLeave(Node $node): Action { attribute('who', 'Jos')($node); return new Action\Noop(); @@ -55,7 +55,7 @@ public function test_it_can_traverse_attributes(): void $doc = Document::fromXmlString($actual = ''); $doc->traverse( new class() extends AbstractVisitor { - public function onNodeLeave(\DOM\Node $node): Action + public function onNodeLeave(Node $node): Action { if (!is_attribute($node)) { return new Action\Noop(); @@ -77,7 +77,7 @@ public function test_it_can_traverse_child_nodes(): void $doc = Document::fromXmlString($actual = ' '); $doc->traverse( new class() extends AbstractVisitor { - public function onNodeLeave(\DOM\Node $node): Action + public function onNodeLeave(Node $node): Action { if (is_non_empty_text($node)) { $node->textContent = 'Yo'; @@ -107,7 +107,7 @@ public function test_it_can_handle_node_enter_and_leave(): void $doc = Document::fromXmlString($actual = ''); $doc->traverse( new class() extends AbstractVisitor { - public function onNodeEnter(\DOM\Node $node): Action + public function onNodeEnter(Node $node): Action { if (!is_element($node)) { return new Action\Noop(); @@ -117,7 +117,7 @@ public function onNodeEnter(\DOM\Node $node): Action return new Action\Noop(); } - public function onNodeLeave(\DOM\Node $node): Action + public function onNodeLeave(Node $node): Action { if (!is_element($node)) { return new Action\Noop(); @@ -153,7 +153,7 @@ public function test_it_can_recursively_remove_empty_nodes(): void ); $transformedNode = $doc->traverse(new class extends AbstractVisitor { - public function onNodeLeave(\DOM\Node $node): Action + public function onNodeLeave(Node $node): Action { if (!is_element($node)) { return new Action\Noop(); diff --git a/tests/Xml/Dom/Validator/ValidatorChainTest.php b/tests/Xml/Dom/Validator/ValidatorChainTest.php index aa0994f5..02860e79 100644 --- a/tests/Xml/Dom/Validator/ValidatorChainTest.php +++ b/tests/Xml/Dom/Validator/ValidatorChainTest.php @@ -4,13 +4,12 @@ namespace VeeWee\Tests\Xml\Dom\Validator; -use \DOM\XMLDocument as DOMDocument; +use DOM\XMLDocument as DOMDocument; use PHPUnit\Framework\TestCase; use VeeWee\Tests\Xml\ErrorHandling\Issue\UseIssueTrait; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\ErrorHandling\Issue\IssueCollection; use VeeWee\Xml\ErrorHandling\Issue\Level; - use function VeeWee\Xml\Dom\Validator\validator_chain; final class ValidatorChainTest extends TestCase @@ -46,7 +45,7 @@ public static function provideErrorCases() yield 'oneFails' => [ 'validator' => validator_chain( static fn (DOMDocument $document) => new IssueCollection(), - fn (DOMDocument $document) => new IssueCollection( + static fn (DOMDocument $document) => new IssueCollection( self::createIssue(Level::fatal()) ), static fn (DOMDocument $document) => new IssueCollection(), @@ -56,10 +55,10 @@ public static function provideErrorCases() ]; yield 'allFails' => [ 'validator' => validator_chain( - fn (DOMDocument $document) => new IssueCollection( + static fn (DOMDocument $document) => new IssueCollection( self::createIssue(Level::fatal()) ), - fn (DOMDocument $document) => new IssueCollection( + static fn (DOMDocument $document) => new IssueCollection( self::createIssue(Level::fatal()), self::createIssue(Level::fatal()) ), diff --git a/tests/Xml/Dom/Xpath/Locator/QuerySingleTest.php b/tests/Xml/Dom/Xpath/Locator/QuerySingleTest.php index 2dbe8cb1..07b62558 100644 --- a/tests/Xml/Dom/Xpath/Locator/QuerySingleTest.php +++ b/tests/Xml/Dom/Xpath/Locator/QuerySingleTest.php @@ -2,7 +2,7 @@ namespace VeeWee\Tests\Xml\Dom\Xpath\Locator; -use \DOM\Element; +use DOM\Element; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Exception\RuntimeException; @@ -36,7 +36,7 @@ public function test_it_can_find_single_xpath_element(): void $xpath = $this->provideXml()->xpath(); $actual = $xpath->querySingle('//item'); - static::assertInstanceOf(\DOM\Element::class, $actual); + static::assertInstanceOf(Element::class, $actual); } @@ -48,7 +48,7 @@ public function test_it_can_find_single_xpath_element_with_node_context(): void $xpath = $doc->xpath(); $actual = $xpath->querySingle('./world', $hello); - static::assertInstanceOf(\DOM\Element::class, $actual); + static::assertInstanceOf(Element::class, $actual); } private function provideXml(): Document diff --git a/tests/Xml/Dom/XpathTest.php b/tests/Xml/Dom/XpathTest.php index bedb23ad..fd586886 100644 --- a/tests/Xml/Dom/XpathTest.php +++ b/tests/Xml/Dom/XpathTest.php @@ -4,7 +4,6 @@ namespace VeeWee\Tests\Xml\Dom; -use DOMXPath; use PHPUnit\Framework\TestCase; use VeeWee\Xml\Dom\Document; use VeeWee\Xml\Dom\Xpath; diff --git a/tests/Xml/ErrorHandling/DetectIssuesTest.php b/tests/Xml/ErrorHandling/DetectIssuesTest.php index 3a79f7a9..da35bd84 100644 --- a/tests/Xml/ErrorHandling/DetectIssuesTest.php +++ b/tests/Xml/ErrorHandling/DetectIssuesTest.php @@ -7,7 +7,6 @@ use Exception; use PHPUnit\Framework\TestCase; use VeeWee\Xml\ErrorHandling; - use function libxml_use_internal_errors; use function simplexml_load_string; diff --git a/tests/Xml/ErrorHandling/DisallowIssuesTest.php b/tests/Xml/ErrorHandling/DisallowIssuesTest.php index 73401dbf..a155eb65 100644 --- a/tests/Xml/ErrorHandling/DisallowIssuesTest.php +++ b/tests/Xml/ErrorHandling/DisallowIssuesTest.php @@ -8,7 +8,6 @@ use PHPUnit\Framework\TestCase; use RuntimeException; use VeeWee\Xml\ErrorHandling; - use function libxml_use_internal_errors; use function simplexml_load_string; diff --git a/tests/Xml/ErrorHandling/IssueCollectionFromXmlErrorsTest.php b/tests/Xml/ErrorHandling/IssueCollectionFromXmlErrorsTest.php index f36d8ac9..5deaef0c 100644 --- a/tests/Xml/ErrorHandling/IssueCollectionFromXmlErrorsTest.php +++ b/tests/Xml/ErrorHandling/IssueCollectionFromXmlErrorsTest.php @@ -7,7 +7,6 @@ use LibXMLError; use PHPUnit\Framework\TestCase; use VeeWee\Xml\ErrorHandling\Issue\Level; - use function VeeWee\Xml\ErrorHandling\issue_collection_from_xml_errors; final class IssueCollectionFromXmlErrorsTest extends TestCase diff --git a/tests/Xml/ErrorHandling/IssueFromXmlErrorTest.php b/tests/Xml/ErrorHandling/IssueFromXmlErrorTest.php index ad3fff34..5988fdb6 100644 --- a/tests/Xml/ErrorHandling/IssueFromXmlErrorTest.php +++ b/tests/Xml/ErrorHandling/IssueFromXmlErrorTest.php @@ -7,7 +7,6 @@ use LibXMLError; use PHPUnit\Framework\TestCase; use VeeWee\Xml\ErrorHandling\Issue\Level; - use function VeeWee\Xml\ErrorHandling\issue_from_xml_error; final class IssueFromXmlErrorTest extends TestCase diff --git a/tests/Xml/ErrorHandling/IssueLevelFromXmlErrorTest.php b/tests/Xml/ErrorHandling/IssueLevelFromXmlErrorTest.php index 8a8658a7..6e9b956d 100644 --- a/tests/Xml/ErrorHandling/IssueLevelFromXmlErrorTest.php +++ b/tests/Xml/ErrorHandling/IssueLevelFromXmlErrorTest.php @@ -7,7 +7,6 @@ use LibXMLError; use PHPUnit\Framework\TestCase; use VeeWee\Xml\ErrorHandling\Issue\Level; - use function VeeWee\Xml\ErrorHandling\issue_level_from_xml_error; final class IssueLevelFromXmlErrorTest extends TestCase diff --git a/tests/Xml/Writer/Builder/PrefixedAttributeTest.php b/tests/Xml/Writer/Builder/PrefixedAttributeTest.php index 7957b3b7..f684a6ae 100644 --- a/tests/Xml/Writer/Builder/PrefixedAttributeTest.php +++ b/tests/Xml/Writer/Builder/PrefixedAttributeTest.php @@ -9,8 +9,8 @@ use VeeWee\Xml\Exception\RuntimeException; use VeeWee\Xml\Writer\Writer; use XMLWriter; -use function VeeWee\Xml\Writer\Builder\element; use function VeeWee\Xml\Writer\Builder\children; +use function VeeWee\Xml\Writer\Builder\element; use function VeeWee\Xml\Writer\Builder\namespace_attribute; use function VeeWee\Xml\Writer\Builder\prefixed_attribute; diff --git a/tools/full-coverage-check.php b/tools/full-coverage-check.php index 2c3066bd..26864671 100755 --- a/tools/full-coverage-check.php +++ b/tools/full-coverage-check.php @@ -1,5 +1,5 @@ #!/usr/bin/env php -