From 5aaa4b7409d2c19f0adea1da6063d0f1d55da1a8 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Fri, 16 Feb 2024 00:04:26 +0100 Subject: [PATCH] Migrate from psalm to phpstan --- .github/workflows/php.yml | 26 +-- phpstan-baseline.neon | 211 ++++++++++++++++++ phpstan-dev.neon | 4 + phpstan.neon | 4 + psalm-dev.xml | 58 ----- psalm.xml | 35 --- src/SAML2/Assertion/ProcessorBuilder.php | 4 +- src/SAML2/XML/EncryptedElementTrait.php | 1 - .../XML/md/AttributeAuthorityDescriptor.php | 2 +- src/SAML2/XML/md/AuthnAuthorityDescriptor.php | 2 +- src/SAML2/XML/md/PDPDescriptor.php | 2 +- src/SAML2/XML/mdui/Logo.php | 1 - src/SAML2/XML/mdui/UIInfo.php | 2 +- src/SAML2/XML/saml/AbstractBaseIDType.php | 12 +- src/SAML2/XML/saml/AttributeStatement.php | 2 +- src/SAML2/XML/saml/AttributeValue.php | 6 +- src/SAML2/XML/saml/AudienceRestriction.php | 2 +- src/SAML2/XML/saml/EncryptedID.php | 6 +- src/SAML2/XML/saml/IDNameQualifiersTrait.php | 4 +- src/SAML2/XML/saml/Issuer.php | 2 - src/SAML2/XML/saml/NameIDType.php | 21 +- src/SAML2/XML/saml/SubjectLocality.php | 2 +- src/SAML2/XML/samlp/ArtifactResolve.php | 3 +- src/SAML2/XML/samlp/ArtifactResponse.php | 2 +- src/SAML2/XML/samlp/AttributeQuery.php | 2 +- src/SAML2/XML/samlp/AuthnRequest.php | 2 +- src/SAML2/XML/samlp/LogoutRequest.php | 3 +- src/SAML2/XML/samlp/RequestedAuthnContext.php | 3 +- src/SAML2/XML/samlp/StatusDetail.php | 2 - 29 files changed, 264 insertions(+), 162 deletions(-) create mode 100644 phpstan-baseline.neon create mode 100644 phpstan-dev.neon create mode 100644 phpstan.neon delete mode 100644 psalm-dev.xml delete mode 100644 psalm.xml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index cc41a82ee..6b2505c77 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -52,9 +52,8 @@ jobs: with: # Should be the higest supported version, so we can use the newest tools php-version: '8.3' - tools: composer, composer-require-checker, composer-unused, phpcs, psalm - # optional performance gain for psalm: opcache - extensions: ctype, date, dom, filter, hash, mbstring, opcache, openssl, pcre, soap, spl, xml + tools: composer, composer-require-checker, composer-unused, phpcs + extensions: ctype, date, dom, filter, hash, mbstring, openssl, pcre, soap, spl, xml coverage: none - name: Setup problem matchers for PHP @@ -88,28 +87,13 @@ jobs: - name: PHP Code Sniffer run: phpcs - - name: Psalm - continue-on-error: true + - name: PHPStan run: | - psalm -c psalm.xml \ - --show-info=true \ - --shepherd \ - --php-version=${{ steps.setup-php.outputs.php-version }} + phpstan analyze -c phpstan.neon - name: Psalm (testsuite) - continue-on-error: true - run: | - psalm -c psalm-dev.xml \ - --show-info=true \ - --shepherd \ - --php-version=${{ steps.setup-php.outputs.php-version }} - - - name: Psalter run: | - psalm --alter \ - --issues=UnnecessaryVarAnnotation \ - --dry-run \ - --php-version=${{ steps.setup-php.outputs.php-version }} + phpstan analyze -c phpstan-dev.neon security: name: Security checks diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 000000000..612048082 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,211 @@ +parameters: + ignoreErrors: + - + message: "#^Access to constant AES128_CBC on an unknown class SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" + count: 1 + path: src/SAML2/Certificate/PrivateKeyLoader.php + + - + message: "#^Access to constant RSA_1_5 on an unknown class SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" + count: 1 + path: src/SAML2/Certificate/PrivateKeyLoader.php + + - + message: "#^Instantiated class SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey not found\\.$#" + count: 2 + path: src/SAML2/Certificate/PrivateKeyLoader.php + + - + message: "#^Method SimpleSAML\\\\SAML2\\\\Certificate\\\\PrivateKeyLoader\\:\\:convertPrivateKeyToRsaKey\\(\\) has invalid return type SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" + count: 1 + path: src/SAML2/Certificate/PrivateKeyLoader.php + + - + message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:convertToIdentityProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" + count: 1 + path: src/SAML2/Configuration/SimpleSAMLConverter.php + + - + message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:convertToServiceProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" + count: 1 + path: src/SAML2/Configuration/SimpleSAMLConverter.php + + - + message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:enrichForDecryptionProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" + count: 1 + path: src/SAML2/Configuration/SimpleSAMLConverter.php + + - + message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:enrichForIdentityProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" + count: 1 + path: src/SAML2/Configuration/SimpleSAMLConverter.php + + - + message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:enrichForServiceProvider\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" + count: 1 + path: src/SAML2/Configuration/SimpleSAMLConverter.php + + - + message: "#^Parameter \\$configuration of method SimpleSAML\\\\SAML2\\\\Configuration\\\\SimpleSAMLConverter\\:\\:pluckConfiguration\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" + count: 1 + path: src/SAML2/Configuration/SimpleSAMLConverter.php + + - + message: "#^Call to static method addSign\\(\\) on an unknown class SimpleSAML\\\\Module\\\\saml\\\\Message\\.$#" + count: 1 + path: src/SAML2/HTTPArtifact.php + + - + message: "#^Call to static method getInstance\\(\\) on an unknown class SimpleSAML\\\\Configuration\\.$#" + count: 2 + path: src/SAML2/HTTPArtifact.php + + - + message: "#^Call to static method getInstance\\(\\) on an unknown class SimpleSAML\\\\Store\\\\StoreFactory\\.$#" + count: 1 + path: src/SAML2/HTTPArtifact.php + + - + message: "#^Call to static method getMetadataHandler\\(\\) on an unknown class SimpleSAML\\\\Metadata\\\\MetaDataStorageHandler\\.$#" + count: 1 + path: src/SAML2/HTTPArtifact.php + + - + message: "#^Instantiated class SimpleSAML\\\\Utils\\\\HTTP not found\\.$#" + count: 1 + path: src/SAML2/HTTPArtifact.php + + - + message: "#^Parameter \\$key of method SimpleSAML\\\\SAML2\\\\HTTPArtifact\\:\\:validateSignature\\(\\) has invalid type SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" + count: 1 + path: src/SAML2/HTTPArtifact.php + + - + message: "#^Parameter \\$sp of method SimpleSAML\\\\SAML2\\\\HTTPArtifact\\:\\:setSPMetadata\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" + count: 1 + path: src/SAML2/HTTPArtifact.php + + - + message: "#^Property SimpleSAML\\\\SAML2\\\\HTTPArtifact\\:\\:\\$spMetadata has unknown class SimpleSAML\\\\Configuration as its type\\.$#" + count: 1 + path: src/SAML2/HTTPArtifact.php + + - + message: "#^Instantiated class SimpleSAML\\\\Utils\\\\Config not found\\.$#" + count: 1 + path: src/SAML2/SOAPClient.php + + - + message: "#^Instantiated class SimpleSAML\\\\Utils\\\\Crypto not found\\.$#" + count: 1 + path: src/SAML2/SOAPClient.php + + - + message: "#^Parameter \\$dstMetadata of method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:send\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" + count: 1 + path: src/SAML2/SOAPClient.php + + - + message: "#^Parameter \\$key of method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:validateSSL\\(\\) has invalid type SimpleSAML\\\\XMLSecurity\\\\XMLSecurityKey\\.$#" + count: 1 + path: src/SAML2/SOAPClient.php + + - + message: "#^Parameter \\$srcMetadata of method SimpleSAML\\\\SAML2\\\\SOAPClient\\:\\:send\\(\\) has invalid type SimpleSAML\\\\Configuration\\.$#" + count: 1 + path: src/SAML2/SOAPClient.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 2 + path: src/SAML2/XML/md/AbstractEndpointType.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 2 + path: src/SAML2/XML/md/AbstractIndexedEndpointType.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor\\)\\:\\:XSI_TYPE_NAME\\.$#" + count: 2 + path: src/SAML2/XML/md/AbstractRoleDescriptor.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#" + count: 2 + path: src/SAML2/XML/md/AbstractRoleDescriptor.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor\\)\\:\\:XSI_TYPE_PREFIX\\.$#" + count: 2 + path: src/SAML2/XML/md/AbstractRoleDescriptor.php + + - + message: "#^Call to an undefined static method static\\(SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractSignedMdElement\\)\\:\\:getXsiTypeNamespaceURI\\(\\)\\.$#" + count: 1 + path: src/SAML2/XML/md/AbstractSignedMdElement.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractBaseID\\)\\:\\:XSI_TYPE_NAME\\.$#" + count: 2 + path: src/SAML2/XML/saml/AbstractBaseID.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractBaseID\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#" + count: 2 + path: src/SAML2/XML/saml/AbstractBaseID.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractBaseID\\)\\:\\:XSI_TYPE_PREFIX\\.$#" + count: 2 + path: src/SAML2/XML/saml/AbstractBaseID.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractCondition\\)\\:\\:XSI_TYPE_NAME\\.$#" + count: 2 + path: src/SAML2/XML/saml/AbstractCondition.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractCondition\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#" + count: 2 + path: src/SAML2/XML/saml/AbstractCondition.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractCondition\\)\\:\\:XSI_TYPE_PREFIX\\.$#" + count: 2 + path: src/SAML2/XML/saml/AbstractCondition.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractStatement\\)\\:\\:XSI_TYPE_NAME\\.$#" + count: 2 + path: src/SAML2/XML/saml/AbstractStatement.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractStatement\\)\\:\\:XSI_TYPE_NAMESPACE\\.$#" + count: 2 + path: src/SAML2/XML/saml/AbstractStatement.php + + - + message: "#^Access to undefined constant static\\(SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\AbstractStatement\\)\\:\\:XSI_TYPE_PREFIX\\.$#" + count: 2 + path: src/SAML2/XML/saml/AbstractStatement.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/SAML2/XML/saml/Attribute.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/SAML2/XML/saml/EncryptedAttribute.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/SAML2/XML/saml/EncryptedID.php + + - + message: "#^Unsafe usage of new static\\(\\)\\.$#" + count: 1 + path: src/SAML2/XML/saml/NameIDType.php diff --git a/phpstan-dev.neon b/phpstan-dev.neon new file mode 100644 index 000000000..09d9773d3 --- /dev/null +++ b/phpstan-dev.neon @@ -0,0 +1,4 @@ +parameters: + level: 5 + paths: + - tests diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 000000000..21cf5903a --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 1 + paths: + - src diff --git a/psalm-dev.xml b/psalm-dev.xml deleted file mode 100644 index f93f66d61..000000000 --- a/psalm-dev.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index 38050e1df..000000000 --- a/psalm.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/SAML2/Assertion/ProcessorBuilder.php b/src/SAML2/Assertion/ProcessorBuilder.php index c05080459..8aa7795a9 100644 --- a/src/SAML2/Assertion/ProcessorBuilder.php +++ b/src/SAML2/Assertion/ProcessorBuilder.php @@ -129,12 +129,12 @@ private static function createSubjectConfirmationValidator( */ private static function createAssertionTransformerChain( LoggerInterface $logger, - PrivateKeyLoader $keyloader, + PrivateKeyLoader $keyLoader, IdentityProvider $identityProvider, ServiceProvider $serviceProvider, ): TransformerChain { $chain = new TransformerChain($identityProvider, $serviceProvider); - $chain->addTransformerStep(new NameIdDecryptionTransformer($logger, $keyloader)); + $chain->addTransformerStep(new NameIdDecryptionTransformer($logger, $keyLoader)); return $chain; } diff --git a/src/SAML2/XML/EncryptedElementTrait.php b/src/SAML2/XML/EncryptedElementTrait.php index a33d5723b..429c4b78a 100644 --- a/src/SAML2/XML/EncryptedElementTrait.php +++ b/src/SAML2/XML/EncryptedElementTrait.php @@ -110,7 +110,6 @@ public static function fromXML(DOMElement $xml): static */ public function toXML(DOMElement $parent = null): DOMElement { - /** @psalm-var \DOMDocument $e->ownerDocument */ $e = $this->instantiateParentElement($parent); $this->encryptedData->toXML($e); foreach ($this->getDecryptionKeys() as $key) { diff --git a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php index 75aaf767c..a64dfede2 100644 --- a/src/SAML2/XML/md/AttributeAuthorityDescriptor.php +++ b/src/SAML2/XML/md/AttributeAuthorityDescriptor.php @@ -28,7 +28,7 @@ final class AttributeAuthorityDescriptor extends AbstractRoleDescriptorType * * @param \SimpleSAML\SAML2\XML\md\AttributeService[] $attributeService * @param string[] $protocolSupportEnumeration - * @param \SimpleSAML\SAML2\XML\md\AssertionIDRequestService[] $asssertionIDRequestService + * @param \SimpleSAML\SAML2\XML\md\AssertionIDRequestService[] $assertionIDRequestService * @param \SimpleSAML\SAML2\XML\md\NameIDFormat[] $nameIDFormat * @param \SimpleSAML\SAML2\XML\md\AttributeProfile[] $attributeProfile * @param \SimpleSAML\SAML2\XML\saml\Attribute[] $attribute diff --git a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php index 83902855a..ebc5a1a54 100644 --- a/src/SAML2/XML/md/AuthnAuthorityDescriptor.php +++ b/src/SAML2/XML/md/AuthnAuthorityDescriptor.php @@ -36,7 +36,7 @@ final class AuthnAuthorityDescriptor extends AbstractRoleDescriptorType * @param \SimpleSAML\SAML2\XML\md\Organization|null $organization * @param array $keyDescriptor * @param array $contact - * @param list<\SimpleSAML\XML\Attribute> + * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes */ public function __construct( protected array $authnQueryService, diff --git a/src/SAML2/XML/md/PDPDescriptor.php b/src/SAML2/XML/md/PDPDescriptor.php index f36820548..7a199f5b4 100644 --- a/src/SAML2/XML/md/PDPDescriptor.php +++ b/src/SAML2/XML/md/PDPDescriptor.php @@ -36,7 +36,7 @@ final class PDPDescriptor extends AbstractRoleDescriptorType * @param \SimpleSAML\SAML2\XML\md\Organization|null $organization * @param \SimpleSAML\SAML2\XML\md\KeyDescriptor[] $keyDescriptors * @param \SimpleSAML\SAML2\XML\md\ContactPerson[] $contacts - * @param list<\SimpleSAML\XML\Attribute> + * @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes */ public function __construct( protected array $authzService, diff --git a/src/SAML2/XML/mdui/Logo.php b/src/SAML2/XML/mdui/Logo.php index 21dd96bf3..1bb413141 100644 --- a/src/SAML2/XML/mdui/Logo.php +++ b/src/SAML2/XML/mdui/Logo.php @@ -130,7 +130,6 @@ public static function fromXML(DOMElement $xml): static */ public function toXML(DOMElement $parent = null): DOMElement { - /** @psalm-var \DOMDocument $e->ownerDocument */ $e = $this->instantiateParentElement($parent); $e->textContent = $this->getContent(); $e->setAttribute('height', strval($this->getHeight())); diff --git a/src/SAML2/XML/mdui/UIInfo.php b/src/SAML2/XML/mdui/UIInfo.php index 2954d6e62..e2b0a321a 100644 --- a/src/SAML2/XML/mdui/UIInfo.php +++ b/src/SAML2/XML/mdui/UIInfo.php @@ -230,7 +230,7 @@ public function isEmptyElement(): bool * * @param (\SimpleSAML\SAML2\XML\md\AbstractLocalizedURL| * \SimpleSAML\SAML2\XML\md\AbstractLocalizedName| - * \SimpleSAML\SAML2\XML\mdui\Keywords)[] $items + * \SimpleSAML\SAML2\XML\mdui\Keywords)[] $elements * @return void */ private function testLocalizedElements(array $elements) diff --git a/src/SAML2/XML/saml/AbstractBaseIDType.php b/src/SAML2/XML/saml/AbstractBaseIDType.php index 0305291c4..0484743c3 100644 --- a/src/SAML2/XML/saml/AbstractBaseIDType.php +++ b/src/SAML2/XML/saml/AbstractBaseIDType.php @@ -20,19 +20,19 @@ abstract class AbstractBaseIDType extends AbstractSamlElement implements BaseIde /** * Initialize a saml:BaseIDAbstractType from scratch * - * @param string|null $nameQualifier + * @param string|null $NameQualifier * The security or administrative domain that qualifies the identifier. * This attribute provides a means to federate identifiers from disparate user stores without collision. - * @param string|null $spNameQualifier + * @param string|null $SPNameQualifier * Further qualifies an identifier with the name of a service provider or affiliation of providers. This * attribute provides an additional means to federate identifiers on the basis of the relying party or parties. */ protected function __construct( - protected ?string $nameQualifier = null, - protected ?string $spNameQualifier = null, + protected ?string $NameQualifier = null, + protected ?string $SPNameQualifier = null, ) { - Assert::nullOrNotWhitespaceOnly($nameQualifier); - Assert::nullOrNotWhitespaceOnly($spNameQualifier); + Assert::nullOrNotWhitespaceOnly($NameQualifier); + Assert::nullOrNotWhitespaceOnly($SPNameQualifier); } diff --git a/src/SAML2/XML/saml/AttributeStatement.php b/src/SAML2/XML/saml/AttributeStatement.php index 5ac843c77..05553bb5a 100644 --- a/src/SAML2/XML/saml/AttributeStatement.php +++ b/src/SAML2/XML/saml/AttributeStatement.php @@ -22,7 +22,7 @@ class AttributeStatement extends AbstractStatementType * @param \SimpleSAML\SAML2\XML\saml\Attribute[] $attributes * @param \SimpleSAML\SAML2\XML\saml\EncryptedAttribute[] $encryptedAttributes */ - public function __construct( + final public function __construct( protected array $attributes = [], protected array $encryptedAttributes = [], ) { diff --git a/src/SAML2/XML/saml/AttributeValue.php b/src/SAML2/XML/saml/AttributeValue.php index 3eb7f6481..9a0b1b431 100644 --- a/src/SAML2/XML/saml/AttributeValue.php +++ b/src/SAML2/XML/saml/AttributeValue.php @@ -27,7 +27,7 @@ class AttributeValue extends AbstractSamlElement /** * Create an AttributeValue. * - * @param mixed $value The value of this element. Can be one of: + * @param string|int|null|\SimpleSAML\XML\AbstractElement $value The value of this element. Can be one of: * - string * - int * - null @@ -35,7 +35,7 @@ class AttributeValue extends AbstractSamlElement * * @throws \SimpleSAML\Assert\AssertionFailedException if the supplied value is neither a string or a DOMElement */ - public function __construct( + final public function __construct( protected string|int|null|AbstractElement $value, ) { } @@ -70,7 +70,7 @@ public function getXsiType(): string /** * Get this attribute value. * - * @return string|int|\SimpleSAML\XML\AbstractElement[]|null + * @return string|int|\SimpleSAML\XML\AbstractElement|null */ public function getValue() { diff --git a/src/SAML2/XML/saml/AudienceRestriction.php b/src/SAML2/XML/saml/AudienceRestriction.php index 57096a8d1..0fbb4c1a3 100644 --- a/src/SAML2/XML/saml/AudienceRestriction.php +++ b/src/SAML2/XML/saml/AudienceRestriction.php @@ -65,7 +65,7 @@ public static function fromXML(DOMElement $xml): static /** * Convert this Audience to XML. * - * @param \DOMElement|null $element The element we are converting to XML. + * @param \DOMElement|null $parent The element we are converting to XML. * @return \DOMElement The XML element after adding the data corresponding to this AudienceRestriction. */ public function toXML(DOMElement $parent = null): DOMElement diff --git a/src/SAML2/XML/saml/EncryptedID.php b/src/SAML2/XML/saml/EncryptedID.php index 2962187b6..0b049c813 100644 --- a/src/SAML2/XML/saml/EncryptedID.php +++ b/src/SAML2/XML/saml/EncryptedID.php @@ -7,7 +7,7 @@ use InvalidArgumentException; use SimpleSAML\SAML2\XML\EncryptedElementTrait; use SimpleSAML\XML\DOMDocumentFactory; -use SimpleSAML\XML\ElementInterface; +use SimpleSAML\XML\SerializableElementInterface; use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmInterface; use SimpleSAML\XMLSecurity\XML\EncryptedElementInterface; @@ -26,10 +26,10 @@ class EncryptedID extends AbstractSamlElement implements EncryptedElementInterfa /** * @inheritDoc * - * @return \SimpleSAML\XML\ElementInterface + * @return \SimpleSAML\XML\SerializableElementInterface * @throws \InvalidArgumentException */ - public function decrypt(EncryptionAlgorithmInterface $decryptor): ElementInterface + public function decrypt(EncryptionAlgorithmInterface $decryptor): SerializableElementInterface { $xml = DOMDocumentFactory::fromString($this->decryptData($decryptor))->documentElement; diff --git a/src/SAML2/XML/saml/IDNameQualifiersTrait.php b/src/SAML2/XML/saml/IDNameQualifiersTrait.php index c573f7657..c321a2370 100644 --- a/src/SAML2/XML/saml/IDNameQualifiersTrait.php +++ b/src/SAML2/XML/saml/IDNameQualifiersTrait.php @@ -18,7 +18,7 @@ trait IDNameQualifiersTrait */ public function getNameQualifier(): ?string { - return $this->nameQualifier; + return $this->NameQualifier; } @@ -29,6 +29,6 @@ public function getNameQualifier(): ?string */ public function getSPNameQualifier(): ?string { - return $this->spNameQualifier; + return $this->SPNameQualifier; } } diff --git a/src/SAML2/XML/saml/Issuer.php b/src/SAML2/XML/saml/Issuer.php index 92512d3a6..1b094fc06 100644 --- a/src/SAML2/XML/saml/Issuer.php +++ b/src/SAML2/XML/saml/Issuer.php @@ -50,8 +50,6 @@ public function __construct( * * From saml-core-2.0-os 8.3.6, when the entity Format is used: "The NameQualifier, SPNameQualifier, and * SPProvidedID attributes MUST be omitted." - * - * @var string */ if ($Format === C::NAMEID_ENTITY || $Format === null) { Assert::allNull( diff --git a/src/SAML2/XML/saml/NameIDType.php b/src/SAML2/XML/saml/NameIDType.php index 935b36d06..3ea679aaf 100644 --- a/src/SAML2/XML/saml/NameIDType.php +++ b/src/SAML2/XML/saml/NameIDType.php @@ -6,6 +6,7 @@ use DOMElement; use SimpleSAML\Assert\Assert; +use SimpleSAML\XML\Exception\InvalidDOMElementException; use SimpleSAML\XML\StringElementTrait; /** @@ -31,15 +32,15 @@ abstract class NameIDType extends AbstractSamlElement implements IdentifierInter */ protected function __construct( string $value, - protected ?string $nameQualifier = null, - protected ?string $spNameQualifier = null, - protected ?string $format = null, - protected ?string $spProvidedID = null, + protected ?string $NameQualifier = null, + protected ?string $SPNameQualifier = null, + protected ?string $Format = null, + protected ?string $SPProvidedID = null, ) { - Assert::nullOrNotWhitespaceOnly($nameQualifier); - Assert::nullOrNotWhitespaceOnly($spNameQualifier); - Assert::nullOrValidURI($format); // Covers the empty string - Assert::nullOrNotWhitespaceOnly($spProvidedID); + Assert::nullOrNotWhitespaceOnly($NameQualifier); + Assert::nullOrNotWhitespaceOnly($SPNameQualifier); + Assert::nullOrValidURI($Format); // Covers the empty string + Assert::nullOrNotWhitespaceOnly($SPProvidedID); $this->setContent($value); } @@ -52,7 +53,7 @@ protected function __construct( */ public function getFormat(): ?string { - return $this->format; + return $this->Format; } @@ -63,7 +64,7 @@ public function getFormat(): ?string */ public function getSPProvidedID(): ?string { - return $this->spProvidedID; + return $this->SPProvidedID; } diff --git a/src/SAML2/XML/saml/SubjectLocality.php b/src/SAML2/XML/saml/SubjectLocality.php index 8deca6b0f..b16194199 100644 --- a/src/SAML2/XML/saml/SubjectLocality.php +++ b/src/SAML2/XML/saml/SubjectLocality.php @@ -26,7 +26,7 @@ public function __construct( protected ?string $dnsName = null, ) { Assert::nullOrIp($address, 'Invalid IP address'); - Assert::nullOrnotWhitespaceOnly($dnsName, 'Invalid DNS name'); + Assert::nullOrNotWhitespaceOnly($dnsName, 'Invalid DNS name'); } diff --git a/src/SAML2/XML/samlp/ArtifactResolve.php b/src/SAML2/XML/samlp/ArtifactResolve.php index 7752d3b18..f3d88fa39 100644 --- a/src/SAML2/XML/samlp/ArtifactResolve.php +++ b/src/SAML2/XML/samlp/ArtifactResolve.php @@ -43,7 +43,7 @@ class ArtifactResolve extends AbstractRequest * * @throws \Exception */ - public function __construct( + final public function __construct( protected string $artifact, DateTimeImmutable $issueInstant, ?Issuer $issuer = null, @@ -151,7 +151,6 @@ protected function toUnsignedXML(?DOMElement $parent = null): DOMElement { Assert::notEmpty($this->artifact, 'Cannot convert ArtifactResolve to XML without an Artifact set.'); - /** @psalm-var \DOMDocument $e->ownerDocument */ $e = parent::toUnsignedXML($parent); $artifactelement = $e->ownerDocument->createElementNS(C::NS_SAMLP, 'Artifact', $this->getArtifact()); $e->appendChild($artifactelement); diff --git a/src/SAML2/XML/samlp/ArtifactResponse.php b/src/SAML2/XML/samlp/ArtifactResponse.php index 9923319c4..fa7a61c5b 100644 --- a/src/SAML2/XML/samlp/ArtifactResponse.php +++ b/src/SAML2/XML/samlp/ArtifactResponse.php @@ -42,7 +42,7 @@ class ArtifactResponse extends AbstractStatusResponse * @param \SimpleSAML\SAML2\XML\samlp\Extensions|null $extensions * @param \SimpleSAML\SAML2\XML\samlp\AbstractMessage|null $message */ - public function __construct( + final public function __construct( Status $status, DateTimeImmutable $issueInstant, ?Issuer $issuer = null, diff --git a/src/SAML2/XML/samlp/AttributeQuery.php b/src/SAML2/XML/samlp/AttributeQuery.php index 3fde70313..4bca73b15 100644 --- a/src/SAML2/XML/samlp/AttributeQuery.php +++ b/src/SAML2/XML/samlp/AttributeQuery.php @@ -52,7 +52,7 @@ class AttributeQuery extends AbstractSubjectQuery * @param string|null $consent * @param \SimpleSAML\SAML2\XML\samlp\Extensions $extensions */ - public function __construct( + final public function __construct( Subject $subject, DateTimeImmutable $issueInstant, protected array $attributes = [], diff --git a/src/SAML2/XML/samlp/AuthnRequest.php b/src/SAML2/XML/samlp/AuthnRequest.php index c35cb24b5..d141192d9 100644 --- a/src/SAML2/XML/samlp/AuthnRequest.php +++ b/src/SAML2/XML/samlp/AuthnRequest.php @@ -51,7 +51,7 @@ class AuthnRequest extends AbstractRequest * @param \SimpleSAML\SAML2\XML\samlp\Scoping|null $scoping * @throws \Exception */ - public function __construct( + final public function __construct( DateTimeImmutable $issueInstant, protected ?RequestedAuthnContext $requestedAuthnContext = null, protected ?Subject $subject = null, diff --git a/src/SAML2/XML/samlp/LogoutRequest.php b/src/SAML2/XML/samlp/LogoutRequest.php index 65349e184..e6bb25ff3 100644 --- a/src/SAML2/XML/samlp/LogoutRequest.php +++ b/src/SAML2/XML/samlp/LogoutRequest.php @@ -205,7 +205,6 @@ public static function fromXML(DOMElement $xml): static */ protected function toUnsignedXML(?DOMElement $parent = null): DOMElement { - /** @psalm-var \DOMDocument $e->ownerDocument */ $e = parent::toUnsignedXML($parent); if ($this->getNotOnOrAfter() !== null) { @@ -216,7 +215,7 @@ protected function toUnsignedXML(?DOMElement $parent = null): DOMElement $e->setAttribute('Reason', $this->getReason()); } - /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $identifier */ + /** @var \SimpleSAML\XML\SerializableElementInterface $identifier */ $identifier = $this->getIdentifier(); $identifier->toXML($e); diff --git a/src/SAML2/XML/samlp/RequestedAuthnContext.php b/src/SAML2/XML/samlp/RequestedAuthnContext.php index 801b9e0d4..02c9900fa 100644 --- a/src/SAML2/XML/samlp/RequestedAuthnContext.php +++ b/src/SAML2/XML/samlp/RequestedAuthnContext.php @@ -73,7 +73,7 @@ public function getRequestedAuthnContexts(): array /** * Collect the value of the Comparison-property * - * @return SimpleSAML\SAML2\XML\Comparison|null + * @return \SimpleSAML\SAML2\XML\Comparison|null */ public function getComparison(): ?Comparison { @@ -114,7 +114,6 @@ public static function fromXML(DOMElement $xml): static */ public function toXML(DOMElement $parent = null): DOMElement { - /** @psalm-var \DOMDocument $e->ownerDocument */ $e = $this->instantiateParentElement($parent); foreach ($this->getRequestedAuthnContexts() as $context) { diff --git a/src/SAML2/XML/samlp/StatusDetail.php b/src/SAML2/XML/samlp/StatusDetail.php index 3e50d7df6..2b13fa5da 100644 --- a/src/SAML2/XML/samlp/StatusDetail.php +++ b/src/SAML2/XML/samlp/StatusDetail.php @@ -81,11 +81,9 @@ public static function fromXML(DOMElement $xml): static */ public function toXML(DOMElement $parent = null): DOMElement { - /** @psalm-var \DOMDocument $e->ownerDocument */ $e = $this->instantiateParentElement($parent); foreach ($this->getElements() as $detail) { - /** @psalm-var \SimpleSAML\XML\SerializableElementInterface $detail */ $detail->toXML($e); }