1010use SimpleSAML \XML \Attribute ;
1111use SimpleSAML \XML \Constants as C ;
1212use SimpleSAML \XMLSchema \Type \StringValue ;
13- use SimpleSAML \XMLSchema \XML \Enumeration \ NamespaceEnum ;
13+ use SimpleSAML \XMLSchema \XML \Constants \ NS ;
1414
1515use function array_diff ;
1616use function array_map ;
@@ -90,17 +90,12 @@ public function getAttributesNS(): array
9090 * NOTE: In case the namespace is ##any, this method will also return local non-namespaced attributes!
9191 *
9292 * @param \DOMElement $xml
93- * @param (
94- * \SimpleSAML\XMLSchema\XML\Enumeration\NamespaceEnum|
95- * array<\SimpleSAML\XMLSchema\XML\Enumeration\NamespaceEnum|string>|
96- * null
97- * ) $namespace
98- *
99- * @return array<int, \SimpleSAML\XML\Attribute> $attributes
93+ * @param string|string[]|null $namespace
94+ * @return array<int, \SimpleSAML\XML\Attribute>
10095 */
10196 protected static function getAttributesNSFromXML (
10297 DOMElement $ xml ,
103- NamespaceEnum |array |null $ namespace = null ,
98+ string |array |null $ namespace = null ,
10499 ): array {
105100 $ namespace = $ namespace ?? self ::XS_ANY_ATTR_NAMESPACE ;
106101 $ exclusionList = self ::getAttributeExclusions ();
@@ -109,16 +104,16 @@ protected static function getAttributesNSFromXML(
109104 // Validate namespace value
110105 if (!is_array ($ namespace )) {
111106 // Must be one of the predefined values
112- Assert::oneOf ($ namespace , NamespaceEnum:: cases () );
107+ Assert::oneOf ($ namespace , NS :: $ PREDEFINED );
113108
114109 foreach ($ xml ->attributes as $ a ) {
115110 if (in_array ([$ a ->namespaceURI , $ a ->localName ], $ exclusionList , true )) {
116111 continue ;
117- } elseif ($ namespace === NamespaceEnum::Other && in_array ($ a ->namespaceURI , [self ::NS , null ], true )) {
112+ } elseif ($ namespace === NS :: OTHER && in_array ($ a ->namespaceURI , [self ::NS , null ], true )) {
118113 continue ;
119- } elseif ($ namespace === NamespaceEnum::TargetNamespace && $ a ->namespaceURI !== self ::NS ) {
114+ } elseif ($ namespace === NS :: TARGETNAMESPACE && $ a ->namespaceURI !== self ::NS ) {
120115 continue ;
121- } elseif ($ namespace === NamespaceEnum::Local && $ a ->namespaceURI !== null ) {
116+ } elseif ($ namespace === NS :: LOCAL && $ a ->namespaceURI !== null ) {
122117 continue ;
123118 }
124119
@@ -133,16 +128,16 @@ protected static function getAttributesNSFromXML(
133128 // Array must be non-empty and cannot contain ##any or ##other
134129 Assert::notEmpty ($ namespace );
135130 Assert::allStringNotEmpty ($ namespace );
136- Assert::allNotSame ($ namespace , NamespaceEnum::Any );
137- Assert::allNotSame ($ namespace , NamespaceEnum::Other );
131+ Assert::allNotSame ($ namespace , NS :: ANY );
132+ Assert::allNotSame ($ namespace , NS :: OTHER );
138133
139134 // Replace the ##targetedNamespace with the actual namespace
140- if (($ key = array_search (NamespaceEnum::TargetNamespace , $ namespace )) !== false ) {
135+ if (($ key = array_search (NS :: TARGETNAMESPACE , $ namespace )) !== false ) {
141136 $ namespace [$ key ] = self ::NS ;
142137 }
143138
144139 // Replace the ##local with null
145- if (($ key = array_search (NamespaceEnum::Local , $ namespace )) !== false ) {
140+ if (($ key = array_search (NS :: LOCAL , $ namespace )) !== false ) {
146141 $ namespace [$ key ] = null ;
147142 }
148143
@@ -183,12 +178,12 @@ protected function setAttributesNS(array $attributes): void
183178 // Validate namespace value
184179 if (!is_array ($ namespace )) {
185180 // Must be one of the predefined values
186- Assert::oneOf ($ namespace , NamespaceEnum:: cases () );
181+ Assert::oneOf ($ namespace , NS :: $ PREDEFINED );
187182 } else {
188183 // Array must be non-empty and cannot contain ##any or ##other
189184 Assert::notEmpty ($ namespace );
190- Assert::allNotSame ($ namespace , NamespaceEnum::Any );
191- Assert::allNotSame ($ namespace , NamespaceEnum::Other );
185+ Assert::allNotSame ($ namespace , NS :: ANY );
186+ Assert::allNotSame ($ namespace , NS :: OTHER );
192187 }
193188
194189 // Get namespaces for all attributes
@@ -203,20 +198,20 @@ function (Attribute $attr) {
203198 $ attributes ,
204199 );
205200
206- if ($ namespace === NamespaceEnum::Local ) {
201+ if ($ namespace === NS :: LOCAL ) {
207202 // If ##local then all namespaces must be null
208203 Assert::allNull ($ actual_namespaces );
209204 } elseif (is_array ($ namespace )) {
210205 // Make a local copy of the property that we can edit
211206 $ allowed_namespaces = $ namespace ;
212207
213208 // Replace the ##targetedNamespace with the actual namespace
214- if (($ key = array_search (NamespaceEnum::TargetNamespace , $ allowed_namespaces )) !== false ) {
209+ if (($ key = array_search (NS :: TARGETNAMESPACE , $ allowed_namespaces )) !== false ) {
215210 $ allowed_namespaces [$ key ] = self ::NS ;
216211 }
217212
218213 // Replace the ##local with null
219- if (($ key = array_search (NamespaceEnum::Local , $ allowed_namespaces )) !== false ) {
214+ if (($ key = array_search (NS :: LOCAL , $ allowed_namespaces )) !== false ) {
220215 $ allowed_namespaces [$ key ] = null ;
221216 }
222217
@@ -230,13 +225,13 @@ function (Attribute $attr) {
230225 ),
231226 );
232227 } else {
233- if ($ namespace === NamespaceEnum::Other ) {
228+ if ($ namespace === NS :: OTHER ) {
234229 // All attributes must be namespaced, ergo non-null
235230 Assert::allNotNull ($ actual_namespaces );
236231
237232 // Must be any namespace other than the parent element
238233 Assert::allNotSame ($ actual_namespaces , self ::NS );
239- } elseif ($ namespace === NamespaceEnum::TargetNamespace ) {
234+ } elseif ($ namespace === NS :: TARGETNAMESPACE ) {
240235 // Must be the same namespace as the one of the parent element
241236 Assert::allSame ($ actual_namespaces , self ::NS );
242237 }
@@ -254,12 +249,9 @@ function (Attribute $attr) {
254249
255250
256251 /**
257- * @return (
258- * array<\SimpleSAML\XMLSchema\XML\Enumeration\NamespaceEnum|string>|
259- * \SimpleSAML\XMLSchema\XML\Enumeration\NamespaceEnum
260- * )[]
252+ * @return string[]|string
261253 */
262- public function getAttributeNamespace (): array |NamespaceEnum
254+ public function getAttributeNamespace (): array |string
263255 {
264256 Assert::true (
265257 defined ('self::XS_ANY_ATTR_NAMESPACE ' ),
0 commit comments