Skip to content

Commit 90f3fb4

Browse files
committed
Fix code quality
1 parent e38af41 commit 90f3fb4

File tree

11 files changed

+129
-146
lines changed

11 files changed

+129
-146
lines changed

phpstan-baseline-dev.neon

Lines changed: 111 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ parameters:
66
count: 1
77
path: tests/InterOperability/EntityDescriptorTest.php
88

9+
-
10+
message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\Utilities\\\\ArrayCollection'' and SimpleSAML\\SAML2\\Utilities\\ArrayCollection will always evaluate to true\.$#'
11+
identifier: staticMethod.alreadyNarrowedType
12+
count: 1
13+
path: tests/SAML2/Assertion/ProcessorTest.php
14+
915
-
1016
message: '#^PHPDoc tag @var for property SimpleSAML\\Test\\SAML2\\Assertion\\Transformer\\NameIdDecryptionTransformerTest\:\:\$validator with type SimpleSAML\\SAML2\\Response\\Validation\\Validator is incompatible with native type SimpleSAML\\SAML2\\Signature\\Validator\.$#'
1117
identifier: property.phpDocType
@@ -36,12 +42,24 @@ parameters:
3642
count: 1
3743
path: tests/SAML2/Assertion/Validation/AssertionValidatorTest.php
3844

45+
-
46+
message: '#^Missing call to parent\:\:setUp\(\) method\.$#'
47+
identifier: phpunit.callParent
48+
count: 1
49+
path: tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
50+
3951
-
4052
message: '#^Parameter \#1 \$serviceProvider of method SimpleSAML\\SAML2\\Assertion\\Validation\\ConstraintValidator\\SpIsValidAudience\:\:setServiceProvider\(\) expects SimpleSAML\\SAML2\\Configuration\\ServiceProvider, Mockery\\MockInterface given\.$#'
4153
identifier: argument.type
4254
count: 3
4355
path: tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php
4456

57+
-
58+
message: '#^Missing call to parent\:\:setUp\(\) method\.$#'
59+
identifier: phpunit.callParent
60+
count: 1
61+
path: tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationResponseToMatchesTest.php
62+
4563
-
4664
message: '#^Parameter \#1 \$response of class SimpleSAML\\SAML2\\Assertion\\Validation\\ConstraintValidator\\SubjectConfirmationResponseToMatches constructor expects SimpleSAML\\SAML2\\XML\\samlp\\Response, Mockery\\MockInterface given\.$#'
4765
identifier: argument.type
@@ -66,38 +84,122 @@ parameters:
6684
count: 3
6785
path: tests/SAML2/Certificate/KeyLoaderTest.php
6886

87+
-
88+
message: '#^Missing call to parent\:\:setUp\(\) method\.$#'
89+
identifier: phpunit.callParent
90+
count: 1
91+
path: tests/SAML2/Certificate/KeyLoaderTest.php
92+
6993
-
7094
message: '#^Parameter \#1 \$config of method SimpleSAML\\SAML2\\Certificate\\KeyLoader\:\:loadKeysFromConfiguration\(\) expects SimpleSAML\\SAML2\\Configuration\\CertificateProvider, Mockery\\MockInterface given\.$#'
7195
identifier: argument.type
7296
count: 3
7397
path: tests/SAML2/Certificate/KeyLoaderTest.php
7498

99+
-
100+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\XMLSecurity\\\\Key\\\\PrivateKey'' and SimpleSAML\\XMLSecurity\\Key\\PrivateKey will always evaluate to true\.$#'
101+
identifier: method.alreadyNarrowedType
102+
count: 1
103+
path: tests/SAML2/Certificate/PrivateKeyLoaderTest.php
104+
105+
-
106+
message: '#^Missing call to parent\:\:setUp\(\) method\.$#'
107+
identifier: phpunit.callParent
108+
count: 1
109+
path: tests/SAML2/Response/SignatureValidationTest.php
110+
111+
-
112+
message: '#^Missing call to parent\:\:setUp\(\) method\.$#'
113+
identifier: phpunit.callParent
114+
count: 1
115+
path: tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
116+
75117
-
76118
message: '#^Parameter \#1 \$response of method SimpleSAML\\SAML2\\Response\\Validation\\ConstraintValidator\\DestinationMatches\:\:validate\(\) expects SimpleSAML\\SAML2\\XML\\samlp\\Response, Mockery\\MockInterface given\.$#'
77119
identifier: argument.type
78120
count: 2
79121
path: tests/SAML2/Response/Validation/ConstraintValidator/DestinationMatchesTest.php
80122

