Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/analyzers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.3', '8.4', '8.5']
php-versions: ['8.4', '8.5']
composer-options: ['--ignore-platform-req=php+']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.3', '8.4', '8.5']
php-versions: ['8.4', '8.5']
composer-options: ['--ignore-platform-req=php+']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.3', '8.4', '8.5']
php-versions: ['8.4', '8.5']
composer-options: ['--ignore-platform-req=php+']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
}
],
"require": {
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
"php": "~8.4.0 || ~8.5.0",
"ext-dom": "*",
"veewee/xml": "^3.4"
"php-standard-library/dict": "^6.1",
"php-standard-library/foundation": "^6.1",
"veewee/xml": "^4.8"
},
"require-dev": {
"phpunit/phpunit": "~12.3",
Expand Down
5 changes: 4 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
errorLevel="1"
resolveFromConfigFile="true"
strictBinaryOperands="true"
phpVersion="8.0"
phpVersion="8.4"
allowStringToStandInForClass="true"
rememberPropertyAssignmentsAfterCall="false"
skipChecksOnUnresolvableIncludes="false"
Expand All @@ -22,6 +22,9 @@
<directory name="tests" />
</ignoreFiles>
</projectFiles>
<stubs>
<file name="vendor/veewee/xml/stubs/DOM.phpstub" />
</stubs>
<ignoreExceptions>
<class name="InvalidArgumentException" />
</ignoreExceptions>
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/Header/Actor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Soap\Xml\Builder\Header;

use DOMNode;
use Dom\Node;
use VeeWee\Xml\Dom\Builder\Builder;
use VeeWee\Xml\Exception\RuntimeException;
use function VeeWee\Xml\Dom\Builder\namespaced_attribute;
Expand All @@ -26,7 +26,7 @@ public static function next(): self
/**
* @psalm-suppress MissingThrowsDocblock
*/
public function __invoke(DOMNode $node): DOMNode
public function __invoke(Node $node): Node
{
$document = detect_document($node);
$namespace = root_namespace_uri()($document) ?? '';
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/Header/MustUnderstand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Soap\Xml\Builder\Header;

use DOMNode;
use Dom\Node;
use VeeWee\Xml\Dom\Builder\Builder;
use VeeWee\Xml\Exception\RuntimeException;
use function VeeWee\Xml\Dom\Builder\namespaced_attribute;
Expand All @@ -16,7 +16,7 @@ final class MustUnderstand implements Builder
/**
* @psalm-suppress MissingThrowsDocblock
*/
public function __invoke(DOMNode $node): DOMNode
public function __invoke(Node $node): Node
{
$document = detect_document($node);
$namespace = root_namespace_uri()($document) ?? '';
Expand Down
10 changes: 5 additions & 5 deletions src/Builder/SoapHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

namespace Soap\Xml\Builder;

use DOMElement;
use DOMNode;
use Dom\Element;
use Dom\Node;
use VeeWee\Xml\Dom\Builder\Builder;
use function VeeWee\Xml\Dom\Builder\children;
use function VeeWee\Xml\Dom\Builder\namespaced_element;

final class SoapHeader implements Builder
{
/**
* @var list<callable(DOMNode): DOMElement>
* @var list<callable(Node): Element>
*/
private array $configurators;

/**
* @no-named-arguments
* @param list<callable(DOMNode): DOMElement> $configurators
* @param list<callable(Node): Element> $configurators
*/
public function __construct(
private string $namespace,
Expand All @@ -31,7 +31,7 @@ public function __construct(
/**
* @psalm-suppress MissingThrowsDocblock
*/
public function __invoke(DOMNode $node): DOMNode
public function __invoke(Node $node): Node
{
return children(
namespaced_element(
Expand Down
10 changes: 5 additions & 5 deletions src/Builder/SoapHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Soap\Xml\Builder;

use DOMElement;
use DOMNode;
use Dom\Element;
use Dom\Node;
use VeeWee\Xml\Dom\Builder\Builder;
use function VeeWee\Xml\Dom\Builder\namespaced_element;
use function VeeWee\Xml\Dom\Locator\Node\detect_document;
Expand All @@ -12,13 +12,13 @@
final class SoapHeaders implements Builder
{
/**
* @var list<callable(DOMNode): DOMElement>
* @var list<callable(Node): Element>
*/
private array $configurators;

/**
* @no-named-arguments
* @param list<callable(DOMNode): DOMElement> $configurators
* @param list<callable(Node): Element> $configurators
*/
public function __construct(callable ... $configurators)
{
Expand All @@ -28,7 +28,7 @@ public function __construct(callable ... $configurators)
/**
* @psalm-suppress MissingThrowsDocblock
*/
public function __invoke(DOMNode $node): DOMNode
public function __invoke(Node $node): Node
{
$document = detect_document($node);

Expand Down
8 changes: 2 additions & 6 deletions src/Locator/BodyNamespaceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@

namespace Soap\Xml\Locator;

use DOMDocument;
use Dom\XMLDocument;
use VeeWee\Xml\Exception\RuntimeException;

final class BodyNamespaceLocator
{
/**
* @psalm-suppress UndefinedPropertyFetch - psalm gets lost
* @psalm-suppress MixedReturnStatement - psalm gets lost
* @psalm-suppress MixedPropertyFetch - psalm gets lost
* @psalm-suppress MixedInferredReturnType - psalm gets lost
* @throws RuntimeException
*/
public function __invoke(DOMDocument $document): ?string
public function __invoke(XMLDocument $document): ?string
{
return (new SoapBodyLocator())($document)?->firstElementChild?->namespaceURI;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Locator/SoapBodyLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Soap\Xml\Locator;

use DOMDocument;
use DOMElement;
use Dom\Element;
use Dom\XMLDocument;
use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Exception\RuntimeException;
use function VeeWee\Xml\Dom\Locator\root_namespace_uri;
Expand All @@ -16,11 +16,11 @@ final class SoapBodyLocator
/**
* @throws RuntimeException
*/
public function __invoke(DOMDocument $document): ?DOMElement
public function __invoke(XMLDocument $document): ?Element
{
$soapNs = root_namespace_uri()($document) ?? '';
$xpath = Document::fromUnsafeDocument($document)->xpath(namespaces(['soap' => $soapNs]));

return $xpath->query('//soap:Envelope/soap:Body')->expectAllOfType(DOMElement::class)->first();
return $xpath->query('//soap:Envelope/soap:Body')->expectAllOfType(Element::class)->first();
}
}
9 changes: 5 additions & 4 deletions src/Locator/SoapEnvelopeLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

namespace Soap\Xml\Locator;

use DOMDocument;
use DOMElement;
use Dom\Element;
use Dom\XMLDocument;
use function VeeWee\Xml\Dom\Locator\document_element;

final class SoapEnvelopeLocator
{
public function __invoke(DOMDocument $document): DOMElement
public function __invoke(XMLDocument $document): Element
{
return $document->documentElement;
return document_element()($document);
}
}
8 changes: 4 additions & 4 deletions src/Locator/SoapHeaderLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Soap\Xml\Locator;

use DOMDocument;
use DOMElement;
use Dom\Element;
use Dom\XMLDocument;
use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Exception\RuntimeException;
use function VeeWee\Xml\Dom\Locator\root_namespace_uri;
Expand All @@ -16,11 +16,11 @@ final class SoapHeaderLocator
/**
* @throws RuntimeException
*/
public function __invoke(DOMDocument $document): ?DOMElement
public function __invoke(XMLDocument $document): ?Element
{
$soapNs = root_namespace_uri()($document) ?? '';
$xpath = Document::fromUnsafeDocument($document)->xpath(namespaces(['soap' => $soapNs]));

return $xpath->query('//soap:Envelope/soap:Header')->expectAllOfType(DOMElement::class)->first();
return $xpath->query('//soap:Envelope/soap:Header')->expectAllOfType(Element::class)->first();
}
}
10 changes: 5 additions & 5 deletions src/Manipulator/PrependSoapHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

namespace Soap\Xml\Manipulator;

use DOMDocument;
use DOMElement;
use Dom\Element;
use Dom\XMLDocument;
use Soap\Xml\Locator\SoapEnvelopeLocator;
use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Exception\RuntimeException;

final class PrependSoapHeaders
{
/**
* @var list<DOMElement>
* @var list<Element>
*/
private array $soapHeaders;

/**
* @no-named-arguments
*/
public function __construct(DOMElement ... $soapHeaders)
public function __construct(Element ... $soapHeaders)
{
$this->soapHeaders = $soapHeaders;
}
Expand All @@ -30,7 +30,7 @@ public function __construct(DOMElement ... $soapHeaders)
* @psalm-suppress LessSpecificReturnStatement
* @psalm-suppress MoreSpecificReturnType
*/
public function __invoke(DOMDocument $document): DOMElement
public function __invoke(XMLDocument $document): Element
{
$doc = Document::fromUnsafeDocument($document);
$envelope = $doc->locate(new SoapEnvelopeLocator());
Expand Down
4 changes: 2 additions & 2 deletions src/Xpath/EnvelopePreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Soap\Xml\Xpath;

use DOMXPath;
use Dom\XPath;
use Soap\Xml\Locator\BodyNamespaceLocator;
use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Dom\Xpath\Configurator\Configurator;
Expand All @@ -24,7 +24,7 @@ public function __construct(Document $document)
/**
* @throws RuntimeException
*/
public function __invoke(DOMXPath $xpath): DOMXPath
public function __invoke(XPath $xpath): XPath
{
return namespaces(array_filter([
'soap' => $this->document->locate(root_namespace_uri()),
Expand Down
6 changes: 3 additions & 3 deletions src/Xpath/WsdlPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Soap\Xml\Xpath;

use DOMXPath;
use Dom\XPath;
use Soap\Xml\Xmlns;
use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Dom\Xpath\Configurator\Configurator;
Expand All @@ -22,7 +22,7 @@ public function __construct(Document $document)
$this->document = $document;
}

public function __invoke(DOMXPath $xpath): DOMXPath
public function __invoke(XPath $xpath): XPath
{
$tns = $this->document->map(document_element())->getAttribute('targetNamespace');

Expand All @@ -34,7 +34,7 @@ public function __invoke(DOMXPath $xpath): DOMXPath
'soap12' => Xmlns::soap12()->value(),
'wsdl' => Xmlns::wsdl()->value(),
],
$tns ? ['tns' => $tns] : []
$tns !== null ? ['tns' => $tns] : []
)
))($xpath);
}
Expand Down
9 changes: 2 additions & 7 deletions tests/Unit/Builder/SoapHeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use function VeeWee\Xml\Dom\Builder\children;
use function VeeWee\Xml\Dom\Builder\namespaced_element;
use function VeeWee\Xml\Dom\Builder\value;
use function VeeWee\Xml\Dom\Configurator\comparable;

final class SoapHeaderTest extends TestCase
{
Expand Down Expand Up @@ -47,13 +46,9 @@ public function test_it_can_create_a_header_element(): void
<Acting xmlns="https://foo.bar" soap:actor="http://schemas.xmlsoap.org/soap/actor/next" />
<Understanding xmlns="https://foo.bar" soap:mustUnderstand="1" />
</soap:Header>
</soap:Envelope>
</soap:Envelope>
EOXML;


static::assertXmlStringEqualsXmlString(
Document::fromXmlString($expected, comparable())->toXmlString(),
Document::fromUnsafeDocument($doc->toUnsafeDocument(), comparable())->toXmlString()
);
static::assertXmlStringEqualsXmlString($expected, $doc->toXmlString());
}
}