Skip to content

Commit c4a41ee

Browse files
committed
Start using PHP 8.1 features
1 parent a34e1b0 commit c4a41ee

25 files changed

+126
-91
lines changed

src/SAML2/Constants.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -96,33 +96,6 @@ class Constants extends \SimpleSAML\XMLSecurity\Constants
9696
*/
9797
public const CM_VOUCHES = 'urn:oasis:names:tc:SAML:2.0:cm:sender-vouches';
9898

99-
/**
100-
* Request Authentication Context Comparison indicating that the resulting authentication context in the
101-
* authentication statement MUST be stronger (as deemed by the responder) than any one of the authentication
102-
* contexts specified
103-
*/
104-
public const COMPARISON_BETTER = 'better';
105-
106-
/**
107-
* Request Authentication Context Comparison indicating that the resulting authentication context in the
108-
* authentication statement MUST be the exact match of at least one of the authentication contexts specified
109-
*/
110-
public const COMPARISON_EXACT = 'exact';
111-
112-
/**
113-
* Request Authentication Context Comparison indicating that the resulting authentication context in the
114-
* authentication statement MUST be as strong as possible (as deemed by the responder) without exceeding the
115-
* strength of at least one of the authentication contexts specified.
116-
*/
117-
public const COMPARISON_MAXIMUM = 'maximum';
118-
119-
/**
120-
* Request Authentication Context Comparison indicating that he resulting authentication context in the
121-
* authentication statement MUST be at least as strong (as deemed by the responder) as one of the authentication
122-
* contexts specified.
123-
*/
124-
public const COMPARISON_MINIMUM = 'minimum';
125-
12699
/**
127100
* Indicates that a principal’s consent has been explicitly obtained by the issuer of the message during the
128101
* action that initiated the message.
@@ -498,17 +471,4 @@ class Constants extends \SimpleSAML\XMLSecurity\Constants
498471
* The format to express a timestamp in SAML2
499472
*/
500473
public const DATETIME_FORMAT = 'Y-m-d\\TH:i:sp';
501-
502-
/**
503-
* Valid values for saml:DecisionType
504-
*/
505-
public const AUTHZ_DECISION_PERMIT = 'Permit';
506-
public const AUTHZ_DECISION_DENY = 'Deny';
507-
public const AUTHZ_DECISION_INDETERMINATE = 'Indeterminate';
508-
509-
public const AUTHZ_DECISIONS = [
510-
self::AUTHZ_DECISION_PERMIT,
511-
self::AUTHZ_DECISION_DENY,
512-
self::AUTHZ_DECISION_INDETERMINATE,
513-
];
514474
}

src/SAML2/XML/Comparison.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\SAML2\XML;
6+
7+
enum Comparison: string
8+
{
9+
/**
10+
* Request Authentication Context Comparison indicating that the resulting authentication context in the
11+
* authentication statement MUST be stronger (as deemed by the responder) than any one of the authentication
12+
* contexts specified
13+
*/
14+
case BETTER = 'better';
15+
16+
/**
17+
* Request Authentication Context Comparison indicating that the resulting authentication context in the
18+
* authentication statement MUST be the exact match of at least one of the authentication contexts specified
19+
*/
20+
case EXACT = 'exact';
21+
22+
/**
23+
* Request Authentication Context Comparison indicating that the resulting authentication context in the
24+
* authentication statement MUST be as strong as possible (as deemed by the responder) without exceeding the
25+
* strength of at least one of the authentication contexts specified.
26+
*/
27+
case MAXIMUM = 'maximum';
28+
29+
/**
30+
* Request Authentication Context Comparison indicating that he resulting authentication context in the
31+
* authentication statement MUST be at least as strong (as deemed by the responder) as one of the authentication
32+
* contexts specified.
33+
*/
34+
case MINIMUM = 'minimum';
35+
}

src/SAML2/XML/Decision.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\SAML2\XML;
6+
7+
/**
8+
* Valid values for saml:DecisionType
9+
*/
10+
enum Decision: string
11+
{
12+
case PERMIT = 'Permit';
13+
case DENY = 'Deny';
14+
case INDETERMINATE = 'Indeterminate';
15+
}

src/SAML2/XML/alg/DigestMethod.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
use DOMElement;
88
use SimpleSAML\Assert\Assert;
99
use SimpleSAML\XML\Chunk;
10-
use SimpleSAML\XML\Constants as C;
1110
use SimpleSAML\XML\DOMDocumentFactory;
1211
use SimpleSAML\XML\Exception\InvalidDOMElementException;
1312
use SimpleSAML\XML\Exception\SchemaViolationException;
1413
use SimpleSAML\XML\ExtendableElementTrait;
14+
use SimpleSAML\XML\XsNamespace as NS;
1515

1616
/**
1717
* Class for handling the alg:DigestMethod element.
@@ -24,7 +24,7 @@ final class DigestMethod extends AbstractAlgElement
2424
use ExtendableElementTrait;
2525

2626
/** The namespace-attribute for the xs:any element */
27-
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_ANY;
27+
public const XS_ANY_ELT_NAMESPACE = NS::ANY;
2828

2929