123+
-
124+
message: '#^Missing call to parent\:\:setUp\(\) method\.$#'
125+
identifier: phpunit.callParent
126+
count: 1
127+
path: tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
128+
81129
-
82130
message: '#^Parameter \#1 \$response of method SimpleSAML\\SAML2\\Response\\Validation\\ConstraintValidator\\IsSuccessful\:\:validate\(\) expects SimpleSAML\\SAML2\\XML\\samlp\\Response, Mockery\\MockInterface given\.$#'
83131
identifier: argument.type
84132
count: 2
85133
path: tests/SAML2/Response/Validation/ConstraintValidator/IsSuccessfulTest.php
86134

87135
-
88-
message: '#^Parameter \#1 \$xml of static method SimpleSAML\\SAML2\\XML\\saml\\Assertion\:\:fromXML\(\) expects DOMElement, DOMNode\|null given\.$#'
89-
identifier: argument.type
136+
message: '#^Missing call to parent\:\:setUp\(\) method\.$#'
137+
identifier: phpunit.callParent
138+
count: 1
139+
path: tests/SAML2/Signature/PublicKeyValidatorTest.php
140+
141+
-
142+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''ArrayIterator'' and ArrayIterator will always evaluate to true\.$#'
143+
identifier: method.alreadyNarrowedType
144+
count: 1
145+
path: tests/SAML2/Utilities/ArrayCollectionTest.php
146+
147+
-
148+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\Utilities\\\\ArrayCollection'' and SimpleSAML\\SAML2\\Utilities\\ArrayCollection will always evaluate to true\.$#'
149+
identifier: method.alreadyNarrowedType
90150
count: 2
91-
path: tests/SAML2/Response/XmlSignatureWrappingTest.php
151+
path: tests/SAML2/Utilities/ArrayCollectionTest.php
152+
153+
-
154+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AdditionalMetadataLocation'' and SimpleSAML\\SAML2\\XML\\md\\AdditionalMetadataLocation will always evaluate to true\.$#'
155+
identifier: method.alreadyNarrowedType
156+
count: 2
157+
path: tests/SAML2/XML/md/EntityDescriptorTest.php
158+
159+
-
160+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\ContactPerson'' and SimpleSAML\\SAML2\\XML\\md\\ContactPerson will always evaluate to true\.$#'
161+
identifier: method.alreadyNarrowedType
162+
count: 3
163+
path: tests/SAML2/XML/md/EntityDescriptorTest.php
92164

93165
-
94-
message: '#^Class SimpleSAML\\Test\\SAML2\\XML\\md\\AssertionFailedException not found\.$#'
95-
identifier: class.notFound
166+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\SingleSignOnService'' and SimpleSAML\\SAML2\\XML\\md\\SingleSignOnService will always evaluate to true\.$#'
167+
identifier: method.alreadyNarrowedType
96168
count: 1
97-
path: tests/SAML2/XML/md/RequestedAttributeTest.php
169+
path: tests/SAML2/XML/md/IDPSSODescriptorTest.php
98170

