Skip to content

Commit 72bbf9c

Browse files
committed
Upgrade to veewee/xml v4 with PHP 8.4+
- Bump minimum PHP to ~8.4.0 || ~8.5.0 - Replace monolithic PSL with standalone php-standard-library packages - Migrate from legacy ext-dom (DOMDocument, DOMElement, DOMNode) to PHP 8.4 Dom\ namespace (XMLDocument, Element, Node, NamespaceInfo) - Handle nullable getAttribute() returns in the new DOM API - Remove FixRemovedDefaultXmlnsDeclarationsDuringImport workaround (no longer needed with PHP 8.4 spec-compliant DOM) - Remove bundled dom.phpstub (now shipped by veewee/xml) - Bump veewee/xml to ^4.9 (includes C14N duplicate xmlns workaround) - Update CI to PHP 8.4/8.5, add test timeout
1 parent bb38ff0 commit 72bbf9c

18 files changed

Lines changed: 143 additions & 140 deletions

.github/workflows/analyzers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
operating-system: [ubuntu-latest]
10-
php-versions: ['8.3', '8.4', '8.5']
10+
php-versions: ['8.4', '8.5']
1111
composer-options: ['--ignore-platform-req=php+']
1212
fail-fast: false
1313
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}

.github/workflows/code-style.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
operating-system: [ubuntu-latest]
10-
php-versions: ['8.3', '8.4', '8.5']
10+
php-versions: ['8.4', '8.5']
1111
composer-options: ['--ignore-platform-req=php+']
1212
fail-fast: false
1313
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}

.github/workflows/tests.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,27 @@ jobs:
77
strategy:
88
matrix:
99
operating-system: [ubuntu-latest]
10-
php-versions: ['8.3', '8.4', '8.5']
10+
php-versions: ['8.4', '8.5']
1111
composer-options: ['--ignore-platform-req=php+']
1212
fail-fast: false
1313
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@master
1717
- name: Install PHP
18-
uses: shivammathur/setup-php@master
18+
uses: shivammathur/setup-php@v2
1919
with:
2020
php-version: ${{ matrix.php-versions }}
2121
tools: 'composer:v2'
22-
extensions: pcov, mbstring, posix, dom, soap
22+
extensions: mbstring, posix, dom, soap
23+
coverage: pcov
24+
env:
25+
update: true
26+
- name: PHP info
27+
run: |
28+
php -v
29+
php -i | grep -i libxml
2330
- name: Install dependencies
2431
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }}
2532
- name: Run the tests
26-
run: ./vendor/bin/phpunit
33+
run: php vendor/bin/phpunit

