Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit daf37e1

Browse files
committed
Migrate to xsd-types
1 parent 0cf7e13 commit daf37e1

18 files changed

Lines changed: 88 additions & 51 deletions

src/XML/wsa_200508/RelatesTo.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use SimpleSAML\XML\TypedTextContentTrait;
1313
use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException;
1414
use SimpleSAML\XMLSchema\Type\AnyURIValue;
15-
use SimpleSAML\XMLSchema\Type\QNameValue;
1615
use SimpleSAML\XMLSchema\XML\Constants\NS;
1716

1817
/**
@@ -38,12 +37,12 @@ final class RelatesTo extends AbstractWsaElement implements SchemaValidatableEle
3837
* Initialize a wsa:RelatesTo
3938
*
4039
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue $content
41-
* @param \SimpleSAML\XMLSchema\Type\QNameValue|null $RelationshipType
40+
* @param \SimpleSAML\XMLSchema\Type\AnyURIValue|null $RelationshipType
4241
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
4342
*/
4443
public function __construct(
4544
AnyURIValue $content,
46-
protected ?QNameValue $RelationshipType,
45+
protected ?AnyURIValue $RelationshipType,
4746
array $namespacedAttributes = [],
4847
) {
4948
$this->setContent($content);
@@ -54,9 +53,9 @@ public function __construct(
5453
/**
5554
* Collect the value of the RelationshipType property.
5655
*
57-
* @return \SimpleSAML\XMLSchema\Type\QNameValue|null
56+
* @return \SimpleSAML\XMLSchema\Type\AnyURIValue|null
5857
*/
59-
public function getRelationshipType(): ?QNameValue
58+
public function getRelationshipType(): ?AnyURIValue
6059
{
6160
return $this->RelationshipType;
6261
}
@@ -78,9 +77,7 @@ public static function fromXML(DOMElement $xml): static
7877

7978
return new static(
8079
AnyURIValue::fromString($xml->textContent),
81-
$xml->hasAttribute('RelationshipType')
82-
? QNameValue::fromDocument($xml->getAttribute('RelationshipType'), $xml)
83-
: null,
80+
self::getOptionalAttribute($xml, 'RelationshipType', AnyURIValue::class, null),
8481
self::getAttributesNSFromXML($xml),
8582
);
8683
}

tests/WSSecurity/XML/wsa_200508/ActionTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use SimpleSAML\XML\DOMDocumentFactory;
1515
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1616
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
17+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
18+
use SimpleSAML\XMLSchema\Type\StringValue;
1719

1820
use function dirname;
1921
use function strval;
@@ -53,8 +55,8 @@ public static function setUpBeforeClass(): void
5355
*/
5456
public function testMarshalling(): void
5557
{
56-
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test', 'value');
57-
$action = new Action('https://login.microsoftonline.com/login.srf', [$attr1]);
58+
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test', StringValue::fromString('value'));
59+
$action = new Action(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr1]);
5860

5961
$this->assertEquals(
6062
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

tests/WSSecurity/XML/wsa_200508/AddressTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use SimpleSAML\XML\Attribute;
1414
use SimpleSAML\XML\DOMDocumentFactory;
1515
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
16+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
17+
use SimpleSAML\XMLSchema\Type\StringValue;
1618

1719
use function dirname;
1820
use function strval;
@@ -51,8 +53,8 @@ public static function setUpBeforeClass(): void
5153
*/
5254
public function testMarshalling(): void
5355
{
54-
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test', 'value');
55-
$address = new Address('https://login.microsoftonline.com/login.srf', [$attr1]);
56+
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test', StringValue::fromString('value'));
57+
$address = new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr1]);
5658

5759
$this->assertEquals(
5860
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

tests/WSSecurity/XML/wsa_200508/EndpointReferenceTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use SimpleSAML\XML\DOMDocumentFactory;
2020
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
2121
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
22+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
23+
use SimpleSAML\XMLSchema\Type\StringValue;
2224

2325
use function dirname;
2426
use function strval;
@@ -80,17 +82,17 @@ public static function setUpBeforeClass(): void
8082
*/
8183
public function testMarshalling(): void
8284
{
83-
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', 'value1');
84-
$attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', 'value2');
85-
$attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', 'value3');
86-
$attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', 'value4');
85+
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1'));
86+
$attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2'));
87+
$attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3'));
88+
$attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4'));
8789

8890
$referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$attr4]);
8991
$metadata = new Metadata([new Chunk(self::$metadataContent)], [$attr3]);
9092
$chunk = new Chunk(self::$customContent);
9193

9294
$endpointReference = new EndpointReference(
93-
new Address('https://login.microsoftonline.com/login.srf', [$attr2]),
95+
new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]),
9496
$referenceParameters,
9597
$metadata,
9698
[$chunk],

tests/WSSecurity/XML/wsa_200508/FaultToTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use SimpleSAML\XML\DOMDocumentFactory;
2020
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
2121
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
22+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
23+
use SimpleSAML\XMLSchema\Type\StringValue;
2224

2325
use function dirname;
2426
use function strval;
@@ -82,17 +84,17 @@ public function testMarshalling(): void
8284
{
8385
$doc = DOMDocumentFactory::fromString('<root/>');
8486

85-
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', 'value1');
86-
$attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', 'value2');
87-
$attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', 'value3');
88-
$attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', 'value4');
87+
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1'));
88+
$attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2'));
89+
$attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3'));
90+
$attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4'));
8991

9092
$referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$attr4]);
9193
$metadata = new Metadata([new Chunk(self::$metadataContent)], [$attr3]);
9294
$chunk = new Chunk(self::$customContent);
9395