99171
-
100-
message: '#^Parameter \#1 \$exception of method PHPUnit\\Framework\\TestCase\:\:expectException\(\) expects class\-string\<Throwable\>, string given\.$#'
101-
identifier: argument.type
172+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\AbstractRoleDescriptor'' and SimpleSAML\\SAML2\\XML\\md\\AbstractRoleDescriptor will always evaluate to true\.$#'
173+
identifier: method.alreadyNarrowedType
174+
count: 1
175+
path: tests/SAML2/XML/md/RoleDescriptorTest.php
176+
177+
-
178+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\ContactPerson'' and SimpleSAML\\SAML2\\XML\\md\\ContactPerson will always evaluate to true\.$#'
179+
identifier: method.alreadyNarrowedType
180+
count: 4
181+
path: tests/SAML2/XML/md/RoleDescriptorTest.php
182+
183+
-
184+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\XML\\\\md\\\\KeyDescriptor'' and SimpleSAML\\SAML2\\XML\\md\\KeyDescriptor will always evaluate to true\.$#'
185+
identifier: method.alreadyNarrowedType
186+
count: 4
187+
path: tests/SAML2/XML/md/RoleDescriptorTest.php
188+
189+
-
190+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\NameID'' and SimpleSAML\\SAML2\\XML\\saml\\NameID will always evaluate to true\.$#'
191+
identifier: method.alreadyNarrowedType
192+
count: 1
193+
path: tests/SAML2/XML/saml/AssertionTest.php
194+
195+
-
196+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\SAML2\\\\XML\\\\saml\\\\NameID'' and array\<SimpleSAML\\SAML2\\XML\\saml\\AttributeValue\|SimpleSAML\\SAML2\\XML\\saml\\IdentifierInterface\> will always evaluate to false\.$#'
197+
identifier: method.impossibleType
198+
count: 4
199+
path: tests/SAML2/XML/saml/AssertionTest.php
200+
201+
-
202+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''SimpleSAML\\\\Test\\\\SAML2\\\\CustomStatement'' and SimpleSAML\\Test\\SAML2\\CustomStatement will always evaluate to true\.$#'
203+
identifier: method.alreadyNarrowedType
102204
count: 1
103-
path: tests/SAML2/XML/md/RequestedAttributeTest.php
205+
path: tests/SAML2/XML/saml/StatementTest.php

phpstan-baseline.neon

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -72,108 +72,6 @@ parameters:
7272
count: 2
7373
path: src/Binding/HTTPArtifact.php
7474

