Skip to content

Commit

Permalink
Add stub for $tag of openssl_encrypt()
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Dec 22, 2024
1 parent b5fc9ec commit 1663a9f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions conf/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ parameters:
- ../stubs/arrayFunctions.stub
- ../stubs/core.stub
- ../stubs/typeCheckingFunctions.stub
- ../stubs/openssl.stub
earlyTerminatingMethodCalls: []
earlyTerminatingFunctionCalls: []
memoryLimitFile: %tmpDir%/.memory_limit
Expand Down
17 changes: 17 additions & 0 deletions stubs/openssl.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* @param-out string $tag
*
* @return string|false
*/
function openssl_encrypt(
#[\SensitiveParameter] string $data,
string $cipher_algo,
#[\SensitiveParameter] string $passphrase,
int $options = 0,
string $iv = "",
?string &$tag = null,
string $aad = "",
int $tag_length = 16
) {}
8 changes: 8 additions & 0 deletions tests/PHPStan/Analyser/nsrt/openssl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

use function PHPStan\Testing\assertType;

$ciphertext = openssl_encrypt('plain text', 'aes-256-gcm', 'key', OPENSSL_RAW_DATA, 'iv', $tag, '', 16);

assertType('string|false', $ciphertext);
assertType('string', $tag);

0 comments on commit 1663a9f

Please sign in to comment.