composer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@
2626
"sort-packages": true
2727
},
2828
"require": {
29-
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
29+
"php": "~8.4.0 || ~8.5.0",
3030
"ext-dom": "*",
31-
"php-standard-library/php-standard-library": "^3.0 || ^4.0 || ^5.0 || ^6.0",
3231
"league/uri": "^7.0",
3332
"league/uri-components": "^7.0",
3433
"php-soap/xml": "^1.9",
34+
"php-standard-library/dict": "^6.1",
35+
"php-standard-library/file": "^6.1",
36+
"php-standard-library/filesystem": "^6.1",
37+
"php-standard-library/foundation": "^6.1",
38+
"php-standard-library/fun": "^6.1",
39+
"php-standard-library/option": "^6.1",
40+
"php-standard-library/str": "^6.1",
41+
"php-standard-library/type": "^6.1",
42+
"php-standard-library/vec": "^6.1",
3543
"symfony/console": "^5.4 || ^6.0 || ^7.0 || ^8.0",
36-
"veewee/xml": "~3.0"
44+
"veewee/xml": "^4.9"
3745
},
3846
"require-dev": {
3947
"php-cs-fixer/shim": "^3.88",

psalm.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
errorLevel="1"
44
resolveFromConfigFile="true"
55
strictBinaryOperands="true"
6-
phpVersion="8.1"
6+
phpVersion="8.4"
77
allowStringToStandInForClass="true"
88
rememberPropertyAssignmentsAfterCall="false"
99
skipChecksOnUnresolvableIncludes="false"
@@ -30,6 +30,6 @@
3030
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
3131
</plugins>
3232
<stubs>
33-
<file name="stubs/dom.phpstub" />
33+
<file name="vendor/veewee/xml/stubs/DOM.phpstub" />
3434
</stubs>
3535
</psalm>

src/Loader/Context/FlatteningContext.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Soap\Wsdl\Loader\Context;
55

6-
use DOMElement;
6+
use Dom\Element;
77
use Psl\Type\Exception\AssertException;
88
use Soap\Wsdl\Exception\UnloadableWsdlException;
99
use Soap\Wsdl\Loader\WsdlLoader;
@@ -79,12 +79,12 @@ public function wsdl(): Document
7979
*
8080
* @throws RuntimeException
8181
*/
82-
public function types(): DOMElement
82+
public function types(): Element
8383
{
8484
$doc = Document::fromUnsafeDocument($this->wsdl->toUnsafeDocument(), new FlattenTypes());
8585
$xpath = $doc->xpath(new WsdlPreset($doc));
8686

87-
/** @var DOMElement $types */
87+
/** @var Element $types */
8888
$types = $xpath->querySingle('//wsdl:types');
8989

9090
return $types;

src/Xml/Configurator/FlattenTypes.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
namespace Soap\Wsdl\Xml\Configurator;
55

6-
use DOMDocument;
7-
use DOMElement;
6+
use Dom\Element;
7+
use Dom\XMLDocument;
88
use Soap\Xml\Xmlns;
99
use Soap\Xml\Xpath\WsdlPreset;
1010
use VeeWee\Xml\Dom\Configurator\Configurator;
1111
use VeeWee\Xml\Dom\Document;
1212
use VeeWee\Xml\Exception\RuntimeException;
1313
use function VeeWee\Xml\Dom\Builder\namespaced_element;
14+
use function VeeWee\Xml\Dom\Locator\document_element;
1415
use function VeeWee\Xml\Dom\Locator\Node\children;
1516
use function VeeWee\Xml\Dom\Manipulator\append;
1617
use function VeeWee\Xml\Dom\Manipulator\Node\remove;
@@ -24,16 +25,16 @@ final class FlattenTypes implements Configurator
2425
/**
2526
* @throws RuntimeException
2627
*/
27-
public function __invoke(DOMDocument $document): DOMDocument
28+
public function __invoke(XMLDocument $document): XMLDocument
2829
{
2930
$xml = Document::fromUnsafeDocument($document);
3031
$xpath = $xml->xpath(new WsdlPreset($xml));
31-
/** @var list<DOMElement> $types */
32+
/** @var list<Element> $types */
3233
$types = [...$xpath->query('wsdl:types')];
3334

3435
// Creates wsdl:types if no matching element exists yet
3536
if (!count($types)) {
36-
$document->documentElement->append(
37+
$xml->map(document_element())->append(
3738
namespaced_element(Xmlns::wsdl()->value(), 'types')($document)
3839
);
3940

src/Xml/Configurator/FlattenWsdlImports.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Soap\Wsdl\Xml\Configurator;
66

7-
use DOMDocument;
8-
use DOMElement;
7+
use Dom\Element;
8+
use Dom\XMLDocument;
99
use Soap\Wsdl\Exception\UnloadableWsdlException;
1010
use Soap\Wsdl\Loader\Context\FlatteningContext;
1111
use Soap\Wsdl\Uri\IncludePathBuilder;
@@ -14,6 +14,7 @@
1414
use VeeWee\Xml\Dom\Configurator\Configurator;
1515
use VeeWee\Xml\Dom\Document;
1616
use VeeWee\Xml\Exception\RuntimeException;
17+
use function VeeWee\Xml\Dom\Assert\assert_document;
1718
use function VeeWee\Xml\Dom\Locator\document_element;
1819
use function VeeWee\Xml\Dom\Locator\Node\children;
1920
use function VeeWee\Xml\Dom\Manipulator\Element\copy_named_xmlns_attributes;
@@ -40,13 +41,13 @@ public function __construct(
4041
* @throws RuntimeException
4142
* @throws UnloadableWsdlException
4243
*/
43-
public function __invoke(DOMDocument $document): DOMDocument
44+
public function __invoke(XMLDocument $document): XMLDocument
4445
{
4546
$xml = Document::fromUnsafeDocument($document);
4647
$xpath = $xml->xpath(new WsdlPreset($xml));
4748

48-
$imports = $xpath->query('wsdl:import')->expectAllOfType(DOMElement::class);
49-
$imports->forEach(fn (DOMElement $import) => $this->importWsdlImportElement($import));
49+
$imports = $xpath->query('wsdl:import')->expectAllOfType(Element::class);
50+
$imports->forEach(fn (Element $import) => $this->importWsdlImportElement($import));
5051

5152
return $document;
5253
}
@@ -55,10 +56,10 @@ public function __invoke(DOMDocument $document): DOMDocument
5556
* @throws RuntimeException
5657
* @throws UnloadableWsdlException
5758
*/
58-
private function importWsdlImportElement(DOMElement $import): void
59+
private function importWsdlImportElement(Element $import): void
5960
{
6061
$location = IncludePathBuilder::build(
61-
$import->getAttribute('location'),
62+
$import->getAttribute('location') ?? '',
6263
$this->currentLocation
6364
);
6465

@@ -79,11 +80,15 @@ private function importWsdlImportElement(DOMElement $import): void
7980

8081
/**
8182
* @throws RuntimeException
83+
* @throws \Psl\Type\Exception\AssertException
8284
*/
83-
private function importWsdlPart(DOMElement $importElement, Document $importedDocument): void
85+
private function importWsdlPart(Element $importElement, Document $importedDocument): void
8486
{
8587
$definitions = $importedDocument->map(document_element());
86-
copy_named_xmlns_attributes($importElement->ownerDocument->documentElement, $definitions);
88+
copy_named_xmlns_attributes(
89+
document_element()(assert_document($importElement->ownerDocument)),
90+
$definitions
91+
);
8792

8893
replace_by_external_nodes(
8994
$importElement,
@@ -94,7 +99,7 @@ private function importWsdlPart(DOMElement $importElement, Document $importedDoc
9499
/**
95100
* @throws RuntimeException
96101
*/
97-
private function importXsdPart(DOMElement $importElement, Document $importedDocument): void
102+
private function importXsdPart(Element $importElement, Document $importedDocument): void
98103
{
99104
$types = $this->context->types();
100105
remove($importElement);

0 commit comments

Comments
 (0)