Skip to content

Commit

Permalink
Change CI settings
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Sep 16, 2024
1 parent 1684b97 commit a31bfa5
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analyzers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.2', '8.3']
php-versions: ['8.4']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/autoloader.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.2', '8.3']
php-versions: ['8.4']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
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 @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.2', '8.3']
php-versions: ['8.4']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stress.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.2', '8.3']
php-versions: ['8.4']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.2', '8.3']
php-versions: ['8.4']
experimental: [false]
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"type": "library",
"require": {
"php": "~8.2.0 || ~8.3.0",
"php": "~8.4.0",
"ext-dom": "*",
"ext-libxml": "*",
"ext-xml": "*",
Expand Down
45 changes: 29 additions & 16 deletions src/Xml/Dom/Manipulator/Xmlns/rename_element_namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,42 @@
namespace VeeWee\Xml\Dom\Manipulator\Xmlns;

use VeeWee\Xml\Exception\RuntimeException;
use function VeeWee\Xml\Dom\Builder\xmlns_attribute;
use function VeeWee\Xml\Dom\Predicate\is_element;
use function VeeWee\Xml\Dom\Predicate\is_xmlns_attribute;

/**
* @throws RuntimeException
* @param non-empty-string $newPrefix
*/
function rename_element_namespace(\DOM\Element $root, string $namespaceURI, string $newPrefix): void
{
foreach ($root->childNodes as $child) {
if (is_element($child)) {
rename_element_namespace($child, $namespaceURI, $newPrefix);

$recurse = function (\DOM\Element $element) use (&$recurse, $namespaceURI, $newPrefix): void {
foreach ($element->childNodes as $child) {
if (is_element($child)) {
$recurse($child);
}
}

$hasXmlnsAttribute = false;
foreach ($element->attributes as $attr) {
if ($attr->namespaceURI === $namespaceURI) {
$attr->rename($namespaceURI, $newPrefix . ':' . $attr->localName);
}

if (is_xmlns_attribute($attr) && $attr->value === $namespaceURI) {
$attr->rename($attr->namespaceURI, 'xmlns:' . $newPrefix);
}
}
}

foreach ($root->attributes as $attr) {
match (true) {
$attr->namespaceURI === $namespaceURI => $attr->rename($namespaceURI, $newPrefix . ':' . $attr->localName),
is_xmlns_attribute($attr) && $attr->value === $namespaceURI => $attr->rename($attr->namespaceURI, 'xmlns:' . $newPrefix),
default => null,
};
}

if ($root->namespaceURI === $namespaceURI) {
$root->rename($namespaceURI, $newPrefix . ':' . $root->localName);
}

if ($element->namespaceURI === $namespaceURI) {
$element->rename($namespaceURI, $newPrefix . ':' . $element->localName);
}
};

$recurse(
// TODO - should become : xmlns_attribute($newPrefix, $namespaceURI)($root),
$root
);
}
2 changes: 1 addition & 1 deletion tests/Xml/Dom/Configurator/ComparableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function provideXmls()
</foo>
EOXML,
<<<EOXML
<foo xmlns:ns1="http://a" xmlns:ns2="http://z" target="universe" version="1.9">
<foo target="universe" version="1.9" xmlns:ns1="http://a" xmlns:ns2="http://z">
<item id="1" sku="jos">Jos</item>
<item id="2" sku="jaak">Jaak</item>
<item ns1:sku="jaak" ns2:id="3">Jul</item>
Expand Down
2 changes: 1 addition & 1 deletion tests/Xml/Dom/Configurator/OptimizeNamespacesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function provideXmls()
<<<EOXML
<foo xmlns:ns1="http://whatever">
<bar>
<ns1:baz xmlns:ns1="http://whatever"/>
<ns1:baz/>
</bar>
</foo>
EOXML,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function provideXmls()
<<<EOXML
<foo xmlns:ns1="http://whatever">
<bar>
<ns1:baz xmlns:ns1="http://whatever"/>
<ns1:baz/>
</bar>
</foo>
EOXML,
Expand Down

0 comments on commit a31bfa5

Please sign in to comment.