Skip to content

Commit 14fe494

Browse files
authored
Merge pull request #381 from thecodingmachine/OpenSSLCertificate
WIP: FIX: changed openssl functions typehinting from ressource to OpenSSLCertificate
2 parents 01b0f7d + 7cfb4b1 commit 14fe494

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

generated/openssl.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ function openssl_spki_verify(string $spki): void
13181318
*
13191319
* @param string $data The string of data used to generate the signature previously
13201320
* @param string $signature A raw binary string, generated by openssl_sign or similar means
1321-
* @param resource|string $public_key OpenSSLAsymmetricKey - a key, returned by openssl_get_publickey
1321+
* @param \ OpenSSLAsymmetricKey|\OpenSSLCertificate|string $public_key OpenSSLAsymmetricKey - a key, returned by openssl_get_publickey
13221322
*
13231323
* string - a PEM formatted key, example, "-----BEGIN PUBLIC KEY-----
13241324
* MIIBCgK..."
@@ -1346,7 +1346,7 @@ function openssl_verify(string $data, string $signature, $public_key, $algorithm
13461346
* certificate into a file named by
13471347
* output_filename in a PEM encoded format.
13481348
*
1349-
* @param string|resource $certificate See Key/Certificate parameters for a list of valid values.
1349+
* @param string|\OpenSSLCertificate $certificate See Key/Certificate parameters for a list of valid values.
13501350
* @param string $output_filename Path to the output file.
13511351
* @param bool $no_text
13521352
* The optional parameter notext affects
@@ -1371,7 +1371,7 @@ function openssl_x509_export_to_file($certificate, string $output_filename, bool
13711371
* certificate into a string named by
13721372
* output in a PEM encoded format.
13731373
*
1374-
* @param string|resource $certificate See Key/Certificate parameters for a list of valid values.
1374+
* @param string|\OpenSSLCertificate $certificate See Key/Certificate parameters for a list of valid values.
13751375
* @param string|null $output On success, this will hold the PEM.
13761376
* @param bool $no_text
13771377
* The optional parameter notext affects
@@ -1395,7 +1395,7 @@ function openssl_x509_export($certificate, ?string &$output, bool $no_text = tru
13951395
* openssl_x509_fingerprint returns the digest of
13961396
* certificate as a string.
13971397
*
1398-
* @param string|resource $certificate See Key/Certificate parameters for a list of valid values.
1398+
* @param string|\OpenSSLCertificate $certificate See Key/Certificate parameters for a list of valid values.
13991399
* @param string $digest_algo The digest method or hash algorithm to use, e.g. "sha256", one of openssl_get_md_methods.
14001400
* @param bool $binary When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits.
14011401
* @return string Returns a string containing the calculated certificate fingerprint as lowercase hexits unless binary is set to TRUE in which case the raw binary representation of the message digest is returned.
@@ -1420,12 +1420,12 @@ function openssl_x509_fingerprint($certificate, string $digest_algo = "sha1", bo
14201420
* certificate and returns an OpenSSLCertificate object for
14211421
* it.
14221422
*
1423-
* @param string|resource $certificate X509 certificate. See Key/Certificate parameters for a list of valid values.
1424-
* @return resource Returns an OpenSSLCertificate on success.
1423+
* @param \OpenSSLCertificate|string $certificate X509 certificate. See Key/Certificate parameters for a list of valid values.
1424+
* @return \OpenSSLCertificate Returns an OpenSSLCertificate on success.
14251425
* @throws OpensslException
14261426
*
14271427
*/
1428-
function openssl_x509_read($certificate)
1428+
function openssl_x509_read($certificate): \OpenSSLCertificate
14291429
{
14301430
error_clear_last();
14311431
$safeResult = \openssl_x509_read($certificate);

generator/config/CustomPhpStanFunctionMap.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
'curl_share_errno' => ['int', 'share_handle' => 'CurlShareHandle'],
2727
'curl_share_setopt' => ['void', 'share_handle' => 'CurlShareHandle', 'option' => 'int', 'value' => 'mixed'],
2828
'curl_unescape' => ['string', 'handle' => 'CurlHandle', 'string' => 'string'],
29+
// theses replace ressource by OpenSSLCertificate
30+
'openssl_verify' => ['-1|0|1|false', 'data'=>'string', 'signature'=>'string', 'pub_key_id'=>' OpenSSLAsymmetricKey|OpenSSLCertificate|string', 'signature_alg='=>'int|string'],
31+
'openssl_x509_read' => ['OpenSSLCertificate|false', 'x509certdata'=>'OpenSSLCertificate|string'], // this replaces ressource by OpenSSLCertificate
32+
'openssl_x509_check_private_key' => ['bool', 'cert'=>'string|OpenSSLCertificate', 'key'=>'string|OpenSSLAsymmetricKey|OpenSSLCertificate|array'],
33+
'openssl_x509_checkpurpose' => ['bool|int', 'x509cert'=>'string|OpenSSLCertificate', 'purpose'=>'int', 'cainfo='=>'array', 'untrustedfile='=>'string'],
34+
'openssl_x509_export' => ['bool', 'x509'=>'string|OpenSSLCertificate', '&w_output'=>'string', 'notext='=>'bool'],
35+
'openssl_x509_export_to_file' => ['bool', 'x509'=>'string|OpenSSLCertificate', 'outfilename'=>'string', 'notext='=>'bool'],
36+
'openssl_x509_fingerprint' => ['string|false', 'x509'=>'string|OpenSSLCertificate', 'hash_algorithm='=>'string', 'raw_output='=>'bool'],
37+
2938
'fgetcsv' => ['array|false|null', 'fp'=>'resource', 'length='=>'0|positive-int', 'delimiter='=>'string', 'enclosure='=>'string', 'escape='=>'string'], //phpstan default return type is too hard to analyse
3039
//todo: edit the reader to turn 0|1 into int
3140
'preg_match' => ['int|false', 'pattern'=>'string', 'subject'=>'string', '&w_subpatterns='=>'string[]', 'flags='=>'int', 'offset='=>'int'], //int|false instead of 0|1|false

0 commit comments

Comments
 (0)