3030
/**

src/SAML2/XML/alg/SigningMethod.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use DOMElement;
88
use SimpleSAML\Assert\Assert;
99
use SimpleSAML\XML\Chunk;
10-
use SimpleSAML\XML\Constants as C;
1110
use SimpleSAML\XML\DOMDocumentFactory;
1211
use SimpleSAML\XML\Exception\InvalidDOMElementException;
1312
use SimpleSAML\XML\Exception\MissingAttributeException;
1413
use SimpleSAML\XML\Exception\SchemaViolationException;
1514
use SimpleSAML\XML\ExtendableElementTrait;
15+
use SimpleSAML\XML\XsNamespace as NS;
1616

1717
use function strval;
1818

@@ -27,7 +27,7 @@ final class SigningMethod extends AbstractAlgElement
2727
use ExtendableElementTrait;
2828

2929
/** The namespace-attribute for the xs:any element */
30-
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_ANY;
30+
public const XS_ANY_ELT_NAMESPACE = NS::ANY;
3131

3232

3333
/**

src/SAML2/XML/md/AbstractEndpointType.php

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

55
namespace SimpleSAML\SAML2\XML\md;
66

7+
use CASE_LOWER;
78
use DOMElement;
89
use SimpleSAML\Assert\Assert;
9-
use SimpleSAML\SAML2\Constants as C;
1010
use SimpleSAML\SAML2\Exception\ArrayValidationException;
1111
use SimpleSAML\XML\ArrayizableElementInterface;
1212
use SimpleSAML\XML\Attribute as XMLAttribute;
@@ -16,6 +16,7 @@
1616
use SimpleSAML\XML\ExtendableAttributesTrait;
1717
use SimpleSAML\XML\ExtendableElementTrait;
1818
use SimpleSAML\XML\SerializableElementInterface;
19+
use SimpleSAML\XML\XsNamespace as NS;
1920

2021
use function array_change_key_case;
2122
use function array_key_exists;
@@ -43,10 +44,10 @@ abstract class AbstractEndpointType extends AbstractMdElement implements Arrayiz
4344
use ExtendableElementTrait;
4445

4546
/** The namespace-attribute for the xs:any element */
46-
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_OTHER;
47+
public const XS_ANY_ELT_NAMESPACE = NS::OTHER;
4748

4849
/** The namespace-attribute for the xs:anyAttribute element */
49-
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
50+
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
5051

5152

5253
/**
@@ -140,13 +141,11 @@ public static function fromXML(DOMElement $xml): static
140141

141142
$children = [];
142143
foreach ($xml->childNodes as $child) {
143-
if ($child->namespaceURI === C::NS_MD) {
144+
if (!($child instanceof DOMElement)) {
144145
continue;
145-
} elseif (!($child instanceof DOMElement)) {
146-
continue;
147-
}
148-
149-
$children[] = new Chunk($child);
146+
} elseif ($child->namespaceURI !== static::NS) {
147+
$children[] = new Chunk($child);
148+
} // else continue
150149
}
151150

152151
return new static(

src/SAML2/XML/md/AbstractRoleDescriptorType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use SimpleSAML\SAML2\Constants as C;
1111
use SimpleSAML\XML\Exception\SchemaViolationException;
1212
use SimpleSAML\XML\ExtendableAttributesTrait;
13+
use SimpleSAML\XML\XsNamespace as NS;
1314

1415
use function implode;
1516

@@ -23,7 +24,7 @@ abstract class AbstractRoleDescriptorType extends AbstractMetadataDocument
2324
use ExtendableAttributesTrait;
2425

2526
/** The namespace-attribute for the xs:anyAttribute element */
26-
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
27+
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
2728

2829

2930
/**

src/SAML2/XML/md/AffiliationDescriptor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use SimpleSAML\XML\Exception\SchemaViolationException;
1515
use SimpleSAML\XML\Exception\TooManyElementsException;
1616
use SimpleSAML\XML\ExtendableAttributesTrait;
17+
use SimpleSAML\XML\XsNamespace as NS;
1718
use SimpleSAML\XMLSecurity\XML\ds\Signature;
1819

1920
/**
@@ -26,7 +27,7 @@ final class AffiliationDescriptor extends AbstractMetadataDocument
2627
use ExtendableAttributesTrait;
2728

2829
/** The namespace-attribute for the xs:anyAttribute element */
29-
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
30+
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
3031

3132

3233
/**

src/SAML2/XML/md/ContactPerson.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use SimpleSAML\XML\ExtendableAttributesTrait;
2121
use SimpleSAML\XML\SerializableElementInterface;
2222
use SimpleSAML\XML\Utils as XMLUtils;
23+
use SimpleSAML\XML\XsNamespace as NS;
2324

2425
use function array_filter;
2526
use function array_change_key_case;
@@ -43,7 +44,7 @@ final class ContactPerson extends AbstractMdElement implements ArrayizableElemen
4344
use ExtendableAttributesTrait;
4445

4546
/** The namespace-attribute for the xs:anyAttribute element */
46-
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
47+
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
4748

4849

4950
/**

src/SAML2/XML/md/EntityDescriptor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use SimpleSAML\XML\Exception\SchemaViolationException;
1414
use SimpleSAML\XML\Exception\TooManyElementsException;
1515
use SimpleSAML\XML\ExtendableAttributesTrait;
16+
use SimpleSAML\XML\XsNamespace as NS;
1617
use SimpleSAML\XMLSecurity\XML\ds\Signature;
1718

1819
use function is_null;
@@ -27,7 +28,7 @@ final class EntityDescriptor extends AbstractMetadataDocument
2728
use ExtendableAttributesTrait;
2829

2930
/** The namespace-attribute for the xs:anyAttribute element */
30-
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
31+
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;
3132

3233

3334
/**

0 commit comments

Comments
 (0)