75-
-
76-
message: '#^Call to an undefined method SimpleSAML\\XMLSecurity\\XML\\ds\\SignatureValue\:\:getContent\(\)\.$#'
77-
identifier: method.notFound
78-
count: 1
79-
path: src/Binding/HTTPRedirect.php
80-
81-
-
82-
message: '#^Access to constant RSA_1_5 on an unknown class SimpleSAML\\XMLSecurity\\XMLSecurityKey\.$#'
83-
identifier: class.notFound
84-
count: 1
85-
path: src/Certificate/PrivateKeyLoader.php
86-
87-
-
88-
message: '#^Access to property \$passphrase on an unknown class SimpleSAML\\XMLSecurity\\XMLSecurityKey\.$#'
89-
identifier: class.notFound
90-
count: 2
91-
path: src/Certificate/PrivateKeyLoader.php
92-
93-
-
94-
message: '#^Call to method loadKey\(\) on an unknown class SimpleSAML\\XMLSecurity\\XMLSecurityKey\.$#'
95-
identifier: class.notFound
96-
count: 2
97-
path: src/Certificate/PrivateKeyLoader.php
98-
99-
-
100-
message: '#^Instantiated class SimpleSAML\\XMLSecurity\\XMLSecurityKey not found\.$#'
101-
identifier: class.notFound
102-
count: 2
103-
path: src/Certificate/PrivateKeyLoader.php
104-
105-
-
106-
message: '#^Method SimpleSAML\\SAML2\\Certificate\\PrivateKeyLoader\:\:convertPrivateKeyToRsaKey\(\) has invalid return type SimpleSAML\\XMLSecurity\\XMLSecurityKey\.$#'
107-
identifier: class.notFound
108-
count: 2
109-
path: src/Certificate/PrivateKeyLoader.php
110-
111-
-
112-
message: '#^Call to method getArray\(\) on an unknown class SimpleSAML\\Configuration\.$#'
113-
identifier: class.notFound
114-
count: 1
115-
path: src/Configuration/SimpleSAMLConverter.php
116-
117-
-
118-
message: '#^Call to method getBoolean\(\) on an unknown class SimpleSAML\\Configuration\.$#'
119-
identifier: class.notFound
120-
count: 2
121-
path: src/Configuration/SimpleSAMLConverter.php
122-
123-
-
124-
message: '#^Call to method getString\(\) on an unknown class SimpleSAML\\Configuration\.$#'
125-
identifier: class.notFound
126-
count: 10
127-
path: src/Configuration/SimpleSAMLConverter.php
128-
129-
-
130-
message: '#^Call to method getValue\(\) on an unknown class SimpleSAML\\Configuration\.$#'
131-
identifier: class.notFound
132-
count: 1
133-
path: src/Configuration/SimpleSAMLConverter.php
134-
135-
-
136-
message: '#^Call to method hasValue\(\) on an unknown class SimpleSAML\\Configuration\.$#'
137-
identifier: class.notFound
138-
count: 7
139-
path: src/Configuration/SimpleSAMLConverter.php
140-
141-
-
142-
message: '#^Parameter \$configuration of method SimpleSAML\\SAML2\\Configuration\\SimpleSAMLConverter\:\:convertToIdentityProvider\(\) has invalid type SimpleSAML\\Configuration\.$#'
143-
identifier: class.notFound
144-
count: 2
145-
path: src/Configuration/SimpleSAMLConverter.php
146-
147-
-
148-
message: '#^Parameter \$configuration of method SimpleSAML\\SAML2\\Configuration\\SimpleSAMLConverter\:\:convertToServiceProvider\(\) has invalid type SimpleSAML\\Configuration\.$#'
149-
identifier: class.notFound
150-
count: 2
151-
path: src/Configuration/SimpleSAMLConverter.php
152-
153-
-
154-
message: '#^Parameter \$configuration of method SimpleSAML\\SAML2\\Configuration\\SimpleSAMLConverter\:\:enrichForDecryptionProvider\(\) has invalid type SimpleSAML\\Configuration\.$#'
155-
identifier: class.notFound
156-
count: 2
157-
path: src/Configuration/SimpleSAMLConverter.php
158-
159-
-
160-
message: '#^Parameter \$configuration of method SimpleSAML\\SAML2\\Configuration\\SimpleSAMLConverter\:\:enrichForIdentityProvider\(\) has invalid type SimpleSAML\\Configuration\.$#'
161-
identifier: class.notFound
162-
count: 2
163-
path: src/Configuration/SimpleSAMLConverter.php
164-
165-
-
166-
message: '#^Parameter \$configuration of method SimpleSAML\\SAML2\\Configuration\\SimpleSAMLConverter\:\:enrichForServiceProvider\(\) has invalid type SimpleSAML\\Configuration\.$#'
167-
identifier: class.notFound
168-
count: 2
169-
path: src/Configuration/SimpleSAMLConverter.php
170-
171-
-
172-
message: '#^Parameter \$configuration of method SimpleSAML\\SAML2\\Configuration\\SimpleSAMLConverter\:\:pluckConfiguration\(\) has invalid type SimpleSAML\\Configuration\.$#'
173-
identifier: class.notFound
174-
count: 2
175-
path: src/Configuration/SimpleSAMLConverter.php
176-
17775
-
17876
message: '#^Access to property \$key on an unknown class SimpleSAML\\XMLSecurity\\XMLSecurityKey\.$#'
17977
identifier: class.notFound
@@ -300,30 +198,12 @@ parameters:
300198
count: 1
301199
path: src/XML/md/Organization.php
302200

303-
-
304-
message: '#^Call to an undefined method SimpleSAML\\XMLSchema\\Type\\Interface\\ValueTypeInterface\:\:toArray\(\)\.$#'
305-
identifier: method.notFound
306-
count: 1
307-
path: src/XML/mdui/Keywords.php
308-
309201
-
310202
message: '#^Unsafe usage of new static\(\)\.$#'
311203
identifier: new.static
312204
count: 1
313205
path: src/XML/saml/Attribute.php
314206

315-
-
316-
message: '#^Unsafe usage of new static\(\)\.$#'
317-
identifier: new.static
318-
count: 1
319-
path: src/XML/saml/EncryptedAttribute.php
320-
321-
-
322-
message: '#^Unsafe usage of new static\(\)\.$#'
323-
identifier: new.static
324-
count: 1
325-
path: src/XML/saml/EncryptedID.php
326-
327207
-
328208
message: '#^Unsafe usage of new static\(\)\.$#'
329209
identifier: new.static

