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+' ]
dependency-preference: ['current', 'lowest', 'stable']
fail-fast: false
Expand Down
23 changes: 17 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,25 @@
}
},
"require": {
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
"php": "~8.4.0 || ~8.5.0",
"ext-dom": "*",
"goetas-webservices/xsd-reader": "^0.4.11",
"php-soap/engine": "^2.19",
"php-soap/wsdl": "^1.18",
"php-soap/xml": "^1.9.0",
"veewee/xml": "^3.6",
"php-standard-library/php-standard-library": "^3.0 || ^4.0 || ^5.0 || ^6.0",
"php-soap/engine": "^2.20",
"php-soap/wsdl": "^1.19",
"php-soap/xml": "^1.10",
"veewee/xml": "^4.10",
"php-standard-library/dict": "^6.1",
"php-standard-library/foundation": "^6.1",
"php-standard-library/fun": "^6.1",
"php-standard-library/iter": "^6.1",
"php-standard-library/json": "^6.1",
"php-standard-library/math": "^6.1",
"php-standard-library/option": "^6.1",
"php-standard-library/regex": "^6.1",
"php-standard-library/result": "^6.1",
"php-standard-library/str": "^6.1",
"php-standard-library/type": "^6.1",
"php-standard-library/vec": "^6.1",
"symfony/console": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"webmozart/assert": "^1.11",
"php-tui/php-tui": "^0.2.1"
Expand Down
4 changes: 4 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
resolveFromConfigFile="true"
findUnusedCode="false"
ensureOverrideAttribute="false"
phpVersion="8.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<stubs>
<file name="vendor/veewee/xml/stubs/DOM.phpstub" />
</stubs>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
Expand Down
4 changes: 2 additions & 2 deletions src/Parser/Definitions/AddressBindingTypeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

namespace Soap\WsdlReader\Parser\Definitions;

use DOMElement;
use Dom\Element;
use Soap\WsdlReader\Model\Definitions\AddressBindingType;
use VeeWee\Xml\Dom\Document;

final class AddressBindingTypeParser
{
public function __invoke(Document $wsdl, DOMElement $namespacedElement): AddressBindingType
public function __invoke(Document $wsdl, Element $namespacedElement): AddressBindingType
{
return AddressBindingType::from($namespacedElement->namespaceURI ?? '');
}
Expand Down
14 changes: 7 additions & 7 deletions src/Parser/Definitions/BindingOperationMessageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Soap\WsdlReader\Parser\Definitions;

use DOMElement;
use Dom\Element;
use Psl\Type;
use Soap\WsdlReader\Model\Definitions\BindingOperationMessage;
use Soap\WsdlReader\Model\Definitions\BindingOperationMessages;
Expand All @@ -16,7 +16,7 @@

final class BindingOperationMessageParser
{
public function __invoke(Document $wsdl, DOMElement $message, StrategyInterface $strategy): BindingOperationMessage
public function __invoke(Document $wsdl, Element $message, StrategyInterface $strategy): BindingOperationMessage
{
$xpath = $wsdl->xpath(new WsdlPreset($wsdl));

Expand All @@ -28,29 +28,29 @@ public function __invoke(Document $wsdl, DOMElement $message, StrategyInterface

public static function tryParseFromOptionalSingleOperationMessage(
Document $wsdl,
DOMElement $operation,
Element $operation,
string $message,
StrategyInterface $strategy
): ?BindingOperationMessage {
$xpath = $wsdl->xpath(new WsdlPreset($wsdl));

return wrap(
static fn (): DOMElement => assert_element($xpath->querySingle('./wsdl:'.$message, $operation))
static fn (): Element => assert_element($xpath->querySingle('./wsdl:'.$message, $operation))
)->proceed(
static fn (DOMElement $messageElement): BindingOperationMessage =>
static fn (Element $messageElement): BindingOperationMessage =>
(new self())($wsdl, $messageElement, $strategy),
static fn () => null
);
}

/**
* @param NodeList<DOMElement> $list
* @param NodeList<Element> $list
*/
public static function tryParseList(Document $wsdl, NodeList $list, StrategyInterface $strategy): BindingOperationMessages
{
return new BindingOperationMessages(
...$list->map(
static fn (DOMElement $message): BindingOperationMessage => (new self)($wsdl, $message, $strategy)
static fn (Element $message): BindingOperationMessage => (new self)($wsdl, $message, $strategy)
)
);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Parser/Definitions/BindingOperationParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@

namespace Soap\WsdlReader\Parser\Definitions;

use DOMElement;
use Dom\Element;
use Soap\WsdlReader\Model\Definitions\BindingOperation;
use Soap\WsdlReader\Parser\Strategy\StrategyInterface;
use Soap\Xml\Xpath\WsdlPreset;
use VeeWee\Xml\Dom\Document;
use function VeeWee\Xml\Dom\Locator\Element\locate_by_tag_name;
use function VeeWee\Xml\Dom\Locator\Element\locate_by_namespaced_tag_name;

final class BindingOperationParser
{
public function __invoke(Document $wsdl, DOMElement $operation, StrategyInterface $strategy): BindingOperation
public function __invoke(Document $wsdl, Element $operation, StrategyInterface $strategy): BindingOperation
{
$xpath = $wsdl->xpath(new WsdlPreset($wsdl));
$soapOperation = locate_by_tag_name($operation, 'operation')->expectFirst('Unable to locate the operation implementation in a WSDL operation element!');
$soapOperation = locate_by_namespaced_tag_name($operation, '*', 'operation')->expectFirst('Unable to locate the operation implementation in a WSDL operation element!');

return new BindingOperation(
name: $operation->getAttribute('name'),
name: $operation->getAttribute('name') ?? '',
implementation: $strategy->parseOperationImplementation($wsdl, $soapOperation),
input: BindingOperationMessageParser::tryParseFromOptionalSingleOperationMessage($wsdl, $operation, 'input', $strategy),
output: BindingOperationMessageParser::tryParseFromOptionalSingleOperationMessage($wsdl, $operation, 'output', $strategy),
fault: BindingOperationMessageParser::tryParseList(
$wsdl,
$xpath->query('./wsdl:fault', $operation)->expectAllOfType(DOMElement::class),
$xpath->query('./wsdl:fault', $operation)->expectAllOfType(Element::class),
$strategy
),
);
Expand Down
20 changes: 10 additions & 10 deletions src/Parser/Definitions/BindingParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@

namespace Soap\WsdlReader\Parser\Definitions;

use DOMElement;
use Dom\Element;
use Soap\WsdlReader\Model\Definitions\Binding;
use Soap\WsdlReader\Model\Definitions\BindingOperations;
use Soap\WsdlReader\Model\Definitions\Bindings;
use Soap\WsdlReader\Model\Definitions\QNamed;
use Soap\WsdlReader\Parser\Strategy\StrategySelector;
use Soap\Xml\Xpath\WsdlPreset;
use VeeWee\Xml\Dom\Document;
use function VeeWee\Xml\Dom\Locator\Element\locate_by_tag_name;
use function VeeWee\Xml\Dom\Locator\Element\locate_by_namespaced_tag_name;

final class BindingParser
{
public function __invoke(Document $wsdl, DOMElement $binding): Binding
public function __invoke(Document $wsdl, Element $binding): Binding
{
$xpath = $wsdl->xpath(new WsdlPreset($wsdl));

$soapBinding = locate_by_tag_name($binding, 'binding')->expectFirst('Unable to locate the SOAP binding in a WSDL binding element!');
$soapBinding = locate_by_namespaced_tag_name($binding, '*', 'binding')->expectFirst('Unable to locate the SOAP binding in a WSDL binding element!');
$addressBindingType = (new AddressBindingTypeParser())($wsdl, $soapBinding);
$strategy = (new StrategySelector())($addressBindingType);

return new Binding(
name: $binding->getAttribute('name'),
type: QNamed::parse($binding->getAttribute('type')),
name: $binding->getAttribute('name') ?? '',
type: QNamed::parse($binding->getAttribute('type') ?? ''),
addressBindingType: $addressBindingType,
implementation: $strategy->parseBindingImplementation($wsdl, $soapBinding),
operations: new BindingOperations(
...$xpath->query('./wsdl:operation', $binding)
->expectAllOfType(DOMElement::class)
->expectAllOfType(Element::class)
->map(
static fn (DOMElement $operation) => (new BindingOperationParser())($wsdl, $operation, $strategy)
static fn (Element $operation) => (new BindingOperationParser())($wsdl, $operation, $strategy)
)
),
);
Expand All @@ -45,9 +45,9 @@ public static function tryParse(Document $wsdl): Bindings

return new Bindings(
...$xpath->query('/wsdl:definitions/wsdl:binding')
->expectAllOfType(DOMElement::class)
->expectAllOfType(Element::class)
->map(
static fn (DOMElement $binding): Binding => $parse($wsdl, $binding)
static fn (Element $binding): Binding => $parse($wsdl, $binding)
)
);
}
Expand Down
20 changes: 10 additions & 10 deletions src/Parser/Definitions/MessageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Soap\WsdlReader\Parser\Definitions;

use DOMElement;
use Dom\Element;
use Soap\WsdlReader\Model\Definitions\Message;
use Soap\WsdlReader\Model\Definitions\Messages;
use Soap\WsdlReader\Model\Definitions\Part;
Expand All @@ -14,25 +14,25 @@

final class MessageParser
{
public function __invoke(Document $wsdl, DOMElement $message): Message
public function __invoke(Document $wsdl, Element $message): Message
{
$xpath = $wsdl->xpath(new WsdlPreset($wsdl));

return new Message(
name: $message->getAttribute('name'),
name: $message->getAttribute('name') ?? '',
parts: new Parts(
...$xpath->query('./wsdl:part', $message)
->expectAllOfType(DOMElement::class)
->expectAllOfType(Element::class)
->map(
static function (DOMElement $part) {
static function (Element $part) {
$element = match (true) {
$part->hasAttribute('element') => QNamed::parse($part->getAttribute('element')),
$part->hasAttribute('type') => QNamed::parse($part->getAttribute('type')),
$part->hasAttribute('element') => QNamed::parse($part->getAttribute('element') ?? ''),
$part->hasAttribute('type') => QNamed::parse($part->getAttribute('type') ?? ''),
default => null
};

return new Part(
name: $part->getAttribute('name'),
name: $part->getAttribute('name') ?? '',
element: $element,
);
}
Expand All @@ -48,9 +48,9 @@ public static function tryParse(Document $wsdl): Messages

return new Messages(
...$xpath->query('/wsdl:definitions/wsdl:message')
->expectAllOfType(DOMElement::class)
->expectAllOfType(Element::class)
->map(
static fn (DOMElement $message) => $parse($wsdl, $message)
static fn (Element $message) => $parse($wsdl, $message)
)
);
}
Expand Down
17 changes: 10 additions & 7 deletions src/Parser/Definitions/NamespacesParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

namespace Soap\WsdlReader\Parser\Definitions;

use DOMNameSpaceNode;
use Dom\NamespaceInfo;
use Soap\WsdlReader\Model\Definitions\Namespaces;
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\recursive_linked_namespaces;

Expand All @@ -18,22 +19,24 @@ public static function tryParse(Document $wsdl): Namespaces
$allNamespaces = recursive_linked_namespaces($root);

return new Namespaces(
$allNamespaces->reduce(
reduce(
$allNamespaces,
/**
* @param array<string, string> $map
* @return array<string, string>
*/
static fn (array $map, DOMNameSpaceNode $node): array
=> merge($map, [(string)$node->localName => (string)$node->namespaceURI]),
static fn (array $map, NamespaceInfo $node): array
=> merge($map, [(string)$node->prefix => (string)$node->namespaceURI]),
[]
),
$allNamespaces->reduce(
reduce(
$allNamespaces,
/**
* @param array<string, string> $map
* @return array<string, string>
*/
static fn (array $map, DOMNameSpaceNode $node): array
=> merge($map, [(string)$node->namespaceURI => (string)$node->localName]),
static fn (array $map, NamespaceInfo $node): array
=> merge($map, [(string)$node->namespaceURI => (string)$node->prefix]),
[]
)
);
Expand Down
14 changes: 7 additions & 7 deletions src/Parser/Definitions/OperationParamParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Soap\WsdlReader\Parser\Definitions;

use DOMElement;
use Dom\Element;
use Psl\Type;
use Soap\WsdlReader\Model\Definitions\Param;
use Soap\WsdlReader\Model\Definitions\Params;
Expand All @@ -16,7 +16,7 @@

final class OperationParamParser
{
public function __invoke(Document $wsdl, DOMElement $operation): Param
public function __invoke(Document $wsdl, Element $operation): Param
{
$xpath = $wsdl->xpath(new WsdlPreset($wsdl));

Expand All @@ -26,25 +26,25 @@ public function __invoke(Document $wsdl, DOMElement $operation): Param
);
}

public static function tryParseOptionally(Document $wsdl, string $message, DOMElement $operation): ?Param
public static function tryParseOptionally(Document $wsdl, string $message, Element $operation): ?Param
{
$xpath = $wsdl->xpath(new WsdlPreset($wsdl));
return wrap(static fn (): DOMElement => assert_element($xpath->querySingle('./wsdl:'.$message, $operation)))
return wrap(static fn (): Element => assert_element($xpath->querySingle('./wsdl:'.$message, $operation)))
->proceed(
static fn (DOMElement $messageElement): Param =>
static fn (Element $messageElement): Param =>
(new self())($wsdl, $messageElement),
static fn () => null
);
}

/**
* @param NodeList<DOMElement> $params
* @param NodeList<Element> $params
*/
public static function tryParseList(Document $wsdl, NodeList $params): Params
{
return new Params(
...$params->map(
static fn (DOMElement $param): Param => (new self)($wsdl, $param)
static fn (Element $param): Param => (new self)($wsdl, $param)
)
);
}
Expand Down
Loading
Loading