Skip to content

Commit

Permalink
Add trailing comma's
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jun 16, 2024
1 parent 418fe22 commit c71753e
Show file tree
Hide file tree
Showing 33 changed files with 75 additions and 70 deletions.
8 changes: 4 additions & 4 deletions src/CryptoEncoding/PEMBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ function ($match) {
$data = base64_decode($payload, true);
if (empty($data)) {
throw new UnexpectedValueException(
'Failed to decode PEM data.'
'Failed to decode PEM data.',
);
}
return new PEM($match[1], $data);
},
$matches
$matches,
);

return new self(...$pems);
Expand Down Expand Up @@ -216,8 +216,8 @@ public function string(): string
function (PEM $pem) {
return $pem->string();
},
$this->pems
)
$this->pems,
),
);
}
}
2 changes: 1 addition & 1 deletion src/Key/PrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final public function __construct(
Assert::oneOf(
$key->type(),
[PEM::TYPE_PRIVATE_KEY, PEM::TYPE_RSA_PRIVATE_KEY],
"PEM structure has the wrong type %s."
"PEM structure has the wrong type %s.",
);

parent::__construct($key);
Expand Down
2 changes: 1 addition & 1 deletion src/Key/PublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final public function __construct(
Assert::oneOf(
$key->type(),
[PEM::TYPE_PUBLIC_KEY, PEM::TYPE_RSA_PUBLIC_KEY],
"PEM structure has the wrong type %s."
"PEM structure has the wrong type %s.",
);

parent::__construct($key);
Expand Down
18 changes: 9 additions & 9 deletions src/TestUtils/PEMCertificatesMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static function getPrivateKey(string $file, string $passphrase = self::PA
* @return string
*/
public static function getPlainCertificate(
string $file = self::CERTIFICATE
string $file = self::CERTIFICATE,
): string {
return self::loadPlainCertificateFile($file);
}
Expand All @@ -131,7 +131,7 @@ public static function getPlainCertificate(
* @return string
*/
public static function getPlainPublicKey(
string $file = self::PUBLIC_KEY
string $file = self::PUBLIC_KEY,
): string {
return self::loadPlainKeyFile($file);
}
Expand All @@ -142,7 +142,7 @@ public static function getPlainPublicKey(
* @return string
*/
public static function getPlainPrivateKey(
string $file = self::PRIVATE_KEY
string $file = self::PRIVATE_KEY,
): string {
return self::loadPlainKeyFile($file);
}
Expand All @@ -153,11 +153,11 @@ public static function getPlainPrivateKey(
* @return string
*/
public static function getPlainCertificateContents(
string $file = self::CERTIFICATE
string $file = self::CERTIFICATE,
): string {
return CertificateUtils::stripHeaders(
self::loadPlainCertificateFile($file),
CertificateUtils::CERTIFICATE_PATTERN
CertificateUtils::CERTIFICATE_PATTERN,
);
}

Expand All @@ -167,11 +167,11 @@ public static function getPlainCertificateContents(
* @return string
*/
public static function getPlainPublicKeyContents(
string $file = self::PUBLIC_KEY
string $file = self::PUBLIC_KEY,
): string {
return CertificateUtils::stripHeaders(
self::loadPlainKeyFile($file),
CertificateUtils::PUBLIC_KEY_PATTERN
CertificateUtils::PUBLIC_KEY_PATTERN,
);
}

Expand All @@ -181,11 +181,11 @@ public static function getPlainPublicKeyContents(
* @return string
*/
public static function getPlainPrivateKeyContents(
string $file = self::PRIVATE_KEY
string $file = self::PRIVATE_KEY,
): string {
return CertificateUtils::stripHeaders(
self::loadPlainCertificateFile($file),
CertificateUtils::PRIVATE_KEY_PATTERN
CertificateUtils::PRIVATE_KEY_PATTERN,
);
}
}
2 changes: 1 addition & 1 deletion src/Utils/Random.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function generateRandomBytes(int $length): string
Assert::positiveInteger(
$length,
'Invalid length received to generate random bytes.',
InvalidArgumentException::class
InvalidArgumentException::class,
);

try {
Expand Down
5 changes: 3 additions & 2 deletions src/Utils/XML.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ class XML
*
* @param \DOMElement $element The DOM element that needs canonicalization.
* @param string $c14nMethod The identifier of the canonicalization algorithm to use.
* See \SimpleSAML\XMLSecurity\Constants.
* See \SimpleSAML\XMLSecurity\Constants.
* @param string[]|null $xpaths An array of xpaths to filter the nodes by. Defaults to null (no filters).
* @param string[]|null $prefixes An array of namespace prefixes to filter the nodes by. Defaults to null (no filters).
* @param string[]|null $prefixes An array of namespace prefixes to filter the nodes by.
* Defaults to null (no filters).
*
* @return string The canonical representation of the given DOM node, according to the algorithm requested.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/XML/SignableElementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public function getId(): ?string;
public function sign(
SignatureAlgorithmInterface $signer,
string $canonicalizationAlg,
?KeyInfo $keyInfo = null
?KeyInfo $keyInfo = null,
): void;
}
2 changes: 1 addition & 1 deletion src/XML/SignableElementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ abstract public function getId(): ?string;
public function sign(
SignatureAlgorithmInterface $signer,
string $canonicalizationAlg = C::C14N_EXCLUSIVE_WITHOUT_COMMENTS,
?KeyInfo $keyInfo = null
?KeyInfo $keyInfo = null,
): void {
$this->signer = $signer;
$this->keyInfo = $keyInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/XML/SignedElementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function verify(SignatureAlgorithmInterface $verifier = null): SignedElem
// build a valid PEM for the certificate
$cert = sprintf(
"-----BEGIN CERTIFICATE-----\n%s\n-----END CERTIFICATE-----",
$data->getRawContent()
$data->getRawContent(),
);

$cert = new Key\X509Certificate(PEM::fromString($cert));
Expand Down
4 changes: 2 additions & 2 deletions src/XML/ds/KeyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function fromXML(DOMElement $xml): static
$RSAKeyValue,
1,
'A <ds:KeyValue> can contain exactly one <ds:RSAKeyValue>',
TooManyElementsException::class
TooManyElementsException::class,
);

$elements = [];
Expand All @@ -95,7 +95,7 @@ public static function fromXML(DOMElement $xml): static
$elements,
1,
'A <ds:KeyValue> can contain exactly one element in namespace ##other',
TooManyElementsException::class
TooManyElementsException::class,
);

return new static(array_pop($RSAKeyValue), array_pop($elements));
Expand Down
8 changes: 4 additions & 4 deletions src/XML/ds/RSAKeyValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ public static function fromXML(DOMElement $xml): static
$modulus,
1,
'An <ds:RSAKeyValue> must contain exactly one <ds:Modulus>',
MissingElementException::class
MissingElementException::class,
);
Assert::maxCount(
$modulus,
1,
'An <ds:RSAKeyValue> must contain exactly one <ds:Modulus>',
TooManyElementsException::class
TooManyElementsException::class,
);

$exponent = Exponent::getChildrenOfClass($xml);
Assert::minCount(
$exponent,
1,
'An <ds:RSAKeyValue> must contain exactly one <ds:Modulus>',
MissingElementException::class
MissingElementException::class,
);
Assert::maxCount(
$exponent,
1,
'An <ds:RSAKeyValue> must contain exactly one <ds:Modulus>',
TooManyElementsException::class
TooManyElementsException::class,
);

return new static(array_pop($modulus), array_pop($exponent));
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/RetrievalMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function fromXML(DOMElement $xml): static
return new static(
array_pop($transforms),
$URI,
$Type
$Type,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/XML/ds/Transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final public function __construct(
sprintf(
'Transform algorithm "%s" or "%s" required if InclusiveNamespaces provided.',
C::C14N_EXCLUSIVE_WITH_COMMENTS,
C::C14N_EXCLUSIVE_WITHOUT_COMMENTS
C::C14N_EXCLUSIVE_WITHOUT_COMMENTS,
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/XML/ec/InclusiveNamespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final public function __construct(
Assert::allString(
$prefixes,
'Can only add string InclusiveNamespaces prefixes.',
InvalidArgumentException::class
InvalidArgumentException::class,
);
Assert::allRegex($prefixes, '/^[a-z0-9._\\-:]*$/i', SchemaViolationException::class); // xsd:NMTOKEN
}
Expand Down
4 changes: 2 additions & 2 deletions src/XML/xenc/CipherData.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ public static function fromXML(DOMElement $xml): static
$cv,
1,
'More than one CipherValue element in <xenc:CipherData>',
TooManyElementsException::class
TooManyElementsException::class,
);

$cr = CipherReference::getChildrenOfClass($xml);
Assert::maxCount(
$cr,
1,
'More than one CipherReference element in <xenc:CipherData>',
TooManyElementsException::class
TooManyElementsException::class,
);

return new static(
Expand Down
2 changes: 1 addition & 1 deletion tests/Alg/Signature/RSASignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function testVerificationFailure(): void
// test wrong key
$rsa = self::$factory->getAlgorithm(
C::SIG_RSA_SHA1,
PEMCertificatesMock::getPublicKey(PEMCertificatesMock::OTHER_PUBLIC_KEY)
PEMCertificatesMock::getPublicKey(PEMCertificatesMock::OTHER_PUBLIC_KEY),
);
$this->assertFalse($rsa->verify(
self::PLAINTEXT,
Expand Down
8 changes: 4 additions & 4 deletions tests/Backend/OpenSSLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ final class OpenSSLTest extends TestCase
public static function setUpBeforeClass(): void
{
self::$privKey = PrivateKey::fromFile(
'file://' . dirname(__FILE__, 3) . '/resources/keys/privkey.pem'
'file://' . dirname(__FILE__, 3) . '/resources/keys/privkey.pem',
);
self::$pubKey = PublicKey::fromFile(
'file://' . dirname(__FILE__, 3) . '/resources/keys/pubkey.pem'
'file://' . dirname(__FILE__, 3) . '/resources/keys/pubkey.pem',
);
self::$sharedKey = new SymmetricKey(hex2bin('54c98b0ea7d98186c27a6c0c6f35ee1a'));
self::$backend = new OpenSSL();
Expand Down Expand Up @@ -142,7 +142,7 @@ public function testDecrypt(): void
'1cb79beec171b9c0cf11466e90187e91377a7f7582f3eec3df6703a1abda89339d0f490bca61ceac743be401d861d50' .
'eb6aaa2db63264cd2013e4008d82c4e7b3f8f13447cf136e52c9b9f06c062a3fe66d3b9f7fa78281d149e7756a97edb' .
'0b2a500f110587f2d81790922def9061c4d8d500cd67ade406b61a20a8fe3b7db1ccc69095a20f556e5ed1f91ccaff1' .
'cb3f13065ebee9e20064b0a75edb2b603af6c'
'cb3f13065ebee9e20064b0a75edb2b603af6c',
),
),
);
Expand All @@ -158,7 +158,7 @@ public function testDecrypt(): void
'4570d9065b9604587111b116e8d15d8ef820f2ea2c1ae129ce27a20c4a7e4df815fb47a047cd11b06ada9f4ad881545' .
'2380a09fb6bff787ff167a20662740e1ac034e66612e2194d8b60a22341032d758fd94221314125dbb2d1432b4a3633' .
'b0857d8d4938aabe1b53ab5f970fb4ad0ed0a554771cfa819cffba8ec5935a6d2f706dfcada355da34b994691c76a60' .
'd10c746a5b683b2a0080d847ff208cf240a1c'
'd10c746a5b683b2a0080d847ff208cf240a1c',
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion tests/XML/CustomSignable.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CustomSignable extends AbstractElement implements
*/
final public function __construct(
protected DOMElement $xml,
protected ?string $id
protected ?string $id,
) {
}

Expand Down
4 changes: 3 additions & 1 deletion tests/XML/CustomSignableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public static function setUpBeforeClass(): void
*/
public function testMarshalling(): void
{
$document = DOMDocumentFactory::fromString(<<<XML
$document = DOMDocumentFactory::fromString(
<<<XML
<ssp:CustomSignable xmlns:ssp="urn:x-simplesamlphp:namespace"><ssp:Chunk>Some</ssp:Chunk></ssp:CustomSignable>
XML
,
);

$customSignable = new CustomSignable($document->documentElement, null);
Expand Down
2 changes: 1 addition & 1 deletion tests/XML/SignableElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function testSigningElementWithIdAndComments(): void

$customSignable->sign($signer, C::C14N_EXCLUSIVE_WITH_COMMENTS, $keyInfo);
$signed = DOMDocumentFactory::fromFile(
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSignedWithCommentsAndId.xml'
dirname(__FILE__, 2) . '/resources/xml/custom_CustomSignableSignedWithCommentsAndId.xml',
);

$this->assertEquals(
Expand Down
2 changes: 1 addition & 1 deletion tests/XML/SignedElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function setUp(): void
)->documentElement;

$this->certificate = PEM::fromString(
PEMCertificatesMock::getPlainCertificate(PEMCertificatesMock::SELFSIGNED_CERTIFICATE)
PEMCertificatesMock::getPlainCertificate(PEMCertificatesMock::SELFSIGNED_CERTIFICATE),
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/XML/ds/DigestMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function testMarshalling(): void
C::DIGEST_SHA256,
[
new Chunk(DOMDocumentFactory::fromString(
'<some:Chunk xmlns:some="urn:test:some">Random</some:Chunk>'
)->documentElement)
'<some:Chunk xmlns:some="urn:test:some">Random</some:Chunk>',
)->documentElement),
],
);

Expand Down
4 changes: 2 additions & 2 deletions tests/XML/ds/KeyInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function setUp(): void
'',
'',
"\n",
''
'',
],
PEMCertificatesMock::getPlainCertificate(PEMCertificatesMock::SELFSIGNED_CERTIFICATE),
);
Expand All @@ -95,7 +95,7 @@ public function testMarshalling(): void
],
),
new Chunk(DOMDocumentFactory::fromString(
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">some</ssp:Chunk>'
'<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">some</ssp:Chunk>',
)->documentElement),
],
'fed654',
Expand Down
4 changes: 2 additions & 2 deletions tests/XML/ds/KeyValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testMarshallingEmpty(): void
{
$this->expectException(SchemaViolationException::class);
$this->expectExceptionMessage(
'A <ds:KeyValue> requires either a RSAKeyValue or an element in namespace ##other'
'A <ds:KeyValue> requires either a RSAKeyValue or an element in namespace ##other',
);

new KeyValue(null, null);
Expand Down Expand Up @@ -147,7 +147,7 @@ public function testUnmarshallingEmpty(): void

$this->expectException(SchemaViolationException::class);
$this->expectExceptionMessage(
'A <ds:KeyValue> requires either a RSAKeyValue or an element in namespace ##other'
'A <ds:KeyValue> requires either a RSAKeyValue or an element in namespace ##other',
);

KeyValue::fromXML($document->documentElement);
Expand Down
Loading

0 comments on commit c71753e

Please sign in to comment.