diff --git a/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php b/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php index 2bec045b..4b976ae8 100644 --- a/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php +++ b/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php @@ -129,10 +129,8 @@ abstract class PKCS8 extends PKCS /** * Returns a SymmetricKey object based on a PBES1 $algo - * - * @return SymmetricKey */ - private static function getPBES1EncryptionObject(string $algo) + private static function getPBES1EncryptionObject(string $algo): SymmetricKey { $algo = preg_match('#^pbeWith(?:MD2|MD5|SHA1|SHA)And(.*?)-CBC$#', $algo, $matches) ? $matches[1] : @@ -511,7 +509,7 @@ abstract class PKCS8 extends PKCS * * @param bool $enabled */ - public static function setBinaryOutput($enabled) + public static function setBinaryOutput($enabled): void { self::$binary = $enabled; } @@ -616,7 +614,7 @@ abstract class PKCS8 extends PKCS $key = ASN1::encodeDER($key, Maps\EncryptedPrivateKeyInfo::MAP); - if (isset($options['binary']) ? $options['binary'] : self::$binary) { + if ($options['binary'] ?? self::$binary) { return $key; } @@ -625,7 +623,7 @@ abstract class PKCS8 extends PKCS "-----END ENCRYPTED PRIVATE KEY-----"; } - if (isset($options['binary']) ? $options['binary'] : self::$binary) { + if ($options['binary'] ?? self::$binary) { return $key; } @@ -654,7 +652,7 @@ abstract class PKCS8 extends PKCS $key = ASN1::encodeDER($key, Maps\PublicKeyInfo::MAP); - if (isset($options['binary']) ? $options['binary'] : self::$binary) { + if ($options['binary'] ?? self::$binary) { return $key; } diff --git a/phpseclib/File/ASN1/Maps/TBSCertList.php b/phpseclib/File/ASN1/Maps/TBSCertList.php index a0b56f4a..49f216c1 100644 --- a/phpseclib/File/ASN1/Maps/TBSCertList.php +++ b/phpseclib/File/ASN1/Maps/TBSCertList.php @@ -31,7 +31,7 @@ abstract class TBSCertList 'type' => ASN1::TYPE_INTEGER, 'mapping' => ['v1', 'v2'], 'optional' => true, - 'default' => 'v1' + 'default' => 'v1', ], 'signature' => AlgorithmIdentifier::MAP, 'issuer' => Name::MAP, diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index cf77cc94..8297e5ea 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -3361,7 +3361,6 @@ class X509 * Returns the list of extensions if there are any and false if not * * @param array $csr optional - * @return mixed */ public function getRequestedCertificateExtensions(array $csr = null) { diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index b6739e13..5f59ed34 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -3273,7 +3273,7 @@ class SFTP extends SSH2 } // if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED - list($status) = Strings::unpackSSH2('N', $response); + [$status] = Strings::unpackSSH2('N', $response); if ($status != StatusCode::OK) { $this->logError($response, $status); return false; diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 9afa3712..ecd1a969 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -3520,7 +3520,7 @@ class SSH2 private function handleDisconnect($payload) { Strings::shift($payload, 1); - list($reason_code, $message) = Strings::unpackSSH2('Ns', $payload); + [$reason_code, $message] = Strings::unpackSSH2('Ns', $payload); $this->errors[] = 'SSH_MSG_DISCONNECT: ' . self::$disconnect_reasons[$reason_code] . "\r\n$message"; $this->disconnect_helper(NET_SSH2_DISCONNECT_CONNECTION_LOST); throw new ConnectionClosedException('Connection closed by server'); diff --git a/tests/Unit/File/X509/CSRTest.php b/tests/Unit/File/X509/CSRTest.php index a6809987..2b50519f 100644 --- a/tests/Unit/File/X509/CSRTest.php +++ b/tests/Unit/File/X509/CSRTest.php @@ -184,7 +184,7 @@ yGSdZsGMatjn2ld+Ndj3uAYlujyKlqGcAOb53bu+PswH5KXTJJquOJH84UoKraog $this->assertTrue(boolval($x509->getPublicKey()->getPadding() & RSA::SIGNATURE_PSS)); } - public function testAttributes() + public function testAttributes(): void { $private = RSA::createKey(); $private = $private->withHash('sha256'); @@ -205,7 +205,7 @@ yGSdZsGMatjn2ld+Ndj3uAYlujyKlqGcAOb53bu+PswH5KXTJJquOJH84UoKraog $extensions = [ ['extnId' => 'id-ce-basicConstraints', 'critical' => true, 'extnValue' => ['cA' => false]], ['extnId' => 'id-ce-keyUsage', 'critical' => true, 'extnValue' => ['digitalSignature', 'keyEncipherment']], - ['extnId' => 'id-ce-extKeyUsage', 'extnValue' => ['id-kp-serverAuth', 'id-kp-clientAuth']] + ['extnId' => 'id-ce-extKeyUsage', 'extnValue' => ['id-kp-serverAuth', 'id-kp-clientAuth']], ]; $subject->setAttribute('pkcs-9-at-extensionRequest', $extensions); diff --git a/tests/Unit/Net/SSH2UnitTest.php b/tests/Unit/Net/SSH2UnitTest.php index 3ec03152..b329c6ca 100644 --- a/tests/Unit/Net/SSH2UnitTest.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -42,9 +42,7 @@ class SSH2UnitTest extends PhpseclibTestCase public function testBitmapMasks(): void { $reflection = new \ReflectionClass(SSH2::class); - $masks = array_filter($reflection->getConstants(), function ($k) { - return str_starts_with($k, 'MASK_'); - }, ARRAY_FILTER_USE_KEY); + $masks = array_filter($reflection->getConstants(), fn ($k) => str_starts_with($k, 'MASK_'), ARRAY_FILTER_USE_KEY); $bitmap = 0; foreach ($masks as $mask => $bit) { $this->assertEquals(0, $bitmap & $bit, "Got unexpected mask {$mask}");