Skip to content

Commit 169bb5d

Browse files
committed
Migrate DOM-classes to PHP 8.4's new DOM-API
1 parent b5b0cde commit 169bb5d

265 files changed

Lines changed: 1189 additions & 1005 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
"psr/http-message": "~2.0",
3232
"psr/log": "~3.0",
3333
"simplesamlphp/assert": "~2.0",
34-
"simplesamlphp/xml-common": "~2.8",
35-
"simplesamlphp/xml-security": "~2.3",
36-
"simplesamlphp/xml-soap": "~2.3",
34+
"simplesamlphp/xml-common": "dev-feature/dom-migration-php84",
35+
"simplesamlphp/xml-security": "dev-feature/dom-migration-php84",
36+
"simplesamlphp/xml-soap": "dev-feature/dom-migration-php84",
3737
"robrichards/xmlseclibs": "^3.1"
3838
},
3939
"require-dev": {

src/Binding/SOAP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ public function receive(/** @scrutinizer ignore-unused */ServerRequestInterface
9999
}
100100

101101
$document = DOMDocumentFactory::fromString($postText);
102-
/** @var \DOMNode $xml */
102+
/** @var \Dom\Node $xml */
103103
$xml = $document->firstChild;
104104
Utils::getContainer()->debugMessage($document->documentElement, 'in');
105105

106106
$xpCache = XPath::getXPath($document->documentElement);
107-
/** @var \DOMElement[] $results */
107+
/** @var \Dom\Element[] $results */
108108
$results = XPath::xpQuery($xml, '/SOAP-ENV:Envelope/SOAP-ENV:Body/*[1]', $xpCache);
109109

110110
return MessageFactory::fromXML($results[0]);

src/Compat/AbstractContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ abstract public function getLogger(): LoggerInterface;
142142
* - **encrypt** XML that is about to be encrypted
143143
* - **decrypt** XML that was just decrypted
144144
*
145-
* @param \DOMElement|string $message
145+
* @param \Dom\Element|string $message
146146
*/
147147
abstract public function debugMessage($message, string $type): void;
148148

src/Compat/MockContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getLogger(): LoggerInterface
4545
* - **encrypt** XML that is about to be encrypted
4646
* - **decrypt** XML that was just decrypted
4747
*
48-
* @param \DOMElement|string $message
48+
* @param \Dom\Element|string $message
4949
*/
5050
public function debugMessage($message, string $type): void
5151
{

src/Utils/XPath.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
namespace SimpleSAML\SAML2\Utils;
66

7-
use DOMNode;
8-
use DOMXPath;
7+
use Dom;
98
use SimpleSAML\SAML2\Constants as C;
109

1110
/**
@@ -16,15 +15,15 @@
1615
class XPath extends \SimpleSAML\XMLSecurity\Utils\XPath
1716
{
1817
/**
19-
* Get a DOMXPath object that can be used to search for SAML elements.
18+
* Get a Dom\XPath object that can be used to search for SAML elements.
2019
*
21-
* @param \DOMNode $node The document to associate to the DOMXPath object.
20+
* @param \Dom\Node $node The document to associate to the Dom\XPath object.
2221
* @param bool $autoregister Whether to auto-register all namespaces used in the document
2322
*
24-
* @return \DOMXPath A DOMXPath object ready to use in the given document, with several
23+
* @return \Dom\XPath A Dom\XPath object ready to use in the given document, with several
2524
* saml-related namespaces already registered.
2625
*/
27-
public static function getXPath(DOMNode $node, bool $autoregister = false): DOMXPath
26+
public static function getXPath(Dom\Node $node, bool $autoregister = false): Dom\XPath
2827
{
2928
$xp = parent::getXPath($node, $autoregister);
3029

src/XML/CanonicalizableElementTrait.php

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

55
namespace SimpleSAML\SAML2\XML;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\XMLSecurity\Assert\Assert;
99
use SimpleSAML\XMLSecurity\Constants as C;
1010
use SimpleSAML\XMLSecurity\Exception\CanonicalizationFailedException;
@@ -26,15 +26,15 @@ trait CanonicalizableElementTrait
2626
* Process all transforms specified by a given Reference element.
2727
*
2828
* @param \SimpleSAML\XMLSecurity\XML\ds\Transforms $transforms The transforms to apply.
29-
* @param \DOMElement $data The data referenced.
29+
* @param \Dom\Element $data The data referenced.
3030
*
3131
* @return string The canonicalized data after applying all transforms specified by $ref.
3232
*
3333
* @see http://www.w3.org/TR/xmldsig-core/#sec-ReferenceProcessingModel
3434
*/
3535
public function processTransforms(
3636
Transforms $transforms,
37-
DOMElement $data,
37+
Dom\Element $data,
3838
): string {
3939
Assert::maxCount(
4040
$transforms->getTransform(),

src/XML/EncryptedElementTrait.php

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

55
namespace SimpleSAML\SAML2\XML;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\SAML2\Assert\Assert;
99
use SimpleSAML\SAML2\Compat\ContainerSingleton;
1010
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
@@ -92,7 +92,7 @@ public function getDecryptionKeys(): array
9292
* @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
9393
* If the qualified name of the supplied element is wrong
9494
*/
95-
public static function fromXML(DOMElement $xml): static
95+
public static function fromXML(Dom\Element $xml): static
9696
{
9797
Assert::same(
9898
$xml->localName,
@@ -120,7 +120,7 @@ public static function fromXML(DOMElement $xml): static
120120
/**
121121
* @inheritDoc
122122
*/
123-
public function toXML(?DOMElement $parent = null): DOMElement
123+
public function toXML(?Dom\Element $parent = null): Dom\Element
124124
{
125125
$e = $this->instantiateParentElement($parent);
126126

src/XML/ExtensionsTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace SimpleSAML\SAML2\XML;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\XML\ExtendableElementTrait;
99

1010
/**
@@ -49,10 +49,10 @@ public function isEmptyElement(): bool
4949
/**
5050
* Convert this object into its md:Extensions XML representation.
5151
*
52-
* @param \DOMElement|null $parent The element we should add this Extensions element to.
53-
* @return \DOMElement The new md:Extensions XML element.
52+
* @param \Dom\Element|null $parent The element we should add this Extensions element to.
53+
* @return \Dom\Element The new md:Extensions XML element.
5454
*/
55-
public function toXML(?DOMElement $parent = null): DOMElement
55+
public function toXML(?Dom\Element $parent = null): Dom\Element
5656
{
5757
$e = $this->instantiateParentElement($parent);
5858

@@ -70,5 +70,5 @@ public function toXML(?DOMElement $parent = null): DOMElement
7070

7171
/**
7272
*/
73-
abstract public function instantiateParentElement(?DOMElement $parent = null): DOMElement;
73+
abstract public function instantiateParentElement(?Dom\Element $parent = null): Dom\Element;
7474
}

src/XML/IdentifierTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace SimpleSAML\SAML2\XML;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\SAML2\Assert\Assert;
99
use SimpleSAML\SAML2\XML\saml\AbstractBaseID;
1010
use SimpleSAML\SAML2\XML\saml\EncryptedID;
@@ -58,7 +58,7 @@ protected function setIdentifier(?IdentifierInterface $identifier): void
5858
* @throws \SimpleSAML\XMLSchema\Exception\TooManyElementsException
5959
* if too many child-elements of a type are specified
6060
*/
61-
protected static function getIdentifierFromXML(DOMElement $xml): ?IdentifierInterface
61+
protected static function getIdentifierFromXML(Dom\Element $xml): ?IdentifierInterface
6262
{
6363
$class = static::NS_PREFIX . ':' . self::getClassName(static::class);
6464

src/XML/SignableElementTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace SimpleSAML\SAML2\XML;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\SAML2\Assert\Assert;
99
use SimpleSAML\SAML2\Compat\ContainerSingleton;
1010
use SimpleSAML\XML\DOMDocumentFactory;
@@ -75,20 +75,20 @@ public function sign(
7575
/**
7676
* Do the actual signing of the document.
7777
*
78-
* Note that this method does not insert the signature in the returned \DOMElement. The signature will be available
78+
* Note that this method does not insert the signature in the returned \Dom\Element. The signature will be available
7979
* in $this->signature as a \SimpleSAML\XMLSecurity\XML\ds\Signature object, which can then be converted to XML
80-
* calling toXML() on it, passing the \DOMElement value returned here as a parameter. The resulting \DOMElement
80+
* calling toXML() on it, passing the \Dom\Element value returned here as a parameter. The resulting \Dom\Element
8181
* can then be inserted in the position desired.
8282
*
8383
* E.g.:
8484
* $xml = // our XML to sign
8585
* $signedXML = $this->doSign($xml);
8686
* $signedXML->appendChild($this->signature->toXML($signedXML));
8787
*
88-
* @param \DOMElement $xml The element to sign.
89-
* @return \DOMElement The signed element, without the signature attached to it just yet.
88+
* @param \Dom\Element $xml The element to sign.
89+
* @return \Dom\Element The signed element, without the signature attached to it just yet.
9090
*/
91-
protected function doSign(DOMElement $xml): DOMElement
91+
protected function doSign(Dom\Element $xml): Dom\Element
9292
{
9393
Assert::notNull(
9494
$this->signer,

0 commit comments

Comments
 (0)