9496
$faultTo = new FaultTo(
95-
new Address('https://login.microsoftonline.com/login.srf', [$attr2]),
97+
new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]),
9698
$referenceParameters,
9799
$metadata,
98100
[$chunk],

tests/WSSecurity/XML/wsa_200508/FromTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use SimpleSAML\XML\DOMDocumentFactory;
2020
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
2121
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
22+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
23+
use SimpleSAML\XMLSchema\Type\StringValue;
2224

2325
use function dirname;
2426
use function strval;
@@ -82,17 +84,17 @@ public function testMarshalling(): void
8284
{
8385
$doc = DOMDocumentFactory::fromString('<root/>');
8486

85-
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', 'value1');
86-
$attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', 'value2');
87-
$attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', 'value3');
88-
$attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', 'value4');
87+
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test1', StringValue::fromString('value1'));
88+
$attr2 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test2', StringValue::fromString('value2'));
89+
$attr3 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test3', StringValue::fromString('value3'));
90+
$attr4 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test4', StringValue::fromString('value4'));
8991

9092
$referenceParameters = new ReferenceParameters([new Chunk(self::$referenceParametersContent)], [$attr4]);
9193
$metadata = new Metadata([new Chunk(self::$metadataContent)], [$attr3]);
9294
$chunk = new Chunk(self::$customContent);
9395

9496
$from = new From(
95-
new Address('https://login.microsoftonline.com/login.srf', [$attr2]),
97+
new Address(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr2]),
9698
$referenceParameters,
9799
$metadata,
98100
[$chunk],

tests/WSSecurity/XML/wsa_200508/MessageIDTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use SimpleSAML\XML\DOMDocumentFactory;
1515
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1616
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
17+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
1718

1819
use function dirname;
1920
use function strval;
@@ -54,7 +55,10 @@ public static function setUpBeforeClass(): void
5455
public function testMarshalling(): void
5556
{
5657
$mustUnderstand = MustUnderstandValue::fromBoolean(true);
57-
$msgId = new MessageID('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de', [$mustUnderstand->toAttribute()]);
58+
$msgId = new MessageID(
59+
AnyURIValue::fromString('uuid:d0ccf3cd-2dce-4c1a-a5d6-be8912ecd7de'),
60+
[$mustUnderstand->toAttribute()],
61+
);
5862

5963
$this->assertEquals(
6064
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

tests/WSSecurity/XML/wsa_200508/MetadataTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use SimpleSAML\XML\DOMDocumentFactory;
1616
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1717
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
18+
use SimpleSAML\XMLSchema\Type\StringValue;
1819

1920
use function dirname;
2021
use function strval;
@@ -57,7 +58,7 @@ public static function setUpBeforeClass(): void
5758
*/
5859
public function testMarshalling(): void
5960
{
60-
$domAttr = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'value1');
61+
$domAttr = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('value1'));
6162

6263
$metadata = new Metadata([new Chunk(self::$metadataContent)], [$domAttr]);
6364
$this->assertFalse($metadata->isEmptyElement());

tests/WSSecurity/XML/wsa_200508/ProblemActionTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use SimpleSAML\XML\DOMDocumentFactory;
1818
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1919
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
20+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
21+
use SimpleSAML\XMLSchema\Type\StringValue;
2022

2123
use function dirname;
2224
use function strval;
@@ -56,11 +58,11 @@ public static function setUpBeforeClass(): void
5658
*/
5759
public function testMarshalling(): void
5860
{
59-
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test', 'value');
61+
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'test', StringValue::fromString('value'));
6062

6163
$problemAction = new ProblemAction(
62-
new Action('https://login.microsoftonline.com/login.srf', [$attr1]),
63-
new SoapAction('http://www.example.com/'),
64+
new Action(AnyURIValue::fromString('https://login.microsoftonline.com/login.srf'), [$attr1]),
65+
new SoapAction(AnyURIValue::fromString('http://www.example.com/')),
6466
[$attr1],
6567
);
6668

tests/WSSecurity/XML/wsa_200508/ProblemHeaderQNameTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
use SimpleSAML\XML\DOMDocumentFactory;
1515
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1616
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
17+
use SimpleSAML\XMLSchema\Type\AnyURIValue;
18+
use SimpleSAML\XMLSchema\Type\NCNameValue;
19+
use SimpleSAML\XMLSchema\Type\StringValue;
20+
use SimpleSAML\XMLSchema\Type\QNameValue;
1721

1822
use function dirname;
1923
use function strval;
@@ -53,9 +57,16 @@ public static function setUpBeforeClass(): void
5357
*/
5458
public function testMarshalling(): void
5559
{
56-
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'value1');
60+
$attr1 = new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', StringValue::fromString('value1'));
5761

58-
$problemHeaderQName = new ProblemHeaderQName('wsa10:Action', [$attr1]);
62+
$problemHeaderQName = new ProblemHeaderQName(
63+
QNameValue::fromParts(
64+
NCNameValue::fromString('Action'),
65+
AnyURIValue::fromString(AbstractWsaElement::NS),
66+
NCNameValue::fromString('wsa10'),
67+
),
68+
[$attr1],
69+
);
5970

6071
$this->assertEquals(
6172
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),

0 commit comments

Comments
 (0)