From 7fd23dbcb93b5d1c68e5796df58cca8874e0a070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20St=C3=A4gemann?= Date: Fri, 20 Feb 2026 10:05:12 +0100 Subject: [PATCH] Removed static from callables because it's deprecated since PHP 8.2 (#1642) --- CHANGELOG.md | 4 ++++ README.md | 2 +- examples/push_notifications.php | 2 +- examples/push_notifications_dispatcher.php | 2 +- src/Command/PrefixableCommand.php | 2 +- src/Command/Redis/XINFO.php | 4 ++-- tests/PHPUnit/PredisTestCase.php | 6 +++--- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 432c7264..baf70176 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ ### Added - Make HTTL and HPTTL commands Prefixable (#1639) +## v3.4.1 (2026-02-11) +### Fixed +- Removed static from callables because it is deprecated since PHP 8.2 + ## v3.4.0 (2026-02-11) ### Added - Added optional retry support (#1616) diff --git a/README.md b/README.md index 61743b19..a91a4ed6 100644 --- a/README.md +++ b/README.md @@ -664,7 +664,7 @@ $client = new Predis\Client(['read_write_timeout' => 0, 'protocol' => 3]); // Create push notifications consumer. // Provides callback where current consumer subscribes to few channels before // enter the loop. -$push = $client->push(static function (ClientInterface $client) { +$push = $client->push(function (ClientInterface $client) { $response = $client->subscribe('channel', 'control'); $status = ($response[2] === 1) ? 'OK' : 'FAILED'; echo "Channel subscription status: {$status}\n"; diff --git a/examples/push_notifications.php b/examples/push_notifications.php index b5c9a87c..ff5b5f54 100644 --- a/examples/push_notifications.php +++ b/examples/push_notifications.php @@ -19,7 +19,7 @@ require __DIR__ . '/shared.php'; $client = new Predis\Client($single_server + ['read_write_timeout' => 0, 'protocol' => 3]); // 2. Create push notifications consumer. Provides callback where current consumer subscribes to few channels before enter the loop. -$push = $client->push(static function (ClientInterface $client) { +$push = $client->push(function (ClientInterface $client) { $response = $client->subscribe('channel', 'control'); $status = ($response[2] === 1) ? 'OK' : 'FAILED'; echo "Channel subscription status: {$status}\n"; diff --git a/examples/push_notifications_dispatcher.php b/examples/push_notifications_dispatcher.php index 3cd4fce3..16f55d48 100644 --- a/examples/push_notifications_dispatcher.php +++ b/examples/push_notifications_dispatcher.php @@ -21,7 +21,7 @@ require __DIR__ . '/shared.php'; $client = new Predis\Client($single_server + ['read_write_timeout' => 0, 'protocol' => 3]); // 2. Create push notifications consumer. Provides callback where current consumer subscribes to few channels before enter the loop. -$push = $client->push(static function (ClientInterface $client) { +$push = $client->push(function (ClientInterface $client) { $response = $client->subscribe('channel', 'control'); $status = ($response[2] === 1) ? 'OK' : 'FAILED'; echo "Channel subscription status: {$status}\n"; diff --git a/src/Command/PrefixableCommand.php b/src/Command/PrefixableCommand.php index cf741513..ae2c66ec 100644 --- a/src/Command/PrefixableCommand.php +++ b/src/Command/PrefixableCommand.php @@ -33,7 +33,7 @@ abstract class PrefixableCommand extends Command implements PrefixableCommandInt public function applyPrefixForAllArguments(string $prefix): void { $this->setRawArguments( - array_map(static function ($key) use ($prefix) { + array_map(function ($key) use ($prefix) { return $prefix . $key; }, $this->getArguments()) ); diff --git a/src/Command/Redis/XINFO.php b/src/Command/Redis/XINFO.php index 4ce60714..a5cefd56 100644 --- a/src/Command/Redis/XINFO.php +++ b/src/Command/Redis/XINFO.php @@ -69,12 +69,12 @@ class XINFO extends RedisCommand } if (isset($result['groups']) && is_array($result['groups'])) { - $result['groups'] = array_map(static function ($group) { + $result['groups'] = array_map(function ($group) { if ($group === array_values($group)) { $group = CommandUtility::arrayToDictionary($group, null, false); } if (isset($group['consumers'])) { - $group['consumers'] = array_map(static function ($consumer) { + $group['consumers'] = array_map(function ($consumer) { if ($consumer === array_values($consumer)) { $consumer = CommandUtility::arrayToDictionary($consumer, null, false); } diff --git a/tests/PHPUnit/PredisTestCase.php b/tests/PHPUnit/PredisTestCase.php index f278dac7..c9883454 100644 --- a/tests/PHPUnit/PredisTestCase.php +++ b/tests/PHPUnit/PredisTestCase.php @@ -352,7 +352,7 @@ abstract class PredisTestCase extends PHPUnit\Framework\TestCase if ($isSSL && $isCluster) { // For cluster SSL tests, use non-SSL cluster endpoints $endpoints = explode(',', constant('REDIS_CLUSTER_ENDPOINTS')); - $parameters = array_map(static function (string $elem) { + $parameters = array_map(function (string $elem) { return 'tcp://' . $elem; }, $endpoints); } elseif ($isSSL) { @@ -792,7 +792,7 @@ abstract class PredisTestCase extends PHPUnit\Framework\TestCase ); $scheme = $this->isSSLTest() ? 'tls' : 'tcp'; - return array_map(static function (string $elem) use ($scheme) { + return array_map(function (string $elem) use ($scheme) { return "{$scheme}://" . $elem; }, $endpoints); } @@ -806,7 +806,7 @@ abstract class PredisTestCase extends PHPUnit\Framework\TestCase { $endpoints = explode(',', constant('REDIS_SENTINEL_ENDPOINTS')); - return array_map(static function (string $elem) { + return array_map(function (string $elem) { return "tcp://{$elem}"; }, $endpoints); }