phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

Add stub for openssl_sign() function

Open piotrekkr opened this issue 1 year ago • 10 comments

Adding openssl_sign() stub so PHPStan will correctly deduce $signature variable type which is now shown as mixed instead of string.

Fixes https://github.com/phpstan/phpstan/issues/11791

piotrekkr avatar Oct 03 '24 11:10 piotrekkr

You've opened the pull request against the latest branch 2.0.x. PHPStan 2.0 is not going to be released for months. If your code is relevant on 1.12.x and you want it to be released sooner, please rebase your pull request and change its target to 1.12.x.

phpstan-bot avatar Oct 03 '24 11:10 phpstan-bot

Will rebase properly in a minute

piotrekkr avatar Oct 03 '24 11:10 piotrekkr

@ondrejmirtes Added it to conf/config.neon

piotrekkr avatar Oct 03 '24 12:10 piotrekkr

Do I need to type all arguments or just this @param-out and the rest will be taken from signature? Asking because tests fail https://github.com/phpstan/phpstan-src/actions/runs/11162040542/job/31025901918 and they mention $private_key which is typed in function but seems like it is not enough.

piotrekkr avatar Oct 03 '24 12:10 piotrekkr

Do I need to type all arguments

Copy the PHPdoc from jetbrains/phpstorm-stubs and leave out unimportant stuff like description.

ondrejmirtes avatar Oct 04 '24 08:10 ondrejmirtes

@ondrejmirtes I've updated phpdoc. Let me know if I need to do something more. Thanks

piotrekkr avatar Oct 04 '24 09:10 piotrekkr

@ondrejmirtes I think there is some bug in PHP manual of this openssl_sign() function. They mention about private key that can be one of those

#[\SensitiveParameter] OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key,

In description of input params, there is no mention of array, so my guess is that array is not allowed. I removed it from stub but not sure if it is good way to go. Lent me know what you think.

piotrekkr avatar Oct 04 '24 10:10 piotrekkr

Made bug report for php docs https://github.com/php/doc-en/issues/3829

piotrekkr avatar Oct 04 '24 10:10 piotrekkr

Also signature changed in PHP 8 so I should probably create two stub files right? Something like openssl.stub and openssl_php8.stub. Then do it similar to this to have both new and older php handled. Is it correct?

piotrekkr avatar Oct 04 '24 10:10 piotrekkr

Okay asked about this array in private_key and it seems it is correct but docs are not updated properly so will need to wait for it to be updated and will then update this PR

piotrekkr avatar Oct 07 '24 08:10 piotrekkr

I'll close this since there is no progress here.

piotrekkr avatar Aug 11 '25 07:08 piotrekkr