From 0b71cbcb0a7e01e2648674310b94fd6aee1056cb Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Sat, 20 Jan 2024 18:13:24 +0100 Subject: [PATCH] Fix several issue reported by PHPstan --- src/SAML2/XML/saml/AttributeValue.php | 2 -- src/SAML2/XML/saml/AuthzDecisionStatement.php | 6 ++++-- src/SAML2/XML/saml/NameID.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SAML2/XML/saml/AttributeValue.php b/src/SAML2/XML/saml/AttributeValue.php index 4fd3456e8..3eb7f6481 100644 --- a/src/SAML2/XML/saml/AttributeValue.php +++ b/src/SAML2/XML/saml/AttributeValue.php @@ -56,11 +56,9 @@ public function getXsiType(): string case "NULL": return "xs:nil"; case "object": - /** @var \SimpleSAML\XML\AbstractElement $this->value */ return sprintf( '%s:%s', $this->value::getNamespacePrefix(), - ":", AbstractElement::getClassName(get_class($this->value)), ); default: diff --git a/src/SAML2/XML/saml/AuthzDecisionStatement.php b/src/SAML2/XML/saml/AuthzDecisionStatement.php index 198968e7e..d2a2f1bf3 100644 --- a/src/SAML2/XML/saml/AuthzDecisionStatement.php +++ b/src/SAML2/XML/saml/AuthzDecisionStatement.php @@ -7,6 +7,7 @@ use DOMElement; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML2\Constants as C; +use SimpleSAML\SAML2\Exception\ProtocolViolationException; use SimpleSAML\SAML2\XML\Decision; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\Exception\MissingElementException; @@ -121,10 +122,11 @@ public static function fromXML(DOMElement $xml): static TooManyElementsException::class, ); + $decision = self::getAttribute($xml, 'Decision'); try { - $decision = Decision::from(self::getAttribute($xml, 'Decision')); + $decision = Decision::from($decision); } catch (ValueError) { - throw ProtocolViolationException(sprintf('Unknown value \'%s\' for Decision attribute.', $decision)); + throw new ProtocolViolationException(sprintf('Unknown value \'%s\' for Decision attribute.', $decision)); } return new static( diff --git a/src/SAML2/XML/saml/NameID.php b/src/SAML2/XML/saml/NameID.php index e6251c47a..f94ebb712 100644 --- a/src/SAML2/XML/saml/NameID.php +++ b/src/SAML2/XML/saml/NameID.php @@ -7,7 +7,7 @@ use DOMElement; use SimpleSAML\Assert\Assert; use SimpleSAML\SAML2\Compat\ContainerSingleton; -use SimpleSAML\XML\Exception\ArrayValidationException; +use SimpleSAML\SAML2\Exception\ArrayValidationException; use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XMLSecurity\Backend\EncryptionBackend; use SimpleSAML\XMLSecurity\XML\EncryptableElementInterface;