Skip to content

Commit 460270d

Browse files
committed
Migrate DOM-classes to PHP 8.4's new DOM-API
1 parent e9234c8 commit 460270d

103 files changed

Lines changed: 464 additions & 410 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.

src/SAML11/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\SAML11\Utils;
66

7-
use DOMNode;
8-
use DOMXPath;
7+
use Dom;
98
use SimpleSAML\SAML11\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/SAML11/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\SAML11\XML;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\SAML11\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/SAML11/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\SAML11\XML;
66

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

src/SAML11/XML/saml/AbstractActionType.php

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

55
namespace SimpleSAML\SAML11\XML\saml;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\Assert\Assert;
99
use SimpleSAML\SAML11\Type\SAMLAnyURIValue;
1010
use SimpleSAML\SAML11\Type\SAMLStringValue;
@@ -60,7 +60,7 @@ public function getNamespace(): ?SAMLAnyURIValue
6060
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
6161
* if the qualified name of the supplied element is wrong
6262
*/
63-
public static function fromXML(DOMElement $xml): static
63+
public static function fromXML(Dom\Element $xml): static
6464
{
6565
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
6666
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
@@ -75,7 +75,7 @@ public static function fromXML(DOMElement $xml): static
7575
/**
7676
* Convert this ActionType to XML.
7777
*/
78-
public function toXML(?DOMElement $parent = null): DOMElement
78+
public function toXML(?Dom\Element $parent = null): Dom\Element
7979
{
8080
$e = $this->instantiateParentElement($parent);
8181
$e->textContent = strval($this->getValue());

src/SAML11/XML/saml/AbstractAdviceType.php

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

55
namespace SimpleSAML\SAML11\XML\saml;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\Assert\Assert;
99
use SimpleSAML\SAML11\Constants as C;
1010
use SimpleSAML\XML\Chunk;
@@ -87,7 +87,7 @@ public function isEmptyElement(): bool
8787
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
8888
* if the qualified name of the supplied element is wrong
8989
*/
90-
public static function fromXML(DOMElement $xml): static
90+
public static function fromXML(Dom\Element $xml): static
9191
{
9292
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
9393
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
@@ -96,7 +96,7 @@ public static function fromXML(DOMElement $xml): static
9696
foreach ($xml->childNodes as $element) {
9797
if ($element->namespaceURI === C::NS_SAML) {
9898
continue;
99-
} elseif (!($element instanceof DOMElement)) {
99+
} elseif (!($element instanceof Dom\Element)) {
100100
continue;
101101
}
102102

@@ -114,7 +114,7 @@ public static function fromXML(DOMElement $xml): static
114114
/**
115115
* Convert this EvidenceType to XML.
116116
*/
117-
public function toXML(?DOMElement $parent = null): DOMElement
117+
public function toXML(?Dom\Element $parent = null): Dom\Element
118118
{
119119
$e = $this->instantiateParentElement($parent);
120120

src/SAML11/XML/saml/AbstractAssertionType.php

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

55
namespace SimpleSAML\SAML11\XML\saml;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\SAML11\Assert\Assert;
99
use SimpleSAML\SAML11\Compat\ContainerSingleton;
1010
use SimpleSAML\SAML11\Constants as C;
@@ -50,7 +50,7 @@ abstract class AbstractAssertionType extends AbstractSamlElement implements
5050
/**
5151
* The original signed XML
5252
*/
53-
protected DOMElement $xml;
53+
protected Dom\Element $xml;
5454

5555

5656
/**
@@ -231,15 +231,15 @@ public function getAttributeStatements(): array
231231
/**
232232
* Set the XML element.
233233
*/
234-
private function setOriginalXML(DOMElement $xml): void
234+
private function setOriginalXML(Dom\Element $xml): void
235235
{
236236
$this->xml = $xml;
237237
}
238238

239239

240240
/**
241241
*/
242-
protected function getOriginalXML(): DOMElement
242+
protected function getOriginalXML(): Dom\Element
243243
{
244244
return $this->xml ?? $this->toUnsignedXML();
245245
}
@@ -258,7 +258,7 @@ public function getBlacklistedAlgorithms(): ?array
258258
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
259259
* if the qualified name of the supplied element is wrong
260260
*/
261-
public static function fromXML(DOMElement $xml): static
261+
public static function fromXML(Dom\Element $xml): static
262262
{
263263
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
264264
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
@@ -312,7 +312,7 @@ public static function fromXML(DOMElement $xml): static
312312
* Convert this assertion to an unsigned XML document.
313313
* This method does not sign the resulting XML document.
314314
*/
315-
protected function toUnsignedXML(?DOMElement $parent = null): DOMElement
315+
protected function toUnsignedXML(?Dom\Element $parent = null): Dom\Element
316316
{
317317
$e = $this->instantiateParentElement($parent);
318318

@@ -338,7 +338,7 @@ protected function toUnsignedXML(?DOMElement $parent = null): DOMElement
338338
*
339339
* @throws \Exception
340340
*/
341-
public function toXML(?DOMElement $parent = null): DOMElement
341+
public function toXML(?Dom\Element $parent = null): Dom\Element
342342
{
343343
if ($this->isSigned() === true && $this->signer === null) {
344344
// We already have a signed document and no signer was set to re-sign it

src/SAML11/XML/saml/AbstractAttributeDesignatorType.php

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

55
namespace SimpleSAML\SAML11\XML\saml;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\SAML11\Type\SAMLAnyURIValue;
99
use SimpleSAML\SAML11\Type\SAMLStringValue;
1010

@@ -55,7 +55,7 @@ public function getAttributeNamespace(): SAMLAnyURIValue
5555
/**
5656
* Convert this AttributeDesignatorType to XML.
5757
*/
58-
public function toXML(?DOMElement $parent = null): DOMElement
58+
public function toXML(?Dom\Element $parent = null): Dom\Element
5959
{
6060
$e = $this->instantiateParentElement($parent);
6161

src/SAML11/XML/saml/AbstractAttributeStatementType.php

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

55
namespace SimpleSAML\SAML11\XML\saml;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\Assert\Assert;
99
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1010
use SimpleSAML\XMLSchema\Exception\MissingElementException;
@@ -51,7 +51,7 @@ public function getAttributes(): array
5151
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
5252
* if the qualified name of the supplied element is wrong
5353
*/
54-
public static function fromXML(DOMElement $xml): static
54+
public static function fromXML(Dom\Element $xml): static
5555
{
5656
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
5757
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
@@ -70,7 +70,7 @@ public static function fromXML(DOMElement $xml): static
7070
/**
7171
* Convert this AttributeStatementType to XML.
7272
*/
73-
public function toXML(?DOMElement $parent = null): DOMElement
73+
public function toXML(?Dom\Element $parent = null): Dom\Element
7474
{
7575
$e = parent::toXML($parent);
7676

src/SAML11/XML/saml/AbstractAttributeType.php

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

55
namespace SimpleSAML\SAML11\XML\saml;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\Assert\Assert;
99
use SimpleSAML\SAML11\Type\SAMLAnyURIValue;
1010
use SimpleSAML\SAML11\Type\SAMLStringValue;
@@ -53,7 +53,7 @@ public function getAttributeValue(): array
5353
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
5454
* if the qualified name of the supplied element is wrong
5555
*/
56-
public static function fromXML(DOMElement $xml): static
56+
public static function fromXML(Dom\Element $xml): static
5757
{
5858
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
5959
Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class);
@@ -69,7 +69,7 @@ public static function fromXML(DOMElement $xml): static
6969
/**
7070
* Convert this AttributeType to XML.
7171
*/
72-
public function toXML(?DOMElement $parent = null): DOMElement
72+
public function toXML(?Dom\Element $parent = null): Dom\Element
7373
{
7474
$e = parent::toXML($parent);
7575

src/SAML11/XML/saml/AbstractAudienceRestrictionConditionType.php

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

55
namespace SimpleSAML\SAML11\XML\saml;
66

7-
use DOMElement;
7+
use Dom;
88
use SimpleSAML\Assert\Assert;
99
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1010
use SimpleSAML\XMLSchema\Exception\MissingElementException;
@@ -44,7 +44,7 @@ public function getAudience(): array
4444
* @throws \SimpleSAML\XML\Exception\InvalidDOMElementException
4545
* if the qualified name of the supplied element is wrong
4646
*/
47-
public static function fromXML(DOMElement $xml): static
47+
public static function fromXML(Dom\Element $xml): static
4848
{
4949
Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class);
5050
Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class);
@@ -61,7 +61,7 @@ public static function fromXML(DOMElement $xml): static
6161
/**
6262
* Convert this AudienceRestrictionCondition to XML.
6363
*/
64-
public function toXML(?DOMElement $parent = null): DOMElement
64+
public function toXML(?Dom\Element $parent = null): Dom\Element
6565
{
6666
$e = $this->instantiateParentElement($parent);
6767

0 commit comments

Comments
 (0)