Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a590e90

Browse files
committed
minor #38567 [Cache] Make Redis initializers static (Nyholm)
This PR was merged into the 4.4 branch. Discussion ---------- [Cache] Make Redis initializers static | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes .. or maybe? | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | I am on very thin ice now. I saw a comment on similar code here: #38563 (comment) These anonymous functions in the cache component could also be made static to avoid being connected to the object using the Redis trait. Feel free to correct me if this does not make much sense. Commits ------- ad8de57 [Cache] Make Redis initializers static
2 parents 674382b + ad8de57 commit a590e90

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public static function createConnection($dsn, array $options = [])
174174
$connect = $params['persistent'] || $params['persistent_id'] ? 'pconnect' : 'connect';
175175
$redis = new $class();
176176

177-
$initializer = function ($redis) use ($connect, $params, $dsn, $auth, $hosts) {
177+
$initializer = static function ($redis) use ($connect, $params, $dsn, $auth, $hosts) {
178178
try {
179179
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
180180

@@ -226,7 +226,7 @@ public static function createConnection($dsn, array $options = [])
226226
$redis->setOption(\Redis::OPT_TCP_KEEPALIVE, $params['tcp_keepalive']);
227227
}
228228
} elseif (is_a($class, \RedisCluster::class, true)) {
229-
$initializer = function () use ($class, $params, $dsn, $hosts) {
229+
$initializer = static function () use ($class, $params, $dsn, $hosts) {
230230
foreach ($hosts as $i => $host) {
231231
$hosts[$i] = 'tcp' === $host['scheme'] ? $host['host'].':'.$host['port'] : $host['path'];
232232
}

0 commit comments

Comments
 (0)