From 63d57bdbf86823dffa6ae4acb6b5cd5dbcc2a48a Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 30 Jul 2026 21:39:50 +0700 Subject: [PATCH 1/2] [DowngradePhp81] Reference MHASH_* constants by name in DowngradeHashAlgorithmXxHashRector to fix PHP 8.5 deprecation --- .../DowngradeHashAlgorithmXxHashRector.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rules/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHashRector.php b/rules/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHashRector.php index 435a9553..5a2304e8 100644 --- a/rules/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHashRector.php +++ b/rules/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHashRector.php @@ -24,13 +24,15 @@ final class DowngradeHashAlgorithmXxHashRector extends AbstractRector { /** - * @var array + * Constants are referenced by name, as the MHASH_* constants are deprecated since PHP 8.5 + * + * @var array */ private const array HASH_ALGORITHMS_TO_DOWNGRADE = [ - 'xxh32' => MHASH_XXH32, - 'xxh64' => MHASH_XXH64, - 'xxh3' => MHASH_XXH3, - 'xxh128' => MHASH_XXH128, + 'xxh32' => 'MHASH_XXH32', + 'xxh64' => 'MHASH_XXH64', + 'xxh3' => 'MHASH_XXH3', + 'xxh128' => 'MHASH_XXH128', ]; private const string REPLACEMENT_ALGORITHM = 'md5'; @@ -167,7 +169,7 @@ private function getHashAlgorithm(array $args): ?string private function mapConstantToString(string $constant): string { - $mappedConstant = array_search(constant($constant), self::HASH_ALGORITHMS_TO_DOWNGRADE, true); + $mappedConstant = array_search(ltrim($constant, '\\'), self::HASH_ALGORITHMS_TO_DOWNGRADE, true); return $mappedConstant !== false ? $mappedConstant : $constant; } From d7d1aff1e1c4a198b927a48bd96dd94ad66a2aa0 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 30 Jul 2026 21:39:56 +0700 Subject: [PATCH 2/2] fix --- .../fixture_fully_qualified_constant.php.inc | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_fully_qualified_constant.php.inc diff --git a/rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_fully_qualified_constant.php.inc b/rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_fully_qualified_constant.php.inc new file mode 100644 index 00000000..45542bc3 --- /dev/null +++ b/rules-tests/DowngradePhp81/Rector/FuncCall/DowngradeHashAlgorithmXxHash/Fixture/fixture_fully_qualified_constant.php.inc @@ -0,0 +1,27 @@ + +----- +