From 5938b8437d74a5068148ff48d0023ae5af72abc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kroczy=C5=84ski?= Date: Thu, 3 Oct 2024 13:51:08 +0200 Subject: [PATCH 1/7] 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 --- stubs/openssl.stub | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 stubs/openssl.stub diff --git a/stubs/openssl.stub b/stubs/openssl.stub new file mode 100644 index 0000000000..0dda8f07de --- /dev/null +++ b/stubs/openssl.stub @@ -0,0 +1,13 @@ + Date: Thu, 3 Oct 2024 14:32:36 +0200 Subject: [PATCH 2/7] Add openssl.stub to config.neon --- conf/config.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/config.neon b/conf/config.neon index 67351dc4da..cfe0677d2a 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -201,6 +201,7 @@ parameters: - ../stubs/arrayFunctions.stub - ../stubs/core.stub - ../stubs/typeCheckingFunctions.stub + - ../stubs/openssl.stub earlyTerminatingMethodCalls: [] earlyTerminatingFunctionCalls: [] memoryLimitFile: %tmpDir%/.memory_limit From 2c85eb7ce882c66728ff9fefb4c548b0833c14e1 Mon Sep 17 00:00:00 2001 From: Piotr Date: Fri, 4 Oct 2024 11:32:42 +0200 Subject: [PATCH 3/7] Update openssl.stub --- stubs/openssl.stub | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/stubs/openssl.stub b/stubs/openssl.stub index 0dda8f07de..888957b29d 100644 --- a/stubs/openssl.stub +++ b/stubs/openssl.stub @@ -1,13 +1,18 @@ 'OpenSSLAsymmetricKey|OpenSSLCertificate|array|string'], default: 'resource|array|string')] $private_key, string|int $algorithm = OPENSSL_ALGO_SHA1 -): bool -{ -} +): bool {} From 16edb9903b037570efe011ac540b8d7f5a702d47 Mon Sep 17 00:00:00 2001 From: Piotr Date: Fri, 4 Oct 2024 11:35:23 +0200 Subject: [PATCH 4/7] Update openssl.stub --- stubs/openssl.stub | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/openssl.stub b/stubs/openssl.stub index 888957b29d..6ba0d4be39 100644 --- a/stubs/openssl.stub +++ b/stubs/openssl.stub @@ -10,9 +10,9 @@ * * @return bool */ -function openssl_sign( + openssl_sign( string $data, - &$signature, - #[LanguageLevelTypeAware(['8.0' => 'OpenSSLAsymmetricKey|OpenSSLCertificate|array|string'], default: 'resource|array|string')] $private_key, + string &$signature, + #[\SensitiveParameter] OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key, string|int $algorithm = OPENSSL_ALGO_SHA1 ): bool {} From 56276272619d3040707ece02f0039e2e2f175004 Mon Sep 17 00:00:00 2001 From: Piotr Date: Fri, 4 Oct 2024 11:51:43 +0200 Subject: [PATCH 5/7] Update openssl.stub --- stubs/openssl.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/openssl.stub b/stubs/openssl.stub index 6ba0d4be39..dc9f611917 100644 --- a/stubs/openssl.stub +++ b/stubs/openssl.stub @@ -10,9 +10,9 @@ * * @return bool */ - openssl_sign( +function openssl_sign( string $data, string &$signature, - #[\SensitiveParameter] OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key, + #[\SensitiveParameter] \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $private_key, string|int $algorithm = OPENSSL_ALGO_SHA1 ): bool {} From 20114e4d4abaed4241610325b53feb2719a212fe Mon Sep 17 00:00:00 2001 From: Piotr Date: Fri, 4 Oct 2024 12:17:39 +0200 Subject: [PATCH 6/7] Update openssl.stub --- stubs/openssl.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/openssl.stub b/stubs/openssl.stub index dc9f611917..fb2aa24083 100644 --- a/stubs/openssl.stub +++ b/stubs/openssl.stub @@ -3,7 +3,7 @@ /** * @param string $data * @param string &$signature - * @param OpenSSLAsymmetricKey|OpenSSLCertificate|array|string $private_key + * @param \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $private_key * @param string|int $algorithm * * @param-out string $signature @@ -13,6 +13,6 @@ function openssl_sign( string $data, string &$signature, - #[\SensitiveParameter] \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $private_key, + \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $private_key, string|int $algorithm = OPENSSL_ALGO_SHA1 ): bool {} From fe15fb82c9b9ec21c5df4fab8ff7c1e63fcab9b8 Mon Sep 17 00:00:00 2001 From: Piotr Date: Fri, 4 Oct 2024 12:24:33 +0200 Subject: [PATCH 7/7] Update openssl.stub --- stubs/openssl.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/openssl.stub b/stubs/openssl.stub index fb2aa24083..6a9ff0208a 100644 --- a/stubs/openssl.stub +++ b/stubs/openssl.stub @@ -3,7 +3,7 @@ /** * @param string $data * @param string &$signature - * @param \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $private_key + * @param \OpenSSLAsymmetricKey|\OpenSSLCertificate|string $private_key * @param string|int $algorithm * * @param-out string $signature @@ -13,6 +13,6 @@ function openssl_sign( string $data, string &$signature, - \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $private_key, + \OpenSSLAsymmetricKey|\OpenSSLCertificate|string $private_key, string|int $algorithm = OPENSSL_ALGO_SHA1 ): bool {}