Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Sep 18, 2024
1 parent 672e71a commit 8a29bbf
Show file tree
Hide file tree
Showing 191 changed files with 579 additions and 592 deletions.
2 changes: 1 addition & 1 deletion build/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env php
<?php
<?php declare(strict_types=1);

use Psl\File\WriteMode;
use Symfony\Component\Finder\Finder;
Expand Down
9 changes: 5 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,16 @@

namespace VeeWee\Xml\Dom\Assert;

use \Dom\Attr;
use Dom\Attr;
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_attribute(mixed $node): \Dom\Attr
function assert_attribute(mixed $node): Attr
{
return instance_of(\Dom\Attr::class)->assert($node);
return instance_of(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 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);
}
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 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);
}
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 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);
}
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 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);
}
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(Node $node): 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(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;
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(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
);
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(CDATASection): CDATASection> $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(
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 Node
*
* @param list<callable(T): \Dom\Node> $builders
* @param list<callable(T): Node> $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));
}
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(Element): Element> $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(
Expand Down
5 changes: 3 additions & 2 deletions src/Xml/Dom/Builder/escaped_value.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
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(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);
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(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
);
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(Element): Element> $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(
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\Node;
use Dom\XMLDocument;
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(XMLDocument): (list<Node>|Node)> $builders
*
* @return Closure(\Dom\XMLDocument): list<\Dom\Node>
* @return Closure(XMLDocument): list<Node>
*/
function nodes(callable ... $builders): Closure
{
return
/**
* @return list<\Dom\Node>
* @return list<Node>
*/
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<Node> $builds
* @param callable(XMLDocument): (Node|list<Node>) $builder
* @return list<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(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;
Expand Down
Loading

0 comments on commit 8a29bbf

Please sign in to comment.