@@ -24,11 +24,11 @@ final class Scope extends AbstractShibmdElement
2424 * Create a Scope.
2525 *
2626 * @param string $scope
27- * @param bool $regexp
27+ * @param bool|null $regexp
2828 */
2929 public function __construct (
3030 string $ scope ,
31- protected bool $ regexp = false ,
31+ protected ? bool $ regexp = false ,
3232 ) {
3333 $ this ->setContent ($ scope );
3434 }
@@ -50,9 +50,9 @@ protected function validateContent(string $content): void
5050 /**
5151 * Collect the value of the regexp-property
5252 *
53- * @return bool
53+ * @return bool|null
5454 */
55- public function isRegexpScope (): bool
55+ public function isRegexpScope (): ? bool
5656 {
5757 return $ this ->regexp ;
5858 }
@@ -73,7 +73,7 @@ public static function fromXML(DOMElement $xml): static
7373 Assert::same ($ xml ->namespaceURI , Scope::NS , InvalidDOMElementException::class);
7474
7575 $ scope = $ xml ->textContent ;
76- $ regexp = self ::getOptionalBooleanAttribute ($ xml , 'regexp ' , false );
76+ $ regexp = self ::getOptionalBooleanAttribute ($ xml , 'regexp ' , null );
7777
7878 return new static ($ scope , $ regexp );
7979 }
@@ -89,7 +89,10 @@ public function toXML(DOMElement $parent = null): DOMElement
8989 {
9090 $ e = $ this ->instantiateParentElement ($ parent );
9191 $ e ->textContent = $ this ->getContent ();
92- $ e ->setAttribute ('regexp ' , $ this ->isRegexpScope () ? 'true ' : 'false ' );
92+
93+ if ($ this ->isRegexpScope () !== null ) {
94+ $ e ->setAttribute ('regexp ' , $ this ->isRegexpScope () ? 'true ' : 'false ' );
95+ }
9396
9497 return $ e ;
9598 }
0 commit comments