diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 417cc7e..ea99efc 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -19,9 +19,9 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['8.5'] + php-version: ['8.5', '8.6'] - uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1 + uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@release-2.x secrets: inherit with: php-version: ${{ matrix.php-version }} @@ -31,7 +31,7 @@ jobs: strategy: fail-fast: false - uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1 + uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@release-2.x secrets: inherit with: enable_eslinter: false @@ -47,7 +47,7 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest] - php-versions: ['8.5'] + php-versions: ['8.5', '8.6'] steps: - name: Setup PHP, with composer and extensions @@ -57,7 +57,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: ctype, date, dom, filter, hash, intl, mbstring, openssl, pcre, soap, sodium, spl, xml tools: composer - ini-values: error_reporting=E_ALL + ini-values: error_reporting=E_ALL, display_errors=on coverage: pcov - name: Setup problem matchers for PHP @@ -71,7 +71,7 @@ jobs: git config --global core.autocrlf false git config --global core.eol lf - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Get composer cache directory run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" @@ -109,7 +109,7 @@ jobs: fail-fast: true matrix: operating-system: [windows-latest] - php-versions: ['8.5'] + php-versions: ['8.5', '8.6'] steps: - name: Setup PHP, with composer and extensions @@ -119,7 +119,7 @@ jobs: php-version: ${{ matrix.php-versions }} extensions: ctype, date, dom, filter, hash, intl, mbstring, openssl, pcre, soap, sodium, spl, xml, zip tools: composer - ini-values: error_reporting=E_ALL + ini-values: error_reporting=E_ALL, display_errors=on coverage: none - name: Setup problem matchers for PHP @@ -133,7 +133,7 @@ jobs: git config --global core.autocrlf false git config --global core.eol lf - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Get composer cache directory run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV" @@ -171,7 +171,7 @@ jobs: - name: Setup problem matchers for PHP run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Get composer cache directory run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" @@ -225,7 +225,7 @@ jobs: - name: Setup problem matchers for PHP run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - name: Get composer cache directory run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV" @@ -254,7 +254,7 @@ jobs: runs-on: [ubuntu-latest] needs: [unit-tests-linux] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - uses: actions/download-artifact@v8 with: diff --git a/composer.json b/composer.json index d48454b..e051ab6 100644 --- a/composer.json +++ b/composer.json @@ -18,12 +18,12 @@ "psr/clock": "~1.0", "psr/log": "~3.0", "simplesamlphp/assert": "~2.0", - "simplesamlphp/xml-common": "~2.8", - "simplesamlphp/xml-security": "~2.3" + "simplesamlphp/xml-common": "dev-feature/dom-migration-php84", + "simplesamlphp/xml-security": "dev-feature/dom-migration-php84" }, "require-dev": { "beste/clock": "~3.0", - "simplesamlphp/simplesamlphp-test-framework": "~1.11" + "simplesamlphp/simplesamlphp-test-framework": "~2.0" }, "autoload": { "psr-4": { diff --git a/src/SAML11/Utils/XPath.php b/src/SAML11/Utils/XPath.php index cb1e61e..b74ed7a 100644 --- a/src/SAML11/Utils/XPath.php +++ b/src/SAML11/Utils/XPath.php @@ -4,8 +4,7 @@ namespace SimpleSAML\SAML11\Utils; -use DOMNode; -use DOMXPath; +use Dom; use SimpleSAML\SAML11\Constants as C; /** @@ -16,15 +15,15 @@ class XPath extends \SimpleSAML\XMLSecurity\Utils\XPath { /** - * Get a DOMXPath object that can be used to search for SAML elements. + * Get a Dom\XPath object that can be used to search for SAML elements. * - * @param \DOMNode $node The document to associate to the DOMXPath object. + * @param \Dom\Node $node The document to associate to the Dom\XPath object. * @param bool $autoregister Whether to auto-register all namespaces used in the document * - * @return \DOMXPath A DOMXPath object ready to use in the given document, with several + * @return \Dom\XPath A Dom\XPath object ready to use in the given document, with several * saml-related namespaces already registered. */ - public static function getXPath(DOMNode $node, bool $autoregister = false): DOMXPath + public static function getXPath(Dom\Node $node, bool $autoregister = false): Dom\XPath { $xp = parent::getXPath($node, $autoregister); diff --git a/src/SAML11/XML/CanonicalizableElementTrait.php b/src/SAML11/XML/CanonicalizableElementTrait.php index 88b53e7..7e440f2 100644 --- a/src/SAML11/XML/CanonicalizableElementTrait.php +++ b/src/SAML11/XML/CanonicalizableElementTrait.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\XMLSecurity\Constants as C; use SimpleSAML\XMLSecurity\Exception\CanonicalizationFailedException; @@ -26,7 +26,7 @@ trait CanonicalizableElementTrait * Process all transforms specified by a given Reference element. * * @param \SimpleSAML\XMLSecurity\XML\ds\Transforms $transforms The transforms to apply. - * @param \DOMElement $data The data referenced. + * @param \Dom\Element $data The data referenced. * * @return string The canonicalized data after applying all transforms specified by $ref. * @@ -34,7 +34,7 @@ trait CanonicalizableElementTrait */ public function processTransforms( Transforms $transforms, - DOMElement $data, + Dom\Element $data, ): string { Assert::maxCount( $transforms->getTransform(), diff --git a/src/SAML11/XML/SignableElementTrait.php b/src/SAML11/XML/SignableElementTrait.php index c3b59ae..4aaa9b2 100644 --- a/src/SAML11/XML/SignableElementTrait.php +++ b/src/SAML11/XML/SignableElementTrait.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Compat\ContainerSingleton; use SimpleSAML\XML\DOMDocumentFactory; @@ -72,9 +72,9 @@ public function sign( /** * Do the actual signing of the document. * - * Note that this method does not insert the signature in the returned \DOMElement. The signature will be available + * Note that this method does not insert the signature in the returned \Dom\Element. The signature will be available * in $this->signature as a \SimpleSAML\XMLSecurity\XML\ds\Signature object, which can then be converted to XML - * calling toXML() on it, passing the \DOMElement value returned here as a parameter. The resulting \DOMElement + * calling toXML() on it, passing the \Dom\Element value returned here as a parameter. The resulting \Dom\Element * can then be inserted in the position desired. * * E.g.: @@ -82,10 +82,10 @@ public function sign( * $signedXML = $this->doSign($xml); * $signedXML->appendChild($this->signature->toXML($signedXML)); * - * @param \DOMElement $xml The element to sign. - * @return \DOMElement The signed element, without the signature attached to it just yet. + * @param \Dom\Element $xml The element to sign. + * @return \Dom\Element The signed element, without the signature attached to it just yet. */ - protected function doSign(DOMElement $xml): DOMElement + protected function doSign(Dom\Element $xml): Dom\Element { Assert::notNull( $this->signer, diff --git a/src/SAML11/XML/SignedElementTrait.php b/src/SAML11/XML/SignedElementTrait.php index 52f23bf..8d9e31a 100644 --- a/src/SAML11/XML/SignedElementTrait.php +++ b/src/SAML11/XML/SignedElementTrait.php @@ -10,6 +10,8 @@ use SimpleSAML\XMLSecurity\XML\ds\Signature; use SimpleSAML\XMLSecurity\XML\SignedElementTrait as BaseSignedElementTrait; +use function array_last; + /** * Helper trait for processing signed elements. * @@ -35,7 +37,7 @@ protected function setSignature(Signature $signature): void $references = $signature->getSignedInfo()->getReferences(); Assert::count($references, 1, "A signature needs to have exactly one Reference, %d found."); - $reference = array_pop($references); + $reference = array_last($references); Assert::notNull($reference->getURI(), "URI attribute not found.", ReferenceValidationFailedException::class); Assert::startsWith( $reference->getURI()->getValue(), diff --git a/src/SAML11/XML/saml/AbstractActionType.php b/src/SAML11/XML/saml/AbstractActionType.php index 4ff24d1..d4cbad8 100644 --- a/src/SAML11/XML/saml/AbstractActionType.php +++ b/src/SAML11/XML/saml/AbstractActionType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\Type\SAMLStringValue; @@ -60,7 +60,7 @@ public function getNamespace(): ?SAMLAnyURIValue * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -75,7 +75,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this ActionType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); $e->textContent = strval($this->getValue()); diff --git a/src/SAML11/XML/saml/AbstractAdviceType.php b/src/SAML11/XML/saml/AbstractAdviceType.php index de0e3ea..829b39a 100644 --- a/src/SAML11/XML/saml/AbstractAdviceType.php +++ b/src/SAML11/XML/saml/AbstractAdviceType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Constants as C; use SimpleSAML\XML\Chunk; @@ -87,16 +87,16 @@ public function isEmptyElement(): bool * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); $elements = []; foreach ($xml->childNodes as $element) { - if ($element->namespaceURI === C::NS_SAML) { + if (!($element instanceof Dom\Element)) { continue; - } elseif (!($element instanceof DOMElement)) { + } elseif ($element->namespaceURI === C::NS_SAML) { continue; } @@ -114,7 +114,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this EvidenceType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractAssertionType.php b/src/SAML11/XML/saml/AbstractAssertionType.php index d4aa909..d2e676e 100644 --- a/src/SAML11/XML/saml/AbstractAssertionType.php +++ b/src/SAML11/XML/saml/AbstractAssertionType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Compat\ContainerSingleton; use SimpleSAML\SAML11\Constants as C; @@ -27,8 +27,8 @@ use SimpleSAML\XMLSecurity\XML\SignedElementTrait; use function array_filter; +use function array_last; use function array_merge; -use function array_pop; use function array_values; use function strval; @@ -50,7 +50,7 @@ abstract class AbstractAssertionType extends AbstractSamlElement implements /** * The original signed XML */ - protected DOMElement $xml; + protected Dom\Element $xml; /** @@ -231,7 +231,7 @@ public function getAttributeStatements(): array /** * Set the XML element. */ - private function setOriginalXML(DOMElement $xml): void + private function setOriginalXML(Dom\Element $xml): void { $this->xml = $xml; } @@ -239,7 +239,7 @@ private function setOriginalXML(DOMElement $xml): void /** */ - protected function getOriginalXML(): DOMElement + protected function getOriginalXML(): Dom\Element { return $this->xml ?? $this->toUnsignedXML(); } @@ -258,7 +258,7 @@ public function getBlacklistedAlgorithms(): ?array * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -294,8 +294,8 @@ public static function fromXML(DOMElement $xml): static self::getAttribute($xml, 'AssertionID', IDValue::class), self::getAttribute($xml, 'Issuer', SAMLStringValue::class), self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), - array_pop($conditions), - array_pop($advice), + array_last($conditions), + array_last($advice), array_merge($statements, $subjectStatement, $authnStatement, $authzDecisionStatement, $attrStatement), ); @@ -312,7 +312,7 @@ public static function fromXML(DOMElement $xml): static * Convert this assertion to an unsigned XML document. * This method does not sign the resulting XML document. */ - protected function toUnsignedXML(?DOMElement $parent = null): DOMElement + protected function toUnsignedXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); @@ -338,7 +338,7 @@ protected function toUnsignedXML(?DOMElement $parent = null): DOMElement * * @throws \Exception */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { if ($this->isSigned() === true && $this->signer === null) { // We already have a signed document and no signer was set to re-sign it @@ -362,7 +362,7 @@ public function toXML(?DOMElement $parent = null): DOMElement './saml_assertion/following-sibling::*[position() = last()]', XPath::getXPath($signedXML), ); - $last = array_pop($assertionElements); + $last = array_last($assertionElements); if ($last !== null) { $signedXML->insertBefore($this->signature?->toXML($signedXML), $last->nextSibling); diff --git a/src/SAML11/XML/saml/AbstractAttributeDesignatorType.php b/src/SAML11/XML/saml/AbstractAttributeDesignatorType.php index 6c726a3..e3bf830 100644 --- a/src/SAML11/XML/saml/AbstractAttributeDesignatorType.php +++ b/src/SAML11/XML/saml/AbstractAttributeDesignatorType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\Type\SAMLStringValue; @@ -55,7 +55,7 @@ public function getAttributeNamespace(): SAMLAnyURIValue /** * Convert this AttributeDesignatorType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractAttributeStatementType.php b/src/SAML11/XML/saml/AbstractAttributeStatementType.php index 46820cb..6c26560 100644 --- a/src/SAML11/XML/saml/AbstractAttributeStatementType.php +++ b/src/SAML11/XML/saml/AbstractAttributeStatementType.php @@ -4,13 +4,15 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; use SimpleSAML\XMLSchema\Exception\MissingElementException; use SimpleSAML\XMLSchema\Exception\SchemaViolationException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; +use function array_last; + /** * SAML AttributeStatementType abstract data type. * @@ -51,7 +53,7 @@ public function getAttributes(): array * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -61,7 +63,7 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($subject, 1, TooManyElementsException::class); return new static( - array_pop($subject), + array_last($subject), Attribute::getChildrenOfClass($xml), ); } @@ -70,7 +72,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this AttributeStatementType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/SAML11/XML/saml/AbstractAttributeType.php b/src/SAML11/XML/saml/AbstractAttributeType.php index 12211a2..5d206eb 100644 --- a/src/SAML11/XML/saml/AbstractAttributeType.php +++ b/src/SAML11/XML/saml/AbstractAttributeType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\Type\SAMLStringValue; @@ -53,7 +53,7 @@ public function getAttributeValue(): array * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -69,7 +69,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this AttributeType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/SAML11/XML/saml/AbstractAudienceRestrictionConditionType.php b/src/SAML11/XML/saml/AbstractAudienceRestrictionConditionType.php index b6391f5..8da05ac 100644 --- a/src/SAML11/XML/saml/AbstractAudienceRestrictionConditionType.php +++ b/src/SAML11/XML/saml/AbstractAudienceRestrictionConditionType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; use SimpleSAML\XMLSchema\Exception\MissingElementException; @@ -44,7 +44,7 @@ public function getAudience(): array * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); @@ -61,7 +61,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this AudienceRestrictionCondition to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractAuthenticationStatementType.php b/src/SAML11/XML/saml/AbstractAuthenticationStatementType.php index 9ca4d14..c513e99 100644 --- a/src/SAML11/XML/saml/AbstractAuthenticationStatementType.php +++ b/src/SAML11/XML/saml/AbstractAuthenticationStatementType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\Type\SAMLDateTimeValue; @@ -13,6 +13,8 @@ use SimpleSAML\XMLSchema\Exception\SchemaViolationException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; +use function array_last; + /** * SAML AuthenticationStatementType abstract data type. * @@ -92,7 +94,7 @@ public function getAuthenticationInstant(): SAMLDateTimeValue * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -106,10 +108,10 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($subject, 1, TooManyElementsException::class); return new static( - array_pop($subject), + array_last($subject), self::getAttribute($xml, 'AuthenticationMethod', SAMLAnyURIValue::class), self::getAttribute($xml, 'AuthenticationInstant', SAMLDateTimeValue::class), - array_pop($subjectLocality), + array_last($subjectLocality), $authorityBinding, ); } @@ -118,7 +120,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this AuthenticationStatementType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/SAML11/XML/saml/AbstractAuthorityBindingType.php b/src/SAML11/XML/saml/AbstractAuthorityBindingType.php index 4586940..3ced255 100644 --- a/src/SAML11/XML/saml/AbstractAuthorityBindingType.php +++ b/src/SAML11/XML/saml/AbstractAuthorityBindingType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -73,7 +73,7 @@ public function getBinding(): SAMLAnyURIValue * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -89,7 +89,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this AuthorityBindingType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractAuthorizationDecisionStatementType.php b/src/SAML11/XML/saml/AbstractAuthorizationDecisionStatementType.php index ff89a65..42f2dc0 100644 --- a/src/SAML11/XML/saml/AbstractAuthorizationDecisionStatementType.php +++ b/src/SAML11/XML/saml/AbstractAuthorizationDecisionStatementType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\DecisionTypeValue; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -13,6 +13,7 @@ use SimpleSAML\XMLSchema\Exception\TooManyElementsException; use SimpleSAML\XMLSchema\Type\AnyURIValue; +use function array_last; use function strval; /** @@ -96,7 +97,7 @@ public function getAction(): array * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -109,11 +110,11 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($evidence, 1, TooManyElementsException::class); return new static( - array_pop($subject), + array_last($subject), self::getAttribute($xml, 'Resource', AnyURIValue::class), self::getAttribute($xml, 'Decision', DecisionTypeValue::class), Action::getChildrenOfClass($xml), - array_pop($evidence), + array_last($evidence), ); } @@ -121,7 +122,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this AuthorizationDecisionStatementType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/SAML11/XML/saml/AbstractCondition.php b/src/SAML11/XML/saml/AbstractCondition.php index 9ee64ee..e347e28 100644 --- a/src/SAML11/XML/saml/AbstractCondition.php +++ b/src/SAML11/XML/saml/AbstractCondition.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Constants as C; use SimpleSAML\SAML11\Utils; @@ -63,7 +63,7 @@ public function getXsiType(): QNameValue * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Condition', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, C::NS_SAML, InvalidDOMElementException::class); @@ -94,7 +94,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Condition to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); if (!$e->lookupPrefix($this->getXsiType()->getNamespaceURI()->getValue())) { diff --git a/src/SAML11/XML/saml/AbstractConditionsType.php b/src/SAML11/XML/saml/AbstractConditionsType.php index cd8e6d7..8c6b728 100644 --- a/src/SAML11/XML/saml/AbstractConditionsType.php +++ b/src/SAML11/XML/saml/AbstractConditionsType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLDateTimeValue; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -114,7 +114,7 @@ public function isEmptyElement(): bool * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -132,7 +132,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this ConditionsType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractDoNotCacheConditionType.php b/src/SAML11/XML/saml/AbstractDoNotCacheConditionType.php index 2f0b36c..182a72d 100644 --- a/src/SAML11/XML/saml/AbstractDoNotCacheConditionType.php +++ b/src/SAML11/XML/saml/AbstractDoNotCacheConditionType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -29,7 +29,7 @@ final public function __construct() * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); @@ -41,7 +41,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this DoNotCacheCondition to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { return $this->instantiateParentElement($parent); } diff --git a/src/SAML11/XML/saml/AbstractEvidenceType.php b/src/SAML11/XML/saml/AbstractEvidenceType.php index 6eae7e6..ce4c438 100644 --- a/src/SAML11/XML/saml/AbstractEvidenceType.php +++ b/src/SAML11/XML/saml/AbstractEvidenceType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Constants as C; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -72,7 +72,7 @@ public function isEmptyElement(): bool * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -87,7 +87,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this EvidenceType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractNameIdentifierType.php b/src/SAML11/XML/saml/AbstractNameIdentifierType.php index e95e95d..bdf8a0f 100644 --- a/src/SAML11/XML/saml/AbstractNameIdentifierType.php +++ b/src/SAML11/XML/saml/AbstractNameIdentifierType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\Type\SAMLStringValue; @@ -73,7 +73,7 @@ public function getNameQualifier(): ?SAMLStringValue * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -89,7 +89,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this NameIdentifierType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); $e->textContent = strval($this->getValue()); diff --git a/src/SAML11/XML/saml/AbstractStatement.php b/src/SAML11/XML/saml/AbstractStatement.php index e3dfe99..5a19471 100644 --- a/src/SAML11/XML/saml/AbstractStatement.php +++ b/src/SAML11/XML/saml/AbstractStatement.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Constants as C; use SimpleSAML\SAML11\Utils; @@ -63,7 +63,7 @@ public function getXsiType(): QNameValue * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Statement', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, C::NS_SAML, InvalidDOMElementException::class); @@ -94,7 +94,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Statement to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractSubjectConfirmationType.php b/src/SAML11/XML/saml/AbstractSubjectConfirmationType.php index 98f7046..5978a0e 100644 --- a/src/SAML11/XML/saml/AbstractSubjectConfirmationType.php +++ b/src/SAML11/XML/saml/AbstractSubjectConfirmationType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; use SimpleSAML\XMLSchema\Exception\MissingElementException; @@ -12,6 +12,8 @@ use SimpleSAML\XMLSchema\Exception\TooManyElementsException; use SimpleSAML\XMLSecurity\XML\ds\KeyInfo; +use function array_last; + /** * SAML SubjectConfirmationType abstract data type. * @@ -75,7 +77,7 @@ public function getKeyInfo(): ?KeyInfo * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -88,8 +90,8 @@ public static function fromXML(DOMElement $xml): static return new static( ConfirmationMethod::getChildrenOfClass($xml), - array_pop($subjectConfirmationData), - array_pop($keyInfo), + array_last($subjectConfirmationData), + array_last($keyInfo), ); } @@ -97,7 +99,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this SubjectConfirmationType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractSubjectLocalityType.php b/src/SAML11/XML/saml/AbstractSubjectLocalityType.php index bf5a7ac..4410dd8 100644 --- a/src/SAML11/XML/saml/AbstractSubjectLocalityType.php +++ b/src/SAML11/XML/saml/AbstractSubjectLocalityType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLStringValue; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -69,7 +69,7 @@ public function isEmptyElement(): bool * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -84,7 +84,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this SubjectLocalityType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractSubjectStatement.php b/src/SAML11/XML/saml/AbstractSubjectStatement.php index 1038b22..2a1417d 100644 --- a/src/SAML11/XML/saml/AbstractSubjectStatement.php +++ b/src/SAML11/XML/saml/AbstractSubjectStatement.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Constants as C; use SimpleSAML\SAML11\Utils; @@ -19,6 +19,8 @@ use SimpleSAML\XMLSchema\Exception\TooManyElementsException; use SimpleSAML\XMLSchema\Type\QNameValue; +use function array_last; + /** * Class implementing the extension point. * @@ -60,7 +62,7 @@ public function getXsiType(): QNameValue * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'SubjectStatement', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, C::NS_SAML, InvalidDOMElementException::class); @@ -80,7 +82,7 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($subject, 1, TooManyElementsException::class); // we don't have a handler, proceed with unknown SubjectStatement - return new UnknownSubjectStatement(new Chunk($xml), $type, array_pop($subject)); + return new UnknownSubjectStatement(new Chunk($xml), $type, array_last($subject)); } Assert::subclassOf( @@ -95,7 +97,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this SubjectStatement to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/SAML11/XML/saml/AbstractSubjectStatementType.php b/src/SAML11/XML/saml/AbstractSubjectStatementType.php index c57e4e8..38fb57e 100644 --- a/src/SAML11/XML/saml/AbstractSubjectStatementType.php +++ b/src/SAML11/XML/saml/AbstractSubjectStatementType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; /** * @package simplesamlphp\saml11 @@ -36,7 +36,7 @@ public function getSubject(): Subject /** * Convert this SubjectStatement to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AbstractSubjectType.php b/src/SAML11/XML/saml/AbstractSubjectType.php index a99d4b1..b5d33db 100644 --- a/src/SAML11/XML/saml/AbstractSubjectType.php +++ b/src/SAML11/XML/saml/AbstractSubjectType.php @@ -4,12 +4,14 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; use SimpleSAML\XMLSchema\Exception\MissingElementException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; +use function array_last; + /** * SAML SubjectType abstract data type. * @@ -61,7 +63,7 @@ public function getNameIdentifier(): ?NameIdentifier * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -73,8 +75,8 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($nameIdentifier, 1, TooManyElementsException::class); return new static( - array_pop($subjectConfirmation), - array_pop($nameIdentifier), + array_last($subjectConfirmation), + array_last($nameIdentifier), ); } @@ -82,7 +84,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this SubjectType to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/AttributeDesignator.php b/src/SAML11/XML/saml/AttributeDesignator.php index 069a6af..9275cd2 100644 --- a/src/SAML11/XML/saml/AttributeDesignator.php +++ b/src/SAML11/XML/saml/AttributeDesignator.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\Type\SAMLStringValue; @@ -28,7 +28,7 @@ final class AttributeDesignator extends AbstractAttributeDesignatorType implemen * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); diff --git a/src/SAML11/XML/saml/AttributeValue.php b/src/SAML11/XML/saml/AttributeValue.php index fe948cd..3a70f40 100644 --- a/src/SAML11/XML/saml/AttributeValue.php +++ b/src/SAML11/XML/saml/AttributeValue.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLDateTimeValue; use SimpleSAML\SAML11\Type\SAMLStringValue; @@ -37,7 +37,7 @@ class AttributeValue extends AbstractSamlElement implements SchemaValidatableEle * Create an AttributeValue. * * @param \SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface|\SimpleSAML\XML\AbstractElement $value - * @throws \SimpleSAML\Assert\AssertionFailedException if the supplied value is neither a string or a DOMElement + * @throws \SimpleSAML\Assert\AssertionFailedException if the supplied value is neither a string or a Dom\Element */ final public function __construct( protected SAMLStringValue|IntegerValue|SAMLDateTimeValue|AbstractElement $value, @@ -89,7 +89,7 @@ public function getValue() * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -139,7 +139,7 @@ public static function fromXML(DOMElement $xml): static /** * Append this attribute value to an element. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::instantiateParentElement($parent); diff --git a/src/SAML11/XML/saml/SubjectConfirmationData.php b/src/SAML11/XML/saml/SubjectConfirmationData.php index 90e2df9..80e5209 100644 --- a/src/SAML11/XML/saml/SubjectConfirmationData.php +++ b/src/SAML11/XML/saml/SubjectConfirmationData.php @@ -4,15 +4,18 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; +use SimpleSAML\SAML11\Constants as C; use SimpleSAML\SAML11\Type\SAMLStringValue; use SimpleSAML\XML\AbstractElement; +use SimpleSAML\XML\Attribute as XMLAttribute; use SimpleSAML\XML\Chunk; use SimpleSAML\XML\SchemaValidatableElementInterface; use SimpleSAML\XML\SchemaValidatableElementTrait; use SimpleSAML\XMLSchema\Constants as C_XSI; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; +use SimpleSAML\XMLSchema\Type\AnyURIValue; use SimpleSAML\XMLSchema\Type\IntegerValue; use SimpleSAML\XMLSchema\Type\Interface\ValueTypeInterface; @@ -41,7 +44,7 @@ class SubjectConfirmationData extends AbstractSamlElement implements SchemaValid * - null * - \SimpleSAML\XML\AbstractElement * - * @throws \SimpleSAML\Assert\AssertionFailedException if the supplied value is neither a string or a DOMElement + * @throws \SimpleSAML\Assert\AssertionFailedException if the supplied value is neither a string or a Dom\Element */ final public function __construct( protected SAMLStringValue|IntegerValue|null|AbstractElement $value, @@ -92,7 +95,7 @@ public function getValue(): SAMLStringValue|IntegerValue|AbstractElement|null * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); @@ -136,7 +139,7 @@ public static function fromXML(DOMElement $xml): static /** * Append this attribute value to an element. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::instantiateParentElement($parent); @@ -146,21 +149,41 @@ public function toXML(?DOMElement $parent = null): DOMElement switch ($type) { case "integer": // make sure that the xs namespace is available in the SubjectConfirmationData - $e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', C_XSI::NS_XSI); - $e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xs', C_XSI::NS_XS); + $xsi_attr = new XMLAttribute(C::NS_XMLNS, 'xmlns', 'xsi', AnyURIValue::fromString(C_XSI::NS_XSI)); + $xsi_attr->toXML($e); + + $xs_attr = new XMLAttribute(C::NS_XMLNS, 'xmlns', 'xs', AnyURIValue::fromString(C_XSI::NS_XS)); + $xs_attr->toXML($e); + $e->setAttributeNS(C_XSI::NS_XSI, 'xsi:type', 'xs:integer'); $e->textContent = strval($value); break; case "NULL": - $e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', C_XSI::NS_XSI); + $xs_attr = new XMLAttribute(C::NS_XMLNS, 'xmlns', 'xs', AnyURIValue::fromString(C_XSI::NS_XS)); + $xs_attr->toXML($e); + $e->setAttributeNS(C_XSI::NS_XSI, 'xsi:nil', '1'); $e->textContent = ''; break; case "object": if ($value instanceof ValueTypeInterface) { if ($this->value instanceof IntegerValue) { - $e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', C_XSI::NS_XSI); - $e->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xs', C_XSI::NS_XS); + $xsi_attr = new XMLAttribute( + C::NS_XMLNS, + 'xmlns', + 'xsi', + AnyURIValue::fromString(C_XSI::NS_XSI), + ); + $xsi_attr->toXML($e); + + $xs_attr = new XMLAttribute( + C::NS_XMLNS, + 'xmlns', + 'xs', + AnyURIValue::fromString(C_XSI::NS_XS), + ); + $xs_attr->toXML($e); + $e->setAttributeNS(C_XSI::NS_XSI, 'xsi:type', 'xs:integer'); } $e->textContent = strval($value); diff --git a/src/SAML11/XML/saml/UnknownCondition.php b/src/SAML11/XML/saml/UnknownCondition.php index 1a02db0..106cbc8 100644 --- a/src/SAML11/XML/saml/UnknownCondition.php +++ b/src/SAML11/XML/saml/UnknownCondition.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\XML\Chunk; use SimpleSAML\XMLSchema\Type\QNameValue; @@ -41,7 +41,7 @@ public function getRawCondition(): Chunk /** * Convert this unknown condition to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { return $this->getRawCondition()->toXML($parent); } diff --git a/src/SAML11/XML/saml/UnknownStatement.php b/src/SAML11/XML/saml/UnknownStatement.php index aa64f44..3024491 100644 --- a/src/SAML11/XML/saml/UnknownStatement.php +++ b/src/SAML11/XML/saml/UnknownStatement.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\XML\Chunk; use SimpleSAML\XMLSchema\Type\QNameValue; @@ -41,7 +41,7 @@ public function getRawStatement(): Chunk /** * Convert this unknown statement to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { return $this->getRawStatement()->toXML($parent); } diff --git a/src/SAML11/XML/saml/UnknownSubjectStatement.php b/src/SAML11/XML/saml/UnknownSubjectStatement.php index 679c1d2..e5b33cc 100644 --- a/src/SAML11/XML/saml/UnknownSubjectStatement.php +++ b/src/SAML11/XML/saml/UnknownSubjectStatement.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\saml; -use DOMElement; +use Dom; use SimpleSAML\XML\Chunk; use SimpleSAML\XMLSchema\Type\QNameValue; @@ -42,7 +42,7 @@ public function getRawSubjectStatement(): Chunk /** * Convert this unknown SubjectStatement to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { return $this->getRawSubjectStatement()->toXML($parent); } diff --git a/src/SAML11/XML/samlp/AbstractAttributeQueryType.php b/src/SAML11/XML/samlp/AbstractAttributeQueryType.php index f90aaa7..2c6b538 100644 --- a/src/SAML11/XML/samlp/AbstractAttributeQueryType.php +++ b/src/SAML11/XML/samlp/AbstractAttributeQueryType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\XML\saml\AttributeDesignator; use SimpleSAML\SAML11\XML\saml\Subject; @@ -59,7 +59,7 @@ public function getAttributeDesignator(): array /** * Convert this AttributeQuery to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/src/SAML11/XML/samlp/AbstractAuthenticationQueryType.php b/src/SAML11/XML/samlp/AbstractAuthenticationQueryType.php index 77c21b5..2178857 100644 --- a/src/SAML11/XML/samlp/AbstractAuthenticationQueryType.php +++ b/src/SAML11/XML/samlp/AbstractAuthenticationQueryType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\XML\saml\Subject; @@ -43,7 +43,7 @@ public function getAuthenticationMethod(): SAMLAnyURIValue /** * Convert this AuthenticationQuery to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); $e->setAttribute('AuthenticationMethod', strval($this->getAuthenticationMethod())); diff --git a/src/SAML11/XML/samlp/AbstractAuthorizationDecisionQueryType.php b/src/SAML11/XML/samlp/AbstractAuthorizationDecisionQueryType.php index f099f99..2a956af 100644 --- a/src/SAML11/XML/samlp/AbstractAuthorizationDecisionQueryType.php +++ b/src/SAML11/XML/samlp/AbstractAuthorizationDecisionQueryType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\XML\saml\Action; @@ -73,7 +73,7 @@ public function getAction(): array /** * Convert this AttributeQuery to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); $e->setAttribute('Resource', strval($this->getResource())); diff --git a/src/SAML11/XML/samlp/AbstractMessage.php b/src/SAML11/XML/samlp/AbstractMessage.php index dfabbb2..af4af0d 100644 --- a/src/SAML11/XML/samlp/AbstractMessage.php +++ b/src/SAML11/XML/samlp/AbstractMessage.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Type\SAMLDateTimeValue; use SimpleSAML\SAML11\XML\CanonicalizableElementTrait; use SimpleSAML\SAML11\XML\SignableElementTrait; @@ -41,7 +41,7 @@ abstract class AbstractMessage extends AbstractSamlpElement implements /** * The original signed XML */ - protected DOMElement $xml; + protected Dom\Element $xml; /** @@ -106,7 +106,7 @@ public function isMessageConstructedWithSignature(): bool /** * Get the XML element. */ - public function getXML(): DOMElement + public function getXML(): Dom\Element { return $this->xml; } @@ -115,7 +115,7 @@ public function getXML(): DOMElement /** * Set the XML element. */ - protected function setXML(DOMElement $xml): void + protected function setXML(Dom\Element $xml): void { $this->xml = $xml; } @@ -123,7 +123,7 @@ protected function setXML(DOMElement $xml): void /** */ - protected function getOriginalXML(): DOMElement + protected function getOriginalXML(): Dom\Element { return $this->xml ?? $this->toUnsignedXML(); } @@ -133,7 +133,7 @@ protected function getOriginalXML(): DOMElement * Convert this message to an unsigned XML document. * This method does not sign the resulting XML document. */ - protected function toUnsignedXML(?DOMElement $parent = null): DOMElement + protected function toUnsignedXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/samlp/AbstractQuery.php b/src/SAML11/XML/samlp/AbstractQuery.php index 87f9084..8328b9b 100644 --- a/src/SAML11/XML/samlp/AbstractQuery.php +++ b/src/SAML11/XML/samlp/AbstractQuery.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Constants as C; use SimpleSAML\SAML11\Utils; @@ -52,7 +52,7 @@ protected function __construct( * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Query', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, C::NS_SAMLP, InvalidDOMElementException::class); @@ -83,7 +83,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Query to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/samlp/AbstractRequestAbstractType.php b/src/SAML11/XML/samlp/AbstractRequestAbstractType.php index cd7b0d5..7a35655 100644 --- a/src/SAML11/XML/samlp/AbstractRequestAbstractType.php +++ b/src/SAML11/XML/samlp/AbstractRequestAbstractType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLDateTimeValue; use SimpleSAML\SAML11\Utils\XPath; @@ -12,7 +12,7 @@ use SimpleSAML\XMLSchema\Type\IDValue; use SimpleSAML\XMLSchema\Type\NonNegativeIntegerValue; -use function array_pop; +use function array_last; use function strval; /** @@ -70,7 +70,7 @@ public function getRespondWith(): array * Convert this message to an unsigned XML document. * This method does not sign the resulting XML document. */ - protected function toUnsignedXML(?DOMElement $parent = null): DOMElement + protected function toUnsignedXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toUnsignedXML($parent); $e->setAttribute('RequestID', strval($this->getID())); @@ -86,7 +86,7 @@ protected function toUnsignedXML(?DOMElement $parent = null): DOMElement /** * Create XML from this class */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { if ($this->isSigned() === true && $this->signer === null) { // We already have a signed document and no signer was set to re-sign it @@ -107,7 +107,7 @@ public function toXML(?DOMElement $parent = null): DOMElement // Test for an RespondWith $messageElements = XPath::xpQuery($signedXML, './saml_protocol:RespondWith', XPath::getXPath($signedXML)); - $respondWith = array_pop($messageElements); + $respondWith = array_last($messageElements); if ($respondWith === null) { $signedXML->appendChild($this->signature?->toXML($signedXML)); diff --git a/src/SAML11/XML/samlp/AbstractRequestType.php b/src/SAML11/XML/samlp/AbstractRequestType.php index f979133..ef9b829 100644 --- a/src/SAML11/XML/samlp/AbstractRequestType.php +++ b/src/SAML11/XML/samlp/AbstractRequestType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLDateTimeValue; use SimpleSAML\SAML11\XML\saml\AssertionIDReference; @@ -12,7 +12,7 @@ use SimpleSAML\XMLSchema\Type\IDValue; use SimpleSAML\XMLSchema\Type\NonNegativeIntegerValue; -use function array_pop; +use function array_last; use function is_array; /** @@ -49,7 +49,7 @@ protected function __construct( if (is_array($request)) { Assert::minCount($request, 1, SchemaViolationException::class); - $req = array_pop($request); + $req = array_last($request); if ($req instanceof AssertionIDReference) { Assert::allIsInstanceOf($request, AssertionIDReference::class, SchemaViolationException::class); } elseif ($req instanceof AssertionArtifact) { @@ -82,7 +82,7 @@ public function getRequest(): AbstractQueryAbstractType|array * Convert this message to an unsigned XML document. * This method does not sign the resulting XML document. */ - protected function toUnsignedXML(?DOMElement $parent = null): DOMElement + protected function toUnsignedXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toUnsignedXML($parent); diff --git a/src/SAML11/XML/samlp/AbstractResponseAbstractType.php b/src/SAML11/XML/samlp/AbstractResponseAbstractType.php index c67f6c5..881d552 100644 --- a/src/SAML11/XML/samlp/AbstractResponseAbstractType.php +++ b/src/SAML11/XML/samlp/AbstractResponseAbstractType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Type\SAMLDateTimeValue; use SimpleSAML\XMLSchema\Type\IDValue; use SimpleSAML\XMLSchema\Type\NonNegativeIntegerValue; @@ -56,7 +56,7 @@ public function getID(): IDValue * Convert this message to an unsigned XML document. * This method does not sign the resulting XML document. */ - protected function toUnsignedXML(?DOMElement $parent = null): DOMElement + protected function toUnsignedXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toUnsignedXML($parent); $e->setAttribute('ResponseID', strval($this->getId())); @@ -68,7 +68,7 @@ protected function toUnsignedXML(?DOMElement $parent = null): DOMElement /** * Create XML from this class */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { if ($this->isSigned() === true && $this->signer === null) { // We already have a signed document and no signer was set to re-sign it diff --git a/src/SAML11/XML/samlp/AbstractResponseType.php b/src/SAML11/XML/samlp/AbstractResponseType.php index ea2e7f0..b504d88 100644 --- a/src/SAML11/XML/samlp/AbstractResponseType.php +++ b/src/SAML11/XML/samlp/AbstractResponseType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\Type\SAMLDateTimeValue; @@ -102,7 +102,7 @@ public function getStatus(): Status * Convert this message to an unsigned XML document. * This method does not sign the resulting XML document. */ - protected function toUnsignedXML(?DOMElement $parent = null): DOMElement + protected function toUnsignedXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toUnsignedXML($parent); diff --git a/src/SAML11/XML/samlp/AbstractStatusCodeType.php b/src/SAML11/XML/samlp/AbstractStatusCodeType.php index 1994075..bd76338 100644 --- a/src/SAML11/XML/samlp/AbstractStatusCodeType.php +++ b/src/SAML11/XML/samlp/AbstractStatusCodeType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Constants as C; use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; @@ -65,7 +65,7 @@ public function getSubCodes(): array * @throws \SimpleSAML\XML\Exception\MissingAttributeException * if the supplied element is missing one of the mandatory attributes */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'StatusCode', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, StatusCode::NS, InvalidDOMElementException::class); @@ -83,7 +83,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this StatusCode to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); $e->setAttribute('Value', strval($this->getValue())); diff --git a/src/SAML11/XML/samlp/AbstractStatusDetailType.php b/src/SAML11/XML/samlp/AbstractStatusDetailType.php index 9740715..299196d 100644 --- a/src/SAML11/XML/samlp/AbstractStatusDetailType.php +++ b/src/SAML11/XML/samlp/AbstractStatusDetailType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\XML\Chunk; use SimpleSAML\XML\ExtendableElementTrait; @@ -51,14 +51,14 @@ public function isEmptyElement(): bool * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'StatusDetail', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, StatusDetail::NS, InvalidDOMElementException::class); $details = []; foreach ($xml->childNodes as $detail) { - if (!($detail instanceof DOMElement)) { + if (!($detail instanceof Dom\Element)) { continue; } @@ -72,7 +72,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this StatusDetail to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/samlp/AbstractStatusType.php b/src/SAML11/XML/samlp/AbstractStatusType.php index 66f88d2..d7acc82 100644 --- a/src/SAML11/XML/samlp/AbstractStatusType.php +++ b/src/SAML11/XML/samlp/AbstractStatusType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Constants as C; use SimpleSAML\SAML11\Exception\ProtocolViolationException; @@ -12,7 +12,7 @@ use SimpleSAML\XMLSchema\Exception\MissingElementException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; -use function array_pop; +use function array_last; /** * SAML Status data type. @@ -85,7 +85,7 @@ public function getStatusDetail(): ?StatusDetail * @throws \SimpleSAML\XML\Exception\MissingElementException * if one of the mandatory child-elements is missing */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Status', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Status::NS, InvalidDOMElementException::class); @@ -100,9 +100,9 @@ public static function fromXML(DOMElement $xml): static $statusDetail = StatusDetail::getChildrenOfClass($xml); return new static( - array_pop($statusCode), - array_pop($statusMessage), - array_pop($statusDetail), + array_last($statusCode), + array_last($statusMessage), + array_last($statusDetail), ); } @@ -110,7 +110,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Status to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/samlp/AbstractSubjectQuery.php b/src/SAML11/XML/samlp/AbstractSubjectQuery.php index 6d668b5..f736809 100644 --- a/src/SAML11/XML/samlp/AbstractSubjectQuery.php +++ b/src/SAML11/XML/samlp/AbstractSubjectQuery.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Constants as C; use SimpleSAML\SAML11\Utils; @@ -21,7 +21,7 @@ use SimpleSAML\XMLSchema\Exception\TooManyElementsException; use SimpleSAML\XMLSchema\Type\QNameValue; -use function array_pop; +use function array_last; /** * SAMLP Query data type. @@ -58,7 +58,7 @@ protected function __construct( * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'SubjectQuery', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, C::NS_SAMLP, InvalidDOMElementException::class); @@ -78,7 +78,7 @@ public static function fromXML(DOMElement $xml): static Assert::maxCount($subject, 1, TooManyElementsException::class); // we don't have a handler, proceed with unknown query - return new UnknownSubjectQuery(new Chunk($xml), $type, array_pop($subject)); + return new UnknownSubjectQuery(new Chunk($xml), $type, array_last($subject)); } Assert::subclassOf( diff --git a/src/SAML11/XML/samlp/AbstractSubjectQueryAbstractType.php b/src/SAML11/XML/samlp/AbstractSubjectQueryAbstractType.php index 8add9cf..79a8fa2 100644 --- a/src/SAML11/XML/samlp/AbstractSubjectQueryAbstractType.php +++ b/src/SAML11/XML/samlp/AbstractSubjectQueryAbstractType.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\XML\saml\Subject; /** @@ -37,7 +37,7 @@ public function getSubject(): Subject /** * Convert this SubjectQuery to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/src/SAML11/XML/samlp/AttributeQuery.php b/src/SAML11/XML/samlp/AttributeQuery.php index 2240557..3b8eeb3 100644 --- a/src/SAML11/XML/samlp/AttributeQuery.php +++ b/src/SAML11/XML/samlp/AttributeQuery.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\XML\saml\AttributeDesignator; @@ -15,7 +15,7 @@ use SimpleSAML\XMLSchema\Exception\MissingElementException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; -use function array_pop; +use function array_last; /** * Class representing a samlp:AttributeQuery element. @@ -33,7 +33,7 @@ final class AttributeQuery extends AbstractAttributeQueryType implements SchemaV * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'AttributeQuery', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, AttributeQuery::NS, InvalidDOMElementException::class); @@ -46,6 +46,6 @@ public static function fromXML(DOMElement $xml): static $attributeDesignator = AttributeDesignator::getChildrenOfClass($xml); - return new static(array_pop($subject), $resource, $attributeDesignator); + return new static(array_last($subject), $resource, $attributeDesignator); } } diff --git a/src/SAML11/XML/samlp/AuthenticationQuery.php b/src/SAML11/XML/samlp/AuthenticationQuery.php index 9d9f28a..3a8d45e 100644 --- a/src/SAML11/XML/samlp/AuthenticationQuery.php +++ b/src/SAML11/XML/samlp/AuthenticationQuery.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\XML\saml\Subject; @@ -14,7 +14,7 @@ use SimpleSAML\XMLSchema\Exception\MissingElementException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; -use function array_pop; +use function array_last; /** * Class representing a samlp:AuthenticationQuery element. @@ -32,7 +32,7 @@ final class AuthenticationQuery extends AbstractAuthenticationQueryType implemen * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'AuthenticationQuery', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, AuthenticationQuery::NS, InvalidDOMElementException::class); @@ -43,6 +43,6 @@ public static function fromXML(DOMElement $xml): static Assert::minCount($subject, 1, MissingElementException::class); Assert::maxCount($subject, 1, TooManyElementsException::class); - return new static(array_pop($subject), $authenticationMethod); + return new static(array_last($subject), $authenticationMethod); } } diff --git a/src/SAML11/XML/samlp/AuthorizationDecisionQuery.php b/src/SAML11/XML/samlp/AuthorizationDecisionQuery.php index 1d59e17..bfeb7b5 100644 --- a/src/SAML11/XML/samlp/AuthorizationDecisionQuery.php +++ b/src/SAML11/XML/samlp/AuthorizationDecisionQuery.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; use SimpleSAML\SAML11\XML\saml\Action; @@ -16,7 +16,7 @@ use SimpleSAML\XMLSchema\Exception\MissingElementException; use SimpleSAML\XMLSchema\Exception\TooManyElementsException; -use function array_pop; +use function array_last; /** * Class representing a samlp:AuthorizationDecisionQuery element. @@ -35,7 +35,7 @@ final class AuthorizationDecisionQuery extends AbstractAuthorizationDecisionQuer * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'AuthorizationDecisionQuery', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, AuthorizationDecisionQuery::NS, InvalidDOMElementException::class); @@ -52,6 +52,6 @@ public static function fromXML(DOMElement $xml): static $evidence = Evidence::getChildrenOfClass($xml); Assert::maxCount($evidence, 1, TooManyElementsException::class); - return new static(array_pop($subject), $resource, array_pop($evidence), $action); + return new static(array_last($subject), $resource, array_last($evidence), $action); } } diff --git a/src/SAML11/XML/samlp/Request.php b/src/SAML11/XML/samlp/Request.php index aa516f4..de8a9d5 100644 --- a/src/SAML11/XML/samlp/Request.php +++ b/src/SAML11/XML/samlp/Request.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\Exception\VersionMismatchException; use SimpleSAML\SAML11\Type\SAMLDateTimeValue; @@ -15,8 +15,8 @@ use SimpleSAML\XMLSchema\Type\IDValue; use SimpleSAML\XMLSchema\Type\NonNegativeIntegerValue; +use function array_last; use function array_merge; -use function array_pop; /** * Class representing a samlp:Request element. @@ -35,7 +35,7 @@ final class Request extends AbstractRequestType * @throws \SimpleSAML\XML\Exception\MissingElementException * if one of the mandatory child-elements is missing */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Request', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Request::NS, InvalidDOMElementException::class); @@ -85,7 +85,7 @@ public static function fromXML(DOMElement $xml): static $issueInstant = self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class); return new static( - $assertionIdReference ?: $assertionArtifact ?: array_pop($query), + $assertionIdReference ?: $assertionArtifact ?: array_last($query), self::getAttribute($xml, 'RequestID', IDValue::class), $majorVersion, $minorVersion, diff --git a/src/SAML11/XML/samlp/Response.php b/src/SAML11/XML/samlp/Response.php index fcbc95d..66b025c 100644 --- a/src/SAML11/XML/samlp/Response.php +++ b/src/SAML11/XML/samlp/Response.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\Assert\Assert; use SimpleSAML\SAML11\Exception\VersionMismatchException; use SimpleSAML\SAML11\Type\SAMLAnyURIValue; @@ -20,7 +20,7 @@ use SimpleSAML\XMLSchema\Type\NCNameValue; use SimpleSAML\XMLSchema\Type\NonNegativeIntegerValue; -use function array_pop; +use function array_last; /** * Class representing a samlp:Response element. @@ -42,7 +42,7 @@ final class Response extends AbstractResponseType implements SchemaValidatableEl * @throws \SimpleSAML\XML\Exception\MissingElementException * if one of the mandatory child-elements is missing */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Response', InvalidDOMElementException::class); Assert::same($xml->namespaceURI, Response::NS, InvalidDOMElementException::class); @@ -61,7 +61,7 @@ public static function fromXML(DOMElement $xml): static $majorVersion, $minorVersion, self::getAttribute($xml, 'ResponseID', IDValue::class), - array_pop($status), + array_last($status), self::getAttribute($xml, 'IssueInstant', SAMLDateTimeValue::class), Assertion::getChildrenOfClass($xml), self::getOptionalAttribute($xml, 'InResponseTo', NCNameValue::class, null), diff --git a/src/SAML11/XML/samlp/UnknownQuery.php b/src/SAML11/XML/samlp/UnknownQuery.php index b3436d0..3e43ac1 100644 --- a/src/SAML11/XML/samlp/UnknownQuery.php +++ b/src/SAML11/XML/samlp/UnknownQuery.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\XML\Chunk; use SimpleSAML\XMLSchema\Type\QNameValue; @@ -41,7 +41,7 @@ public function getRawQuery(): Chunk /** * Convert this unknown query to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { return $this->getRawQuery()->toXML($parent); } diff --git a/src/SAML11/XML/samlp/UnknownSubjectQuery.php b/src/SAML11/XML/samlp/UnknownSubjectQuery.php index b9611d6..c33e61c 100644 --- a/src/SAML11/XML/samlp/UnknownSubjectQuery.php +++ b/src/SAML11/XML/samlp/UnknownSubjectQuery.php @@ -4,7 +4,7 @@ namespace SimpleSAML\SAML11\XML\samlp; -use DOMElement; +use Dom; use SimpleSAML\SAML11\XML\saml\Subject; use SimpleSAML\XML\Chunk; use SimpleSAML\XMLSchema\Type\QNameValue; @@ -43,7 +43,7 @@ public function getRawSubjectQuery(): Chunk /** * Convert this unknown subject query to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { return $this->getRawSubjectQuery()->toXML($parent); } diff --git a/tests/bin/signedassertion.php b/tests/bin/signedassertion.php index 3677c22..bb48bbd 100644 --- a/tests/bin/signedassertion.php +++ b/tests/bin/signedassertion.php @@ -21,4 +21,8 @@ $unsignedAssertion = Assertion::fromXML($document->documentElement); $unsignedAssertion->sign($signer); -echo $unsignedAssertion->toXML()->ownerDocument->saveXML(); + +/** @var \Dom\XMLDocument $ownerDocument */ +$ownerDocument = $unsignedAssertion->toXML()->ownerDocument; + +echo $ownerDocument->saveXML(); diff --git a/tests/resources/schemas/simplesamlphp.xsd b/tests/resources/schemas/simplesamlphp.xsd index 56e6f00..09700f0 100644 --- a/tests/resources/schemas/simplesamlphp.xsd +++ b/tests/resources/schemas/simplesamlphp.xsd @@ -1,17 +1,7 @@ - - - - - ]> - - + @@ -129,7 +129,7 @@ - + diff --git a/tests/resources/xml/saml_Assertion.xml b/tests/resources/xml/saml_Assertion.xml index 55ce644..c7592ca 100644 --- a/tests/resources/xml/saml_Assertion.xml +++ b/tests/resources/xml/saml_Assertion.xml @@ -72,7 +72,7 @@ - + @@ -139,7 +139,7 @@ - + @@ -206,7 +206,7 @@ - + @@ -278,7 +278,7 @@ - + diff --git a/tests/resources/xml/saml_AuthenticationStatement.xml b/tests/resources/xml/saml_AuthenticationStatement.xml index f6777e6..480f369 100644 --- a/tests/resources/xml/saml_AuthenticationStatement.xml +++ b/tests/resources/xml/saml_AuthenticationStatement.xml @@ -16,5 +16,5 @@ - + diff --git a/tests/resources/xml/saml_AuthorityBinding.xml b/tests/resources/xml/saml_AuthorityBinding.xml index 8d15770..9a553bf 100644 --- a/tests/resources/xml/saml_AuthorityBinding.xml +++ b/tests/resources/xml/saml_AuthorityBinding.xml @@ -1 +1 @@ - + diff --git a/tests/resources/xml/saml_AuthorizationDecisionStatement.xml b/tests/resources/xml/saml_AuthorizationDecisionStatement.xml index 7ab7b9c..c5f69e0 100644 --- a/tests/resources/xml/saml_AuthorizationDecisionStatement.xml +++ b/tests/resources/xml/saml_AuthorizationDecisionStatement.xml @@ -68,7 +68,7 @@ - + diff --git a/tests/resources/xml/saml_Evidence.xml b/tests/resources/xml/saml_Evidence.xml index 84740a8..ba39915 100644 --- a/tests/resources/xml/saml_Evidence.xml +++ b/tests/resources/xml/saml_Evidence.xml @@ -13,13 +13,13 @@ urn:some:audience - + TheNameIDValue _Test1 _Test2 - 2 + 2 testkey @@ -38,7 +38,7 @@ _Test1 _Test2 - 2 + 2 testkey @@ -50,7 +50,7 @@ - + @@ -58,7 +58,7 @@ _Test1 _Test2 - 2 + 2 testkey diff --git a/tests/resources/xml/saml_Statement.xml b/tests/resources/xml/saml_Statement.xml index 84f9724..bc8cdad 100644 --- a/tests/resources/xml/saml_Statement.xml +++ b/tests/resources/xml/saml_Statement.xml @@ -1,3 +1,3 @@ - + urn:some:audience diff --git a/tests/resources/xml/saml_Subject.xml b/tests/resources/xml/saml_Subject.xml index 735f58d..4d6dedd 100644 --- a/tests/resources/xml/saml_Subject.xml +++ b/tests/resources/xml/saml_Subject.xml @@ -1,4 +1,4 @@ - + TheNameIDValue _Test1 diff --git a/tests/resources/xml/saml_SubjectConfirmationData.xml b/tests/resources/xml/saml_SubjectConfirmationData.xml index 98262f0..c53dbed 100644 --- a/tests/resources/xml/saml_SubjectConfirmationData.xml +++ b/tests/resources/xml/saml_SubjectConfirmationData.xml @@ -1 +1 @@ -2 +2 diff --git a/tests/resources/xml/saml_SubjectStatement.xml b/tests/resources/xml/saml_SubjectStatement.xml index 36b755a..8fb7788 100644 --- a/tests/resources/xml/saml_SubjectStatement.xml +++ b/tests/resources/xml/saml_SubjectStatement.xml @@ -1,4 +1,4 @@ - + TheNameIDValue diff --git a/tests/resources/xml/samlp_AuthorizationDecisionQuery.xml b/tests/resources/xml/samlp_AuthorizationDecisionQuery.xml index 867bd70..aeb5f29 100644 --- a/tests/resources/xml/samlp_AuthorizationDecisionQuery.xml +++ b/tests/resources/xml/samlp_AuthorizationDecisionQuery.xml @@ -43,7 +43,7 @@ - + @@ -51,7 +51,7 @@ _Test1 _Test2 - 2 + 2 testkey diff --git a/tests/resources/xml/samlp_Query.xml b/tests/resources/xml/samlp_Query.xml index 9572d6b..9245a0b 100644 --- a/tests/resources/xml/samlp_Query.xml +++ b/tests/resources/xml/samlp_Query.xml @@ -1,3 +1,3 @@ - + urn:some:audience diff --git a/tests/resources/xml/samlp_Response.xml b/tests/resources/xml/samlp_Response.xml index 638a0d1..761dcd7 100644 --- a/tests/resources/xml/samlp_Response.xml +++ b/tests/resources/xml/samlp_Response.xml @@ -1,4 +1,4 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/tests/src/SAML11/CustomCondition.php b/tests/src/SAML11/CustomCondition.php index 76f1f40..1a42447 100644 --- a/tests/src/SAML11/CustomCondition.php +++ b/tests/src/SAML11/CustomCondition.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\XML\saml\AbstractCondition; use SimpleSAML\SAML11\XML\saml\Audience; @@ -61,7 +61,7 @@ public function getAudience(): array * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Condition', InvalidDOMElementException::class); Assert::notNull($xml->namespaceURI, InvalidDOMElementException::class); @@ -84,7 +84,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Condition to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/tests/src/SAML11/CustomQuery.php b/tests/src/SAML11/CustomQuery.php index e6fb4d1..8cdcab0 100644 --- a/tests/src/SAML11/CustomQuery.php +++ b/tests/src/SAML11/CustomQuery.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\XML\samlp\AbstractQuery; use SimpleSAML\SAML11\XML\samlp\StatusMessage; @@ -61,7 +61,7 @@ public function getStatusMessage(): array * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Query', InvalidDOMElementException::class); Assert::notNull($xml->namespaceURI, InvalidDOMElementException::class); @@ -84,7 +84,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Query to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/tests/src/SAML11/CustomStatement.php b/tests/src/SAML11/CustomStatement.php index d54bc5f..6ebf8dd 100644 --- a/tests/src/SAML11/CustomStatement.php +++ b/tests/src/SAML11/CustomStatement.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\XML\saml\AbstractStatement; use SimpleSAML\SAML11\XML\saml\Audience; @@ -61,7 +61,7 @@ public function getAudience(): array * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'Statement', InvalidDOMElementException::class); Assert::notNull($xml->namespaceURI, InvalidDOMElementException::class); @@ -84,7 +84,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Statement to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/tests/src/SAML11/CustomSubjectQuery.php b/tests/src/SAML11/CustomSubjectQuery.php index 35dfdfe..088d79a 100644 --- a/tests/src/SAML11/CustomSubjectQuery.php +++ b/tests/src/SAML11/CustomSubjectQuery.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\XML\saml\Subject; use SimpleSAML\SAML11\XML\samlp\AbstractSubjectQuery; @@ -16,7 +16,7 @@ use SimpleSAML\XMLSchema\Exception\TooManyElementsException; use SimpleSAML\XMLSchema\Type\QNameValue; -use function array_pop; +use function array_last; /** * Example class to demonstrate how SubjectQuery can be extended. @@ -69,7 +69,7 @@ public function getStatusMessage(): array * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'SubjectQuery', InvalidDOMElementException::class); Assert::notNull($xml->namespaceURI, InvalidDOMElementException::class); @@ -89,14 +89,14 @@ public static function fromXML(DOMElement $xml): static Assert::minCount($subject, 1, MissingElementException::class); Assert::maxCount($subject, 1, TooManyElementsException::class); - return new static(array_pop($subject), $statusMessage); + return new static(array_last($subject), $statusMessage); } /** * Convert this SubjectQuery to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = $this->instantiateParentElement($parent); diff --git a/tests/src/SAML11/CustomSubjectStatement.php b/tests/src/SAML11/CustomSubjectStatement.php index 12b5e50..7fd5ddf 100644 --- a/tests/src/SAML11/CustomSubjectStatement.php +++ b/tests/src/SAML11/CustomSubjectStatement.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11; -use DOMElement; +use Dom; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML11\XML\saml\AbstractSubjectStatement; use SimpleSAML\SAML11\XML\saml\Audience; @@ -67,7 +67,7 @@ public function getAudience(): array * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException * if the qualified name of the supplied element is wrong */ - public static function fromXML(DOMElement $xml): static + public static function fromXML(Dom\Element $xml): static { Assert::same($xml->localName, 'SubjectStatement', InvalidDOMElementException::class); Assert::notNull($xml->namespaceURI, InvalidDOMElementException::class); @@ -87,14 +87,14 @@ public static function fromXML(DOMElement $xml): static $audience = Audience::getChildrenOfClass($xml); - return new static(array_pop($subject), $audience); + return new static(array_last($subject), $audience); } /** * Convert this SubjectStatement to XML. */ - public function toXML(?DOMElement $parent = null): DOMElement + public function toXML(?Dom\Element $parent = null): Dom\Element { $e = parent::toXML($parent); diff --git a/tests/src/SAML11/XML/saml/ActionTest.php b/tests/src/SAML11/XML/saml/ActionTest.php index 7b16e13..e3bd089 100644 --- a/tests/src/SAML11/XML/saml/ActionTest.php +++ b/tests/src/SAML11/XML/saml/ActionTest.php @@ -59,9 +59,10 @@ public function testMarshalling(): void SAMLAnyURIValue::fromString('urn:x-simplesamlphp:namespace'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($action), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($action); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/AdviceTest.php b/tests/src/SAML11/XML/saml/AdviceTest.php index f3488d8..c280ab3 100644 --- a/tests/src/SAML11/XML/saml/AdviceTest.php +++ b/tests/src/SAML11/XML/saml/AdviceTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11\XML\saml; -use DOMDocument; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -83,23 +83,23 @@ final class AdviceTest extends TestCase /** @var \SimpleSAML\XML\Chunk $chunk */ private static Chunk $chunk; - /** @var \DOMDocument $conditions */ - private static DOMDocument $conditions; + /** @var \Dom\XMLDocument $conditions */ + private static Dom\XMLDocument $conditions; - /** @var \DOMDocument $statement */ - private static DOMDocument $statement; + /** @var \Dom\XMLDocument $statement */ + private static Dom\XMLDocument $statement; - /** @var \DOMDocument $subjectStatement */ - private static DOMDocument $subjectStatement; + /** @var \Dom\XMLDocument $subjectStatement */ + private static Dom\XMLDocument $subjectStatement; - /** @var \DOMDocument $authnStatement */ - private static DOMDocument $authnStatement; + /** @var \Dom\XMLDocument $authnStatement */ + private static Dom\XMLDocument $authnStatement; - /** @var \DOMDocument $authzDecisionStatement */ -// private static DOMDocument $authzDecisionStatement; + /** @var \Dom\XMLDocument $authzDecisionStatement */ +// private static Dom\XMLDocument $authzDecisionStatement; - /** @var \DOMDocument $attributeStatement */ - private static DOMDocument $attributeStatement; + /** @var \Dom\XMLDocument $attributeStatement */ + private static Dom\XMLDocument $attributeStatement; /** @@ -264,7 +264,7 @@ public function testMarshalling(): void SAMLStringValue::fromString('simplesamlphp.org'), ); $authorityBinding = new AuthorityBinding( - QNameValue::fromString('{' . C::NS_SAMLP . '}samlp:AttributeQuery'), + QNameValue::fromString('{' . C::NS_SAMLP . '}samlp:AssertionIdReference'), SAMLAnyURIValue::fromString('urn:x-simplesamlphp:location'), SAMLAnyURIValue::fromString('urn:x-simplesamlphp:binding'), ); @@ -370,10 +370,11 @@ public function testMarshalling(): void [self::$chunk], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($advice), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($advice); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/src/SAML11/XML/saml/AssertionIDReferenceTest.php b/tests/src/SAML11/XML/saml/AssertionIDReferenceTest.php index 4e0b6ae..9f29a03 100644 --- a/tests/src/SAML11/XML/saml/AssertionIDReferenceTest.php +++ b/tests/src/SAML11/XML/saml/AssertionIDReferenceTest.php @@ -48,9 +48,10 @@ public function testMarshalling(): void { $assertionIDReference = AssertionIDReference::fromString('_Test'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($assertionIDReference), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($assertionIDReference); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/AssertionTest.php b/tests/src/SAML11/XML/saml/AssertionTest.php index bb0c375..92776c2 100644 --- a/tests/src/SAML11/XML/saml/AssertionTest.php +++ b/tests/src/SAML11/XML/saml/AssertionTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11\XML\saml; -use DOMDocument; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -83,26 +83,26 @@ final class AssertionTest extends TestCase /** @var \SimpleSAML\SAML11\Compat\AbstractContainer */ private static AbstractContainer $containerBackup; - /** @var \DOMDocument $conditions */ - private static DOMDocument $conditions; + /** @var \Dom\XMLDocument $conditions */ + private static Dom\XMLDocument $conditions; - /** @var \DOMDocument $action */ - //private static DOMDocument $action; + /** @var \Dom\XMLDocument $action */ + //private static Dom\XMLDocument $action; - /** @var \DOMDocument $statement */ - private static DOMDocument $statement; + /** @var \Dom\XMLDocument $statement */ + private static Dom\XMLDocument $statement; - /** @var \DOMDocument $subjectStatement */ - private static DOMDocument $subjectStatement; + /** @var \Dom\XMLDocument $subjectStatement */ + private static Dom\XMLDocument $subjectStatement; - /** @var \DOMDocument $authnStatement */ - private static DOMDocument $authnStatement; + /** @var \Dom\XMLDocument $authnStatement */ + private static Dom\XMLDocument $authnStatement; - /** @var \DOMDocument $authzDecisionStatement */ - private static DOMDocument $authzDecisionStatement; + /** @var \Dom\XMLDocument $authzDecisionStatement */ + private static Dom\XMLDocument $authzDecisionStatement; - /** @var \DOMDocument $attributeStatement */ - private static DOMDocument $attributeStatement; + /** @var \Dom\XMLDocument $attributeStatement */ + private static Dom\XMLDocument $attributeStatement; /** @@ -280,10 +280,11 @@ public function testMarshalling(): void ], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($assertion), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($assertion); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -409,7 +410,7 @@ private function createAuthenticationStatement(string $id): AuthenticationStatem ); $authorityBinding = new AuthorityBinding( - QNameValue::fromString('{' . C::NS_SAMLP . '}samlp:AttributeQuery'), + QNameValue::fromString('{' . C::NS_SAMLP . '}samlp:AssertionIdReference'), SAMLAnyURIValue::fromString('urn:x-simplesamlphp:location'), SAMLAnyURIValue::fromString('urn:x-simplesamlphp:binding'), ); diff --git a/tests/src/SAML11/XML/saml/AttributeDesignatorTest.php b/tests/src/SAML11/XML/saml/AttributeDesignatorTest.php index f0256a5..c3ad1a2 100644 --- a/tests/src/SAML11/XML/saml/AttributeDesignatorTest.php +++ b/tests/src/SAML11/XML/saml/AttributeDesignatorTest.php @@ -58,9 +58,10 @@ public function testMarshalling(): void SAMLAnyURIValue::fromString('https://example.org/'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($attributeDesignator), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($attributeDesignator); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/AttributeStatementTest.php b/tests/src/SAML11/XML/saml/AttributeStatementTest.php index 320d80f..d57e192 100644 --- a/tests/src/SAML11/XML/saml/AttributeStatementTest.php +++ b/tests/src/SAML11/XML/saml/AttributeStatementTest.php @@ -157,10 +157,11 @@ public function testMarshalling(): void [$attribute], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($attributeStatement), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($attributeStatement); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/src/SAML11/XML/saml/AttributeTest.php b/tests/src/SAML11/XML/saml/AttributeTest.php index 33de2ef..7b2f90e 100644 --- a/tests/src/SAML11/XML/saml/AttributeTest.php +++ b/tests/src/SAML11/XML/saml/AttributeTest.php @@ -78,9 +78,10 @@ public function testMarshalling(): void ], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($attribute), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($attribute); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/AttributeValueTest.php b/tests/src/SAML11/XML/saml/AttributeValueTest.php index e2635e2..861dc94 100644 --- a/tests/src/SAML11/XML/saml/AttributeValueTest.php +++ b/tests/src/SAML11/XML/saml/AttributeValueTest.php @@ -64,10 +64,11 @@ public function testMarshalling(): void $this->assertEquals('2', $av->getValue()); $this->assertEquals('xs:integer', $av->getXsiType()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($av), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($av); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -167,12 +168,18 @@ public function testUnmarshallingNameID(): void $this->assertEquals('abcd-some-value-xyz', $value->getValue()); $this->assertEquals('urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified', $value->getFormat()); - $this->assertXmlStringEqualsXmlString($document->saveXML(), $av->toXML()->ownerDocument?->saveXML()); + + /** @var \Dom\XMLDocument $ownerDocument */ + $ownerDocument = $av->toXML()->ownerDocument; + $this->assertXmlStringEqualsXmlString( + $document->saveXml($document->documentElement), + $ownerDocument->saveXml($ownerDocument->documentElement), + ); } /** - * Verifies that we cannot create an AttributeValue that is nullable, like SAML2 allows, but SAML1.1 does not. + * Verifies that we cannot create an AttributeValue that is nullable, like SAML 2.0 allows, but SAML1.1 does not. * * @return void */ diff --git a/tests/src/SAML11/XML/saml/AudienceRestrictionConditionTest.php b/tests/src/SAML11/XML/saml/AudienceRestrictionConditionTest.php index 5f45833..b18c8ca 100644 --- a/tests/src/SAML11/XML/saml/AudienceRestrictionConditionTest.php +++ b/tests/src/SAML11/XML/saml/AudienceRestrictionConditionTest.php @@ -56,9 +56,10 @@ public function testMarshalling(): void $audience = Audience::fromString('urn:x-simplesamlphp:audience'); $audienceRestrictionCondition = new AudienceRestrictionCondition([$audience]); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($audienceRestrictionCondition), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($audienceRestrictionCondition); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/AudienceTest.php b/tests/src/SAML11/XML/saml/AudienceTest.php index 01d2c4a..052bd13 100644 --- a/tests/src/SAML11/XML/saml/AudienceTest.php +++ b/tests/src/SAML11/XML/saml/AudienceTest.php @@ -52,9 +52,10 @@ public function testMarshalling(): void { $audience = Audience::fromString('urn:x-simplesamlphp:audience'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($audience), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($audience); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/AuthenticationStatementTest.php b/tests/src/SAML11/XML/saml/AuthenticationStatementTest.php index a1d5224..4a2c737 100644 --- a/tests/src/SAML11/XML/saml/AuthenticationStatementTest.php +++ b/tests/src/SAML11/XML/saml/AuthenticationStatementTest.php @@ -148,7 +148,7 @@ public function testMarshalling(): void ); $authorityBinding = new AuthorityBinding( - QNameValue::fromString('{' . C::NS_SAMLP . '}samlp:AttributeQuery'), + QNameValue::fromString('{' . C::NS_SAMLP . '}samlp:AssertionIdReference'), SAMLAnyURIValue::fromString('urn:x-simplesamlphp:location'), SAMLAnyURIValue::fromString('urn:x-simplesamlphp:binding'), ); @@ -161,10 +161,11 @@ public function testMarshalling(): void [$authorityBinding], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($authenticationStatement), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($authenticationStatement); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/src/SAML11/XML/saml/AuthorityBindingTest.php b/tests/src/SAML11/XML/saml/AuthorityBindingTest.php index abdbb85..e5bb3c3 100644 --- a/tests/src/SAML11/XML/saml/AuthorityBindingTest.php +++ b/tests/src/SAML11/XML/saml/AuthorityBindingTest.php @@ -58,7 +58,7 @@ public function testMarshalling(): void { $ab = new AuthorityBinding( QNameValue::fromParts( - NCNameValue::fromString('AttributeQuery'), + NCNameValue::fromString('AssertionIdReference'), SAMLAnyURIValue::fromString(C::NS_SAMLP), NCNameValue::fromString('samlp'), ), @@ -66,9 +66,10 @@ public function testMarshalling(): void SAMLAnyURIValue::fromString('urn:x-simplesamlphp:binding'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($ab), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($ab); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/AuthorizationDecisionStatementTest.php b/tests/src/SAML11/XML/saml/AuthorizationDecisionStatementTest.php index 89fcad8..1d3973b 100644 --- a/tests/src/SAML11/XML/saml/AuthorizationDecisionStatementTest.php +++ b/tests/src/SAML11/XML/saml/AuthorizationDecisionStatementTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11\XML\saml; -use DOMDocument; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -47,17 +47,17 @@ final class AuthorizationDecisionStatementTest extends TestCase /** @var \SimpleSAML\SAML11\Compat\AbstractContainer */ private static AbstractContainer $containerBackup; - /** @var \DOMDocument $action */ - private static DOMDocument $action; + /** @var \Dom\XMLDocument $action */ + private static Dom\XMLDocument $action; - /** @var \DOMDocument $advice */ -// private static DOMDocument $advice; + /** @var \Dom\XMLDocument $advice */ +// private static Dom\XMLDocument $advice; - /** @var \DOMDocument $evidence */ - private static DOMDocument $evidence; + /** @var \Dom\XMLDocument $evidence */ + private static Dom\XMLDocument $evidence; - /** @var \DOMDocument $subject */ - private static DOMDocument $subject; + /** @var \Dom\XMLDocument $subject */ + private static Dom\XMLDocument $subject; /** @@ -126,9 +126,10 @@ public function testMarshalling(): void $evidence, ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($authzDecisionStatement), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($authzDecisionStatement); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/ConditionTest.php b/tests/src/SAML11/XML/saml/ConditionTest.php index d574690..3822880 100644 --- a/tests/src/SAML11/XML/saml/ConditionTest.php +++ b/tests/src/SAML11/XML/saml/ConditionTest.php @@ -85,10 +85,11 @@ public function testMarshalling(): void ], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($condition), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($condition); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -115,6 +116,8 @@ public function testUnmarshallingUnregistered(): void $this->assertEquals('Condition', $chunk->getLocalName()); $this->assertEquals(C::NS_SAML, $chunk->getNamespaceURI()); - $this->assertEquals($element->ownerDocument?->saveXML($element), strval($condition)); + /** @var \Dom\XMLDocument $ownerDocument */ + $ownerDocument = $element->ownerDocument; + $this->assertXmlStringEqualsXmlString($ownerDocument->saveXML($element), strval($condition)); } } diff --git a/tests/src/SAML11/XML/saml/ConditionsTest.php b/tests/src/SAML11/XML/saml/ConditionsTest.php index cab7703..9ed4567 100644 --- a/tests/src/SAML11/XML/saml/ConditionsTest.php +++ b/tests/src/SAML11/XML/saml/ConditionsTest.php @@ -82,10 +82,11 @@ public function testMarshalling(): void SAMLDateTimeValue::fromString('2023-01-24T09:47:26Z'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($conditions), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($conditions); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/src/SAML11/XML/saml/ConfirmationMethodTest.php b/tests/src/SAML11/XML/saml/ConfirmationMethodTest.php index 0c11ed9..683ce4b 100644 --- a/tests/src/SAML11/XML/saml/ConfirmationMethodTest.php +++ b/tests/src/SAML11/XML/saml/ConfirmationMethodTest.php @@ -51,9 +51,10 @@ public function testMarshalling(): void SAMLAnyURIValue::fromString('_Test'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($confirmationMethod), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($confirmationMethod); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/DoNotCacheConditionTest.php b/tests/src/SAML11/XML/saml/DoNotCacheConditionTest.php index 9372333..4bc548f 100644 --- a/tests/src/SAML11/XML/saml/DoNotCacheConditionTest.php +++ b/tests/src/SAML11/XML/saml/DoNotCacheConditionTest.php @@ -52,11 +52,12 @@ public static function setUpBeforeClass(): void */ public function testMarshalling(): void { - $DoNotCacheCondition = new DoNotCacheCondition(); + $doNotCacheCondition = new DoNotCacheCondition(); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($DoNotCacheCondition), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($doNotCacheCondition); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/EvidenceTest.php b/tests/src/SAML11/XML/saml/EvidenceTest.php index 701d4aa..d627525 100644 --- a/tests/src/SAML11/XML/saml/EvidenceTest.php +++ b/tests/src/SAML11/XML/saml/EvidenceTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11\XML\saml; -use DOMDocument; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -80,17 +80,17 @@ final class EvidenceTest extends TestCase /** @var \SimpleSAML\SAML11\Compat\AbstractContainer */ private static AbstractContainer $containerBackup; - /** @var \DOMDocument $conditions */ - private static DOMDocument $conditions; + /** @var \Dom\Document $conditions */ + private static Dom\Document $conditions; - /** @var \DOMDocument $advice */ - //private static DOMDocument $advice; + /** @var \Dom\Document $advice */ + //private static Dom\Document $advice; - /** @var \DOMDocument $authzDecisionStatement */ - //private static DOMDocument $authzDecisionStatement; + /** @var \Dom\Document $authzDecisionStatement */ + //private static Dom\Document $authzDecisionStatement; - /** @var \DOMDocument $statement */ - private static DOMDocument $statement; + /** @var \Dom\Document $statement */ + private static Dom\Document $statement; /** @@ -201,10 +201,11 @@ public function testMarshalling(): void $evidence = new Evidence([$assertionIDReference], [$assertion]); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($evidence), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($evidence); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -308,7 +309,7 @@ private function createAuthenticationStatement(string $id): AuthenticationStatem ); $authorityBinding = new AuthorityBinding( - QNameValue::fromString('{' . C::NS_SAMLP . '}samlp:AttributeQuery'), + QNameValue::fromString('{' . C::NS_SAMLP . '}samlp:AssertionIdReference'), SAMLAnyURIValue::fromString('urn:x-simplesamlphp:location'), SAMLAnyURIValue::fromString('urn:x-simplesamlphp:binding'), ); diff --git a/tests/src/SAML11/XML/saml/NameIdentifierTest.php b/tests/src/SAML11/XML/saml/NameIdentifierTest.php index 47d4f54..de50cd6 100644 --- a/tests/src/SAML11/XML/saml/NameIdentifierTest.php +++ b/tests/src/SAML11/XML/saml/NameIdentifierTest.php @@ -59,9 +59,10 @@ public function testMarshalling(): void SAMLAnyURIValue::fromString('urn:the:format'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($nameIdentifier), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($nameIdentifier); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/StatementTest.php b/tests/src/SAML11/XML/saml/StatementTest.php index 41676a5..1278239 100644 --- a/tests/src/SAML11/XML/saml/StatementTest.php +++ b/tests/src/SAML11/XML/saml/StatementTest.php @@ -85,7 +85,7 @@ public function testMarshalling(): void ], ); - $this->assertEquals( + $this->assertXmlStringEqualsXmlString( self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), strval($statement), ); @@ -107,10 +107,11 @@ public function testUnmarshalling(): void $this->assertCount(1, $audience); $this->assertEquals('urn:some:audience', $audience[0]->getContent()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($statement), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($statement); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -134,6 +135,8 @@ public function testUnmarshallingUnregistered(): void $this->assertEquals('Statement', $chunk->getLocalName()); $this->assertEquals(C::NS_SAML, $chunk->getNamespaceURI()); - $this->assertEquals($element->ownerDocument?->saveXML($element), strval($statement)); + /** @var \Dom\XMLDocument $ownerDocument */ + $ownerDocument = $element->ownerDocument; + $this->assertXmlStringEqualsXmlString($ownerDocument->saveXML($element), strval($statement)); } } diff --git a/tests/src/SAML11/XML/saml/SubjectConfirmationDataTest.php b/tests/src/SAML11/XML/saml/SubjectConfirmationDataTest.php index 85c1044..b82e4a7 100644 --- a/tests/src/SAML11/XML/saml/SubjectConfirmationDataTest.php +++ b/tests/src/SAML11/XML/saml/SubjectConfirmationDataTest.php @@ -63,10 +63,11 @@ public function testMarshalling(): void $this->assertEquals('2', strval($scd->getValue())); $this->assertEquals('xs:integer', $scd->getXsiType()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($scd), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($scd); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -93,9 +94,10 @@ public function testMarshallingNull(): void $this->assertNull($scd->getValue()); $this->assertEquals('xs:nil', $scd->getXsiType()); $nssaml = C::NS_SAML; + $nsxs = C_XSI::NS_XS; $nsxsi = C_XSI::NS_XSI; $xml = << + XML; $this->assertEquals( $xml, @@ -125,6 +127,12 @@ public function testUnmarshallingNameID(): void $this->assertEquals('abcd-some-value-xyz', $value->getValue()); $this->assertEquals('urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified', $value->getFormat()); - $this->assertXmlStringEqualsXmlString($document->saveXML(), $scd->toXML()->ownerDocument?->saveXML()); + + /** @var \Dom\XMLDocument $ownerDocument */ + $ownerDocument = $scd->toXML()->ownerDocument; + $this->assertXmlStringEqualsXmlString( + $document->saveXML($document->documentElement), + $ownerDocument->saveXML($ownerDocument->documentElement), + ); } } diff --git a/tests/src/SAML11/XML/saml/SubjectConfirmationTest.php b/tests/src/SAML11/XML/saml/SubjectConfirmationTest.php index c5b9df5..a0b7128 100644 --- a/tests/src/SAML11/XML/saml/SubjectConfirmationTest.php +++ b/tests/src/SAML11/XML/saml/SubjectConfirmationTest.php @@ -123,9 +123,10 @@ public function testMarshalling(): void $keyInfo, ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($sc), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($sc); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/saml/SubjectLocalityTest.php b/tests/src/SAML11/XML/saml/SubjectLocalityTest.php index dbbf602..552f09e 100644 --- a/tests/src/SAML11/XML/saml/SubjectLocalityTest.php +++ b/tests/src/SAML11/XML/saml/SubjectLocalityTest.php @@ -58,10 +58,11 @@ public function testMarshalling(): void SAMLStringValue::fromString('simplesamlphp.org'), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($sl), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($sl); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/src/SAML11/XML/saml/SubjectStatementTest.php b/tests/src/SAML11/XML/saml/SubjectStatementTest.php index 474d6f5..7d6e70e 100644 --- a/tests/src/SAML11/XML/saml/SubjectStatementTest.php +++ b/tests/src/SAML11/XML/saml/SubjectStatementTest.php @@ -162,7 +162,7 @@ public function testMarshalling(): void $audience = Audience::fromString('urn:x-simplesamlphp:audience'); $subjectStatement = new CustomSubjectStatement($subject, [$audience]); - $this->assertEquals( + $this->assertXmlStringEqualsXmlString( self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), strval($subjectStatement), ); @@ -181,10 +181,11 @@ public function testUnmarshalling(): void $this->assertCount(1, $audience); $this->assertEquals('urn:x-simplesamlphp:audience', $audience[0]->getContent()); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($subjectStatement), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($subjectStatement); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -208,6 +209,8 @@ public function testUnmarshallingUnregistered(): void $this->assertEquals('SubjectStatement', $chunk->getLocalName()); $this->assertEquals(C::NS_SAML, $chunk->getNamespaceURI()); - $this->assertEquals($element->ownerDocument?->saveXML($element), strval($subjectStatement)); + /** @var \Dom\XMLDocument $ownerDocument */ + $ownerDocument = $element->ownerDocument; + $this->assertXmlStringEqualsXmlString($ownerDocument->saveXML($element), strval($subjectStatement)); } } diff --git a/tests/src/SAML11/XML/saml/SubjectTest.php b/tests/src/SAML11/XML/saml/SubjectTest.php index 18856c5..fb938d4 100644 --- a/tests/src/SAML11/XML/saml/SubjectTest.php +++ b/tests/src/SAML11/XML/saml/SubjectTest.php @@ -135,9 +135,10 @@ public function testMarshalling(): void $subject = new Subject($sc, $nameIdentifier); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($subject), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($subject); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/samlp/AssertionArtifactTest.php b/tests/src/SAML11/XML/samlp/AssertionArtifactTest.php index cd4795a..df02134 100644 --- a/tests/src/SAML11/XML/samlp/AssertionArtifactTest.php +++ b/tests/src/SAML11/XML/samlp/AssertionArtifactTest.php @@ -52,9 +52,10 @@ public function testMarshalling(): void { $assertionArtifact = AssertionArtifact::fromString('AAEbuqrPjR1XORIHk5YAV8I4sM0nKP2CLV+h1CMiWbnkaWvvlJ0g4Ess'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($assertionArtifact), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($assertionArtifact); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/samlp/AttributeQueryTest.php b/tests/src/SAML11/XML/samlp/AttributeQueryTest.php index b601756..88a7d5a 100644 --- a/tests/src/SAML11/XML/samlp/AttributeQueryTest.php +++ b/tests/src/SAML11/XML/samlp/AttributeQueryTest.php @@ -154,9 +154,10 @@ public function testMarshalling(): void ], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($attributeQuery), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($attributeQuery); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/samlp/AuthenticationQueryTest.php b/tests/src/SAML11/XML/samlp/AuthenticationQueryTest.php index 0191d74..715f5ca 100644 --- a/tests/src/SAML11/XML/samlp/AuthenticationQueryTest.php +++ b/tests/src/SAML11/XML/samlp/AuthenticationQueryTest.php @@ -144,9 +144,10 @@ public function testMarshalling(): void SAMLAnyURIValue::fromString(C::AC_PASSWORD), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($authnQuery), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($authnQuery); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/samlp/AuthorizationDecisionQueryTest.php b/tests/src/SAML11/XML/samlp/AuthorizationDecisionQueryTest.php index 09dfa0a..ba99973 100644 --- a/tests/src/SAML11/XML/samlp/AuthorizationDecisionQueryTest.php +++ b/tests/src/SAML11/XML/samlp/AuthorizationDecisionQueryTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11\XML\samlp; -use DOMDocument; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -70,23 +70,23 @@ final class AuthorizationDecisionQueryTest extends TestCase /** @var string[] */ private static array $certData; - /** @var \DOMDocument $advice */ - //private static DOMDocument $advice; + /** @var \Dom\XMLDocument $advice */ + //private static Dom\XMLDocument $advice; - /** @var \DOMDocument $statement */ - //private static DOMDocument $statement; + /** @var \Dom\XMLDocument $statement */ + //private static Dom\XMLDocument $statement; - /** @var \DOMDocument $subjectStatement */ - //private static DOMDocument $subjectStatement; + /** @var \Dom\XMLDocument $subjectStatement */ + //private static Dom\XMLDocument $subjectStatement; - /** @var \DOMDocument $authnStatement */ - private static DOMDocument $authnStatement; + /** @var \Dom\XMLDocument $authnStatement */ + private static Dom\XMLDocument $authnStatement; - /** @var \DOMDocument $authzDecisionStatement */ - //private static DOMDocument $authzDecisionStatement; + /** @var \Dom\XMLDocument $authzDecisionStatement */ + //private static \Dom\XMLDocument $authzDecisionStatement; - /** @var \DOMDocument $attributeStatement */ - private static DOMDocument $attributeStatement; + /** @var \Dom\XMLDocument $attributeStatement */ + private static Dom\XMLDocument $attributeStatement; /** @@ -237,9 +237,10 @@ public function testMarshalling(): void ], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($authorizationDecisionQuery), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($authorizationDecisionQuery); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/samlp/QueryTest.php b/tests/src/SAML11/XML/samlp/QueryTest.php index a9bbc97..c9119fe 100644 --- a/tests/src/SAML11/XML/samlp/QueryTest.php +++ b/tests/src/SAML11/XML/samlp/QueryTest.php @@ -85,10 +85,11 @@ public function testMarshalling(): void ], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($query), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($query); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -115,6 +116,9 @@ public function testUnmarshallingUnregistered(): void $this->assertEquals('Query', $chunk->getLocalName()); $this->assertEquals(C::NS_SAMLP, $chunk->getNamespaceURI()); - $this->assertEquals($element->ownerDocument?->saveXML($element), strval($query)); + /** @var \Dom\XMLDocument $ownerDocument */ + $ownerDocument = $element->ownerDocument; + + $this->assertXmlStringEqualsXmlString($ownerDocument->saveXml($element), strval($query)); } } diff --git a/tests/src/SAML11/XML/samlp/RespondWithTest.php b/tests/src/SAML11/XML/samlp/RespondWithTest.php index 06b2e8f..52b8a23 100644 --- a/tests/src/SAML11/XML/samlp/RespondWithTest.php +++ b/tests/src/SAML11/XML/samlp/RespondWithTest.php @@ -55,9 +55,10 @@ public function testMarshalling(): void ), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($respondWith), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($respondWith); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/samlp/ResponseTest.php b/tests/src/SAML11/XML/samlp/ResponseTest.php index 86e4983..fd2a0c8 100644 --- a/tests/src/SAML11/XML/samlp/ResponseTest.php +++ b/tests/src/SAML11/XML/samlp/ResponseTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11\XML\samlp; -use DOMDocument; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -50,8 +50,8 @@ final class ResponseTest extends TestCase use SerializableElementTestTrait; - /** @var \DOMDocument $authnStatement */ - private static DOMDocument $authnStatement; + /** @var \Dom\XMLDocument $authnStatement */ + private static Dom\XMLDocument $authnStatement; /** @@ -125,9 +125,10 @@ public function testMarshalling(): void [$assertion], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($response), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($response); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/samlp/StatusCodeTest.php b/tests/src/SAML11/XML/samlp/StatusCodeTest.php index 5e82d3d..0512d03 100644 --- a/tests/src/SAML11/XML/samlp/StatusCodeTest.php +++ b/tests/src/SAML11/XML/samlp/StatusCodeTest.php @@ -58,9 +58,10 @@ public function testMarshalling(): void ], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($statusCode), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($statusCode); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/samlp/StatusDetailTest.php b/tests/src/SAML11/XML/samlp/StatusDetailTest.php index 1ea228d..9cc2ae0 100644 --- a/tests/src/SAML11/XML/samlp/StatusDetailTest.php +++ b/tests/src/SAML11/XML/samlp/StatusDetailTest.php @@ -56,10 +56,11 @@ public function testMarshalling(): void $statusDetail = new StatusDetail([new Chunk($document->documentElement)]); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($statusDetail), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($statusDetail); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } diff --git a/tests/src/SAML11/XML/samlp/StatusMessageTest.php b/tests/src/SAML11/XML/samlp/StatusMessageTest.php index 0e493fa..1c33be8 100644 --- a/tests/src/SAML11/XML/samlp/StatusMessageTest.php +++ b/tests/src/SAML11/XML/samlp/StatusMessageTest.php @@ -48,9 +48,10 @@ public function testMarshalling(): void { $statusMessage = StatusMessage::fromString('Something went wrong'); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($statusMessage), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($statusMessage); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } } diff --git a/tests/src/SAML11/XML/samlp/StatusTest.php b/tests/src/SAML11/XML/samlp/StatusTest.php index 9396637..58a04b6 100644 --- a/tests/src/SAML11/XML/samlp/StatusTest.php +++ b/tests/src/SAML11/XML/samlp/StatusTest.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Test\SAML11\XML\samlp; -use DOMDocument; +use Dom; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; @@ -38,8 +38,8 @@ final class StatusTest extends TestCase use SerializableElementTestTrait; - /** @var \DOMDocument $detail */ - private static DOMDocument $detail; + /** @var \Dom\XMLDocument $detail */ + private static Dom\XMLDocument $detail; /** @@ -79,10 +79,11 @@ public function testMarshalling(): void ), ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($status), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($status); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -111,7 +112,7 @@ public function testMarshallingElementOrdering(): void $this->assertCount(1, $statusElements); // Test ordering of Status contents - /** @var \DOMElement[] $statusElements */ + /** @var \Dom\Element[] $statusElements */ $statusElements = XPath::xpQuery($statusElement, './saml_protocol:StatusCode/following-sibling::*', $xpCache); $this->assertCount(2, $statusElements); $this->assertEquals('samlp:StatusMessage', $statusElements[0]->tagName); diff --git a/tests/src/SAML11/XML/samlp/SubjectQueryTest.php b/tests/src/SAML11/XML/samlp/SubjectQueryTest.php index 1fa9e0a..3a7dc0d 100644 --- a/tests/src/SAML11/XML/samlp/SubjectQueryTest.php +++ b/tests/src/SAML11/XML/samlp/SubjectQueryTest.php @@ -167,10 +167,11 @@ public function testMarshalling(): void ], ); - $this->assertEquals( - self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), - strval($subjectQuery), - ); + $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); + $this->assertNotFalse($expectedXml); + $actualXml = strval($subjectQuery); + + $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); } @@ -187,7 +188,7 @@ public function testUnmarshallingUnregistered(): void // Normalize the DOMElement by importing it into a clean empty document $newDoc = DOMDocumentFactory::create(); - /** @var \DOMElement $element */ + /** @var \Dom\Element $element */ $element = $newDoc->appendChild($newDoc->importNode($element, true)); $subjectQuery = AbstractSubjectQuery::fromXML($element);