|
24 | 24 | final class DowngradeHashAlgorithmXxHashRector extends AbstractRector |
25 | 25 | { |
26 | 26 | /** |
27 | | - * @var array<string, int> |
| 27 | + * Constants are referenced by name, as the MHASH_* constants are deprecated since PHP 8.5 |
| 28 | + * |
| 29 | + * @var array<string, string> |
28 | 30 | */ |
29 | 31 | private const array HASH_ALGORITHMS_TO_DOWNGRADE = [ |
30 | | - 'xxh32' => MHASH_XXH32, |
31 | | - 'xxh64' => MHASH_XXH64, |
32 | | - 'xxh3' => MHASH_XXH3, |
33 | | - 'xxh128' => MHASH_XXH128, |
| 32 | + 'xxh32' => 'MHASH_XXH32', |
| 33 | + 'xxh64' => 'MHASH_XXH64', |
| 34 | + 'xxh3' => 'MHASH_XXH3', |
| 35 | + 'xxh128' => 'MHASH_XXH128', |
34 | 36 | ]; |
35 | 37 |
|
36 | 38 | private const string REPLACEMENT_ALGORITHM = 'md5'; |
@@ -167,7 +169,7 @@ private function getHashAlgorithm(array $args): ?string |
167 | 169 |
|
168 | 170 | private function mapConstantToString(string $constant): string |
169 | 171 | { |
170 | | - $mappedConstant = array_search(constant($constant), self::HASH_ALGORITHMS_TO_DOWNGRADE, true); |
| 172 | + $mappedConstant = array_search(ltrim($constant, '\\'), self::HASH_ALGORITHMS_TO_DOWNGRADE, true); |
171 | 173 |
|
172 | 174 | return $mappedConstant !== false ? $mappedConstant : $constant; |
173 | 175 | } |
|
0 commit comments