Skip to content

Commit

Permalink
Make compatible with alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Sep 16, 2024
1 parent d46ac5a commit cc7cde1
Show file tree
Hide file tree
Showing 131 changed files with 525 additions and 477 deletions.
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace VeeWee\Xml\Dom\Assert;

use \DOM\Attr;
use \Dom\Attr;
use Psl\Type\Exception\AssertException;
use function Psl\Type\instance_of;

/**
* @psalm-assert \DOM\Element $node
* @psalm-assert \Dom\Element $node
* @throws AssertException
*/
function assert_attribute(mixed $node): \DOM\Attr
function assert_attribute(mixed $node): \Dom\Attr
{
return instance_of(\DOM\Attr::class)->assert($node);
return instance_of(\Dom\Attr::class)->assert($node);
}
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_cdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 \Dom\CDATASection $node
* @throws AssertException
*/
function assert_cdata(mixed $node): \DOM\CDATASection
function assert_cdata(mixed $node): \Dom\CDATASection
{
return instance_of(\DOM\CDATASection::class)->assert($node);
return instance_of(\Dom\CDATASection::class)->assert($node);
}
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_document.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 \Dom\XMLDocument $node
* @throws AssertException
*/
function assert_document(mixed $node): \DOM\XMLDocument
function assert_document(mixed $node): \Dom\XMLDocument
{
return instance_of(\DOM\XMLDocument::class)->assert($node);
return instance_of(\Dom\XMLDocument::class)->assert($node);
}
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_dom_node_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 \Dom\NodeList $node
* @throws AssertException
*/
function assert_dom_node_list(mixed $node): \DOM\NodeList
function assert_dom_node_list(mixed $node): \Dom\NodeList
{
return instance_of(\DOM\NodeList::class)->assert($node);
return instance_of(\Dom\NodeList::class)->assert($node);
}
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_element.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 \Dom\Element $node
* @throws AssertException
*/
function assert_element(mixed $node): \DOM\Element
function assert_element(mixed $node): \Dom\Element
{
return instance_of(\DOM\Element::class)->assert($node);
return instance_of(\Dom\Element::class)->assert($node);
}
4 changes: 2 additions & 2 deletions src/Xml/Dom/Builder/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(\Dom\Node $node): \Dom\Node;
}
6 changes: 3 additions & 3 deletions src/Xml/Dom/Builder/attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(\Dom\Element): \Dom\Element
*/
function attribute(string $name, string $value): Closure
{
return static function (\DOM\Element $node) use ($name, $value): \DOM\Element {
return static function (\Dom\Element $node) use ($name, $value): \Dom\Element {
$node->setAttribute($name, $value);

return $node;
Expand Down
8 changes: 4 additions & 4 deletions src/Xml/Dom/Builder/attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> $attributes
* @return Closure(\DOM\Element): \DOM\Element
* @return Closure(\Dom\Element): \Dom\Element
*/
function attributes(array $attributes): Closure
{
return static function (\DOM\Element $node) use ($attributes): \DOM\Element {
return static function (\Dom\Element $node) use ($attributes): \Dom\Element {
return reduce_with_keys(
$attributes,
static fn (\DOM\Element $node, string $name, string $value)
static fn (\Dom\Element $node, string $name, string $value)
=> attribute($name, $value)($node),
$node
);
Expand Down
10 changes: 5 additions & 5 deletions src/Xml/Dom/Builder/cdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<callable(\DOM\CDATASection): \DOM\CDATASection> $configurators
* @param list<callable(\Dom\CDATASection): \Dom\CDATASection> $configurators
*
* @return Closure(\DOM\Node): \DOM\CDATASection
* @return Closure(\Dom\Node): \Dom\CDATASection
*/
function cdata(string $data, ...$configurators): Closure
{
return static function (\DOM\Node $node) use ($data, $configurators): \DOM\CDATASection {
return static function (\Dom\Node $node) use ($data, $configurators): \Dom\CDATASection {
$document = detect_document($node);

return assert_cdata(
Expand Down
8 changes: 4 additions & 4 deletions src/Xml/Dom/Builder/children.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 \Dom\Node
*
* @param list<callable(T): \DOM\Node> $builders
* @param list<callable(T): \Dom\Node> $builders
*
* @return Closure(T): T
*/
function children(callable ...$builders): Closure
{
return static function (\DOM\Node $node) use ($builders): \DOM\Node {
return static function (\Dom\Node $node) use ($builders): \Dom\Node {
foreach ($builders as $builder) {
$node->appendChild($builder($node));
}
Expand Down
10 changes: 5 additions & 5 deletions src/Xml/Dom/Builder/element.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<callable(\DOM\Element): \DOM\Element> $configurators
* @param list<callable(\Dom\Element): \Dom\Element> $configurators
*
* @return Closure(\DOM\Node): \DOM\Element
* @return Closure(\Dom\Node): \Dom\Element
*/
function element(string $name, callable ...$configurators): Closure
{
return static function (\DOM\Node $node) use ($name, $configurators): \DOM\Element {
return static function (\Dom\Node $node) use ($name, $configurators): \Dom\Element {
$document = detect_document($node);

return assert_element(
Expand Down
4 changes: 2 additions & 2 deletions src/Xml/Dom/Builder/escaped_value.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
use Closure;

/**
* @return Closure(\DOM\Element): \DOM\Element
* @return Closure(\Dom\Element): \Dom\Element
*/
function escaped_value(string $value): Closure
{
return static function (\DOM\Element $node) use ($value): \DOM\Element {
return static function (\Dom\Element $node) use ($value): \Dom\Element {
return value(htmlspecialchars($value, ENT_XML1|ENT_QUOTES))($node);
};
}
6 changes: 3 additions & 3 deletions src/Xml/Dom/Builder/namespaced_attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(\Dom\Element): \Dom\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 (\Dom\Element $node) use ($namespace, $qualifiedName, $value): \Dom\Element {
assert_strict_prefixed_name($qualifiedName);

$node->setAttributeNS($namespace, $qualifiedName, $value);
Expand Down
8 changes: 4 additions & 4 deletions src/Xml/Dom/Builder/namespaced_attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> $attributes
* @return Closure(\DOM\Element): \DOM\Element
* @return Closure(\Dom\Element): \Dom\Element
*/
function namespaced_attributes(string $namespace, array $attributes): Closure
{
return static function (\DOM\Element $node) use ($namespace, $attributes): \DOM\Element {
return static function (\Dom\Element $node) use ($namespace, $attributes): \Dom\Element {
return reduce_with_keys(
$attributes,
static fn (\DOM\Element $node, string $name, string $value)
static fn (\Dom\Element $node, string $name, string $value)
=> namespaced_attribute($namespace, $name, $value)($node),
$node
);
Expand Down
10 changes: 5 additions & 5 deletions src/Xml/Dom/Builder/namespaced_element.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<callable(\DOM\Element): \DOM\Element> $configurators
* @param list<callable(\Dom\Element): \Dom\Element> $configurators
*
* @return Closure(\DOM\Node): \DOM\Element
* @return Closure(\Dom\Node): \Dom\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 (\Dom\Node $node) use ($namespace, $qualifiedName, $configurators): \Dom\Element {
$document = detect_document($node);

return assert_element(
Expand Down
18 changes: 9 additions & 9 deletions src/Xml/Dom/Builder/nodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@
namespace VeeWee\Xml\Dom\Builder;

use Closure;
use \DOM\XMLDocument;
use \DOM\Node;
use \Dom\XMLDocument;
use \Dom\Node;
use function is_array;
use function Psl\Iter\reduce;
use function VeeWee\Xml\Dom\Locator\Node\detect_document;

/**
* @param list<callable(\DOM\XMLDocument): (list<\DOM\Node>|\DOM\Node)> $builders
* @param list<callable(\Dom\XMLDocument): (list<\Dom\Node>|\Dom\Node)> $builders
*
* @return Closure(\DOM\XMLDocument): list<\DOM\Node>
* @return Closure(\Dom\XMLDocument): list<\Dom\Node>
*/
function nodes(callable ... $builders): Closure
{
return
/**
* @return list<\DOM\Node>
* @return list<\Dom\Node>
*/
static fn (\DOM\Node $node): array
static fn (\Dom\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<\Dom\Node> $builds
* @param callable(\Dom\XMLDocument): (\Dom\Node|list<\Dom\Node>) $builder
* @return list<\Dom\Node>
*/
static function (array $builds, callable $builder) use ($node): array {
$result = $builder(detect_document($node));
Expand Down
6 changes: 3 additions & 3 deletions src/Xml/Dom/Builder/value.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(\Dom\Element): \Dom\Element
*/
function value(string $value): Closure
{
return static function (\DOM\Element $node) use ($value): \DOM\Element {
return static function (\Dom\Element $node) use ($value): \Dom\Element {
$node->substitutedNodeValue = $value;

return $node;
Expand Down
6 changes: 3 additions & 3 deletions src/Xml/Dom/Builder/xmlns_attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(\Dom\Element): \Dom\Element
*/
function xmlns_attribute(string $prefix, string $namespaceURI): Closure
{
return static function (\DOM\Element $node) use ($prefix, $namespaceURI): \DOM\Element {
return static function (\Dom\Element $node) use ($prefix, $namespaceURI): \Dom\Element {
$prefixed = 'xmlns:'.$prefix;
assert_strict_prefixed_name($prefixed);

Expand Down
Loading

0 comments on commit cc7cde1

Please sign in to comment.