Skip to content

Commit

Permalink
Merge pull request #25 from fredbradley/v1
Browse files Browse the repository at this point in the history
Upgrade | PHP 8.3 & `veewee/xml` v3.1
  • Loading branch information
Sammyjo20 authored Aug 3, 2024
2 parents 0656017 + aedd86f commit 2ae4e69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# Caches, externally stored stuff, etc
.php-cs-fixer.cache
.phpunit.result.cache
.phpunit.cache

# environments/configs
phpstan.neon
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"homepage": "https://github.com/saloonphp/xml-wrangler",
"require": {
"php": "^8.1",
"veewee/xml": "^2.11.2",
"veewee/xml": "^3.1.0",
"spatie/array-to-xml": "^3.2",
"ext-dom": "*"
},
Expand Down
10 changes: 7 additions & 3 deletions src/XmlReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use InvalidArgumentException;
use VeeWee\Xml\Reader\Reader;
use VeeWee\Xml\Reader\Matcher;
use VeeWee\Xml\Reader\MatchingNode;
use Saloon\XmlWrangler\Data\Element;
use Psr\Http\Message\MessageInterface;
use function VeeWee\Xml\Encoding\xml_decode;
Expand Down Expand Up @@ -189,7 +190,7 @@ public function elements(): array

$results = function () use ($results): Generator {
foreach ($results as $result) {
yield from $this->parseXml($result);
yield from $this->parseXml($result->xml());
}
};

Expand Down Expand Up @@ -288,7 +289,7 @@ public function element(string $name, array $withAttributes = []): LazyQuery
continue;
}

$element = $this->parseXml($result);
$element = $this->parseXml($result->xml());

yield $element[array_key_first($element)];
}
Expand Down Expand Up @@ -328,9 +329,12 @@ public function xpathElement(string $query): Query
if (empty($namespaceMap)) {
$namespaceFilter = $keepNamespaces ? RemoveNamespaces::unprefixed() : RemoveNamespaces::all();

$xml = Document::fromXmlString($xml, traverse($namespaceFilter))->toXmlString();
$xml = Document::fromXmlString($xml->xml(), traverse($namespaceFilter))->toXmlString();
} else {
$xpathConfigurators[] = namespaces($namespaceMap);

// Make $xml from MatchingNode into a string
$xml = $xml->xml();
}

$xpath = Document::fromXmlString($xml)->xpath(...$xpathConfigurators);
Expand Down

0 comments on commit 2ae4e69

Please sign in to comment.