Skip to content

Commit ecbc1de

Browse files
committed
Add openssl_pkey_get_details function missing in PHP < 8.4
1 parent b065ccb commit ecbc1de

File tree

10 files changed

+35
-63
lines changed

10 files changed

+35
-63
lines changed

generated/8.1/functionsList.php

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.1/rector-migrate.php

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.2/functionsList.php

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.2/rector-migrate.php

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.3/functionsList.php

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.3/rector-migrate.php

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.4/openssl.php

Lines changed: 0 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/8.5/openssl.php

Lines changed: 0 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator/config/CustomPhpStanFunctionMap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'openssl_random_pseudo_bytes' => ['string', 'length'=>'int', '&strong_result='=>'bool'],
2020

2121
// theses replace resource by OpenSSLAsymmetricKey
22+
'openssl_pkey_get_details' => ['array|false', 'key'=>'OpenSSLAsymmetricKey'],
2223
'openssl_pkey_get_private' => ['OpenSSLAsymmetricKey|false', 'private_key'=>'OpenSSLAsymmetricKey|OpenSSLCertificate|array|string', 'passphrase='=>'null|string'],
2324
'openssl_pkey_get_public' => ['OpenSSLAsymmetricKey|false', 'public_key'=>'OpenSSLAsymmetricKey|OpenSSLCertificate|array|string'],
2425
'openssl_csr_sign' => ['resource|false', 'csr'=>'string|OpenSSLCertificateSigningRequest', 'ca_certificate'=>'string|OpenSSLCertificate|null', 'private_key'=>'OpenSSLAsymmetricKey|OpenSSLCertificate|array|string', 'days'=>'int', 'options='=>'array', 'serial='=>'int', 'serial_hex='=>'string|null'],

lib/special_cases.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,34 @@ function openssl_encrypt(string $data, string $method, string $key, int $options
180180
return $result;
181181
}
182182

183+
/**
184+
* This function returns the key details (bits, key, type).
185+
*
186+
* @param \OpenSSLAsymmetricKey $key Resource holding the key.
187+
* @return array Returns an array with the key details on success.
188+
* Returned array has indexes bits (number of bits),
189+
* key (string representation of the public key) and
190+
* type (type of the key which is one of
191+
* OPENSSL_KEYTYPE_RSA,
192+
* OPENSSL_KEYTYPE_DSA,
193+
* OPENSSL_KEYTYPE_DH,
194+
* OPENSSL_KEYTYPE_EC or -1 meaning unknown).
195+
*
196+
* Depending on the key type used, additional details may be returned. Note that
197+
* some elements may not always be available.
198+
* @throws OpensslException
199+
*
200+
*/
201+
function openssl_pkey_get_details(\OpenSSLAsymmetricKey $key): array
202+
{
203+
error_clear_last();
204+
$safeResult = \openssl_pkey_get_details($key);
205+
if ($safeResult === false) {
206+
throw OpensslException::createFromPhpError();
207+
}
208+
return $safeResult;
209+
}
210+
183211
/**
184212
* The function socket_write writes to the
185213
* socket from the given

0 commit comments

Comments
 (0)