|
2 | 2 |
|
3 | 3 | namespace PHPStan\Type\Php; |
4 | 4 |
|
5 | | -use PHPStan\Analyser\ResultCache\ResultCacheMetaExtension; |
| 5 | +use PHPStan\Analyser\DependencyTracker; |
| 6 | +use PHPStan\Analyser\ResultCache\ResultCacheValueExtension; |
6 | 7 | use PHPStan\DependencyInjection\AutowiredService; |
7 | 8 | use function array_filter; |
8 | 9 | use function array_map; |
9 | 10 | use function array_values; |
10 | 11 | use function function_exists; |
11 | | -use function hash; |
12 | | -use function implode; |
13 | 12 | use function in_array; |
14 | 13 | use function openssl_cipher_iv_length; |
15 | 14 | use function openssl_get_cipher_methods; |
16 | | -use function sort; |
17 | 15 | use function strtolower; |
18 | 16 |
|
| 17 | +/** |
| 18 | + * The supported ciphers are read out of the runtime, and the inferred types of |
| 19 | + * openssl_cipher_iv_length() and friends follow them. The set is a property of the PHP build rather |
| 20 | + * than of the PHP version: PHP 8.4.25 reports 212 methods on ubuntu-latest and 208 on macos-latest. |
| 21 | + * So whether a cipher is supported is tracked as a value, for the files asking about it. |
| 22 | + */ |
19 | 23 | #[AutowiredService] |
20 | | -final class OpenSslCipherMethodsProvider implements ResultCacheMetaExtension |
| 24 | +final class OpenSslCipherMethodsProvider implements ResultCacheValueExtension |
21 | 25 | { |
22 | 26 |
|
23 | 27 | /** |
@@ -61,28 +65,27 @@ private function getSupportedCipherMethods(): array |
61 | 65 | return $this->supportedCipherMethods; |
62 | 66 | } |
63 | 67 |
|
64 | | - public function isSupportedCipherMethod(string $method): bool |
| 68 | + public function isSupportedCipherMethod(string $method, DependencyTracker $dependencyTracker): bool |
65 | 69 | { |
66 | | - return in_array(strtolower($method), $this->getSupportedCipherMethods(), true); |
| 70 | + $method = strtolower($method); |
| 71 | + $dependencyTracker->trackValueDependency(self::class, $method); |
| 72 | + |
| 73 | + return in_array($method, $this->getSupportedCipherMethods(), true); |
67 | 74 | } |
68 | 75 |
|
69 | | - public function getKey(): string |
| 76 | + public function getValue(string $key): string |
70 | 77 | { |
71 | | - return 'openSslCipherMethods'; |
| 78 | + return in_array($key, $this->getSupportedCipherMethods(), true) ? 'supported' : 'unsupported'; |
72 | 79 | } |
73 | 80 |
|
74 | | - /** |
75 | | - * The supported ciphers are read out of the runtime, and the inferred type of |
76 | | - * openssl_cipher_iv_length() and friends follows them, so a host offering a different set has to |
77 | | - * invalidate the cache. The set is a property of the PHP build rather than of the PHP version: |
78 | | - * PHP 8.4.25 reports 212 methods on ubuntu-latest and 208 on macos-latest. |
79 | | - */ |
80 | | - public function getHash(): string |
| 81 | + public function keyToResultCache(string $key): string |
81 | 82 | { |
82 | | - $methods = $this->getSupportedCipherMethods(); |
83 | | - sort($methods); |
| 83 | + return $key; |
| 84 | + } |
84 | 85 |
|
85 | | - return hash('sha256', implode(',', $methods)); |
| 86 | + public function keyFromResultCache(string $storedKey): string |
| 87 | + { |
| 88 | + return $storedKey; |
86 | 89 | } |
87 | 90 |
|
88 | 91 | } |
0 commit comments