phpstan-dev.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ parameters:
22
level: 5
33
paths:
44
- tests
5-
#includes:
6-
# - phpstan-baseline-dev.neon
5+
includes:
6+
- phpstan-baseline-dev.neon

phpstan.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ parameters:
22
level: 2
33
paths:
44
- src
5-
#includes:
6-
# - phpstan-baseline.neon
5+
includes:
6+
- phpstan-baseline.neon

src/XML/EncryptedElementTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ trait EncryptedElementTrait
3131
* Constructor for encrypted elements.
3232
*
3333
* @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptedData $encryptedData The EncryptedData object.
34-
* @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey[] $encryptedKey The EncryptedKey objects.
34+
* @param \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey[] $decryptionKeys The EncryptedKey objects.
3535
*/
3636
final public function __construct(
3737
protected EncryptedData $encryptedData,

tests/SAML2/Response/XmlSignatureWrappingTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ public function testThatASignatureReferencingAnotherAssertionIsNotValid(): void
6666
*/
6767
private function getSignedAssertionWithSignatureThatReferencesAnotherAssertion(): Assertion
6868
{
69-
$doc = DOMDocumentFactory::fromFile(__DIR__ . '/signedAssertionWithInvalidReferencedId.xml');
70-
return Assertion::fromXML($doc->firstChild);
69+
$document = DOMDocumentFactory::fromFile(__DIR__ . '/signedAssertionWithInvalidReferencedId.xml');
70+
/** @var \DOMElement $element */
71+
$element = $document->firstChild;
72+
return Assertion::fromXML($element);
7173
}
7274

7375

@@ -77,6 +79,8 @@ private function getSignedAssertionWithSignatureThatReferencesAnotherAssertion()
7779
private function getSignedAssertionWithEmbeddedAssertionReferencedInSignature(): Assertion
7880
{
7981
$document = DOMDocumentFactory::fromFile(__DIR__ . '/signedAssertionReferencedEmbeddedAssertion.xml');
80-
return Assertion::fromXML($document->firstChild);
82+
/** @var \DOMElement $element */
83+
$element = $document->firstChild;
84+
return Assertion::fromXML($element);
8185
}
8286
}

tests/SAML2/Type/AnyURIListValueTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testAnyURIList(bool $shouldPass, string $anyURIList): void
3131
try {
3232
AnyURIListValue::fromString($anyURIList);
3333
$this->assertTrue($shouldPass);
34-
} catch (ProtocolViolationException|SchemaViolationException $e) {
34+
} catch (ProtocolViolationException | SchemaViolationException $e) {
3535
$this->assertFalse($shouldPass);
3636
}
3737
}
@@ -48,7 +48,7 @@ public function testToArray(): void
4848

4949

5050
/**
51-
* @return array<string, array{0: true, 1: string}>
51+
* @return array<array{0: bool, 1: string}>
5252
*/
5353
public static function provideAnyURIList(): array
5454
{

tests/SAML2/XML/md/RequestedAttributeTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPUnit\Framework\Attributes\CoversClass;
88
use PHPUnit\Framework\Attributes\Group;
99
use PHPUnit\Framework\TestCase;
10-
use SimpleSAML\Assert\AssertionFailedException;
1110
use SimpleSAML\SAML2\Constants as C;
1211
use SimpleSAML\SAML2\Type\SAMLAnyURIValue;
1312
use SimpleSAML\SAML2\Type\SAMLStringValue;

tests/SAML2/XML/saml/AdviceTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use SimpleSAML\SAML2\XML\saml\Assertion;
1414
use SimpleSAML\SAML2\XML\saml\AssertionIDRef;
1515
use SimpleSAML\SAML2\XML\saml\AssertionURIRef;
16-
use SimpleSAML\SAML2\XML\saml\EncryptedAssertion;
1716
use SimpleSAML\XML\Chunk;
1817
use SimpleSAML\XML\DOMDocumentFactory;
1918
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;

0 commit comments

Comments
 (0)