Test Failed
Branch develop (a8dd82)
by Andreas
09:23
created
phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Rediscluster/Config.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -23,164 +23,164 @@
 block discarded – undo
23 23
 
24 24
 class Config extends ConfigurationOption
25 25
 {
26
-    /**
27
-     * @var array<string>
28
-     */
29
-    protected array $clusters = [];
30
-    protected string $password = '';
31
-    protected int $timeout = 5;
32
-    protected int $readTimeout = 5;
33
-    protected ?RedisClusterClient $redisClusterClient = null;
34
-    protected string $optPrefix = '';
35
-    protected ?int $slaveFailover = null;
36
-
37
-    /**
38
-     * @return array<string>
39
-     */
40
-    public function getClusters(): array
41
-    {
42
-        return $this->clusters;
43
-    }
44
-
45
-    /**
46
-     * @param string $cluster
47
-     * @return Config
48
-     */
49
-    public function addCluster(string $cluster): static
50
-    {
51
-        $this->enforceLockedProperty(__FUNCTION__);
52
-        $this->clusters[] = $cluster;
53
-        return $this;
54
-    }
55
-
56
-    /**
57
-     * @param string $clusters
58
-     * @return Config
59
-     */
60
-    public function setClusters(...$clusters): static
61
-    {
62
-        return $this->setProperty('clusters', $clusters);
63
-    }
64
-
65
-    /**
66
-     * @return string
67
-     */
68
-    public function getPassword(): string
69
-    {
70
-        return $this->password;
71
-    }
72
-
73
-    /**
74
-     * @param string $password
75
-     *
76
-     * @return static
77
-     * @throws PhpfastcacheLogicException
78
-     */
79
-    public function setPassword(string $password): static
80
-    {
81
-        return $this->setProperty('password', $password);
82
-    }
83
-
84
-    /**
85
-     * @return int
86
-     */
87
-    public function getTimeout(): int
88
-    {
89
-        return $this->timeout;
90
-    }
91
-
92
-    /**
93
-     * @param int $timeout
94
-     * @return static
95
-     * @throws PhpfastcacheLogicException
96
-     */
97
-    public function setTimeout(int $timeout): static
98
-    {
99
-        return $this->setProperty('timeout', $timeout);
100
-    }
101
-
102
-    /**
103
-     * @return int
104
-     */
105
-    public function getReadTimeout(): int
106
-    {
107
-        return $this->readTimeout;
108
-    }
109
-
110
-    /**
111
-     * @param int $readTimeout
112
-     * @return static
113
-     * @throws PhpfastcacheLogicException
114
-     */
115
-    public function setReadTimeout(int $readTimeout): static
116
-    {
117
-        return $this->setProperty('readTimeout', $readTimeout);
118
-    }
119
-
120
-
121
-    /**
122
-     * @return RedisClusterClient|null
123
-     */
124
-    public function getRedisClusterClient(): ?RedisClusterClient
125
-    {
126
-        return $this->redisClusterClient;
127
-    }
128
-
129
-    /**
130
-     * @param RedisClusterClient|null $redisClusterClient
131
-     * @return Config
132
-     * @throws PhpfastcacheLogicException
133
-     */
134
-    public function setRedisClusterClient(?RedisClusterClient $redisClusterClient): static
135
-    {
136
-        return $this->setProperty('redisClusterClient', $redisClusterClient);
137
-    }
138
-
139
-    /**
140
-     * @return string
141
-     * @since 7.0.2
142
-     */
143
-    public function getOptPrefix(): string
144
-    {
145
-        return $this->optPrefix;
146
-    }
147
-
148
-    /**
149
-     * @param string $optPrefix
150
-     * @return Config
151
-     * @throws PhpfastcacheLogicException
152
-     * @since 7.0.2
153
-     */
154
-    public function setOptPrefix(string $optPrefix): static
155
-    {
156
-        return $this->setProperty('optPrefix', trim($optPrefix));
157
-    }
158
-
159
-    /**
160
-     * @return int|null
161
-     */
162
-    public function getSlaveFailover(): ?int
163
-    {
164
-        return $this->slaveFailover;
165
-    }
166
-
167
-    /**
168
-     * @param int|null $slaveFailover
169
-     * @return Config
170
-     * @throws PhpfastcacheInvalidArgumentException
171
-     */
172
-    public function setSlaveFailover(?int $slaveFailover): static
173
-    {
174
-        if (
175
-            $slaveFailover !== null && !in_array($slaveFailover, [
176
-            RedisClusterClient::FAILOVER_NONE,
177
-            RedisClusterClient::FAILOVER_ERROR,
178
-            RedisClusterClient::FAILOVER_DISTRIBUTE,
179
-            RedisClusterClient::FAILOVER_DISTRIBUTE_SLAVES,
180
-            ])
181
-        ) {
182
-            throw new PhpfastcacheInvalidArgumentException('Invalid Slave Failover option: ' . $slaveFailover);
183
-        }
184
-        return $this->setProperty('slaveFailover', $slaveFailover);
185
-    }
26
+	/**
27
+	 * @var array<string>
28
+	 */
29
+	protected array $clusters = [];
30
+	protected string $password = '';
31
+	protected int $timeout = 5;
32
+	protected int $readTimeout = 5;
33
+	protected ?RedisClusterClient $redisClusterClient = null;
34
+	protected string $optPrefix = '';
35
+	protected ?int $slaveFailover = null;
36
+
37
+	/**
38
+	 * @return array<string>
39
+	 */
40
+	public function getClusters(): array
41
+	{
42
+		return $this->clusters;
43
+	}
44
+
45
+	/**
46
+	 * @param string $cluster
47
+	 * @return Config
48
+	 */
49
+	public function addCluster(string $cluster): static
50
+	{
51
+		$this->enforceLockedProperty(__FUNCTION__);
52
+		$this->clusters[] = $cluster;
53
+		return $this;
54
+	}
55
+
56
+	/**
57
+	 * @param string $clusters
58
+	 * @return Config
59
+	 */
60
+	public function setClusters(...$clusters): static
61
+	{
62
+		return $this->setProperty('clusters', $clusters);
63
+	}
64
+
65
+	/**
66
+	 * @return string
67
+	 */
68
+	public function getPassword(): string
69
+	{
70
+		return $this->password;
71
+	}
72
+
73
+	/**
74
+	 * @param string $password
75
+	 *
76
+	 * @return static
77
+	 * @throws PhpfastcacheLogicException
78
+	 */
79
+	public function setPassword(string $password): static
80
+	{
81
+		return $this->setProperty('password', $password);
82
+	}
83
+
84
+	/**
85
+	 * @return int
86
+	 */
87
+	public function getTimeout(): int
88
+	{
89
+		return $this->timeout;
90
+	}
91
+
92
+	/**
93
+	 * @param int $timeout
94
+	 * @return static
95
+	 * @throws PhpfastcacheLogicException
96
+	 */
97
+	public function setTimeout(int $timeout): static
98
+	{
99
+		return $this->setProperty('timeout', $timeout);
100
+	}
101
+
102
+	/**
103
+	 * @return int
104
+	 */
105
+	public function getReadTimeout(): int
106
+	{
107
+		return $this->readTimeout;
108
+	}
109
+
110
+	/**
111
+	 * @param int $readTimeout
112
+	 * @return static
113
+	 * @throws PhpfastcacheLogicException
114
+	 */
115
+	public function setReadTimeout(int $readTimeout): static
116
+	{
117
+		return $this->setProperty('readTimeout', $readTimeout);
118
+	}
119
+
120
+
121
+	/**
122
+	 * @return RedisClusterClient|null
123
+	 */
124
+	public function getRedisClusterClient(): ?RedisClusterClient
125
+	{
126
+		return $this->redisClusterClient;
127
+	}
128
+
129
+	/**
130
+	 * @param RedisClusterClient|null $redisClusterClient
131
+	 * @return Config
132
+	 * @throws PhpfastcacheLogicException
133
+	 */
134
+	public function setRedisClusterClient(?RedisClusterClient $redisClusterClient): static
135
+	{
136
+		return $this->setProperty('redisClusterClient', $redisClusterClient);
137
+	}
138
+
139
+	/**
140
+	 * @return string
141
+	 * @since 7.0.2
142
+	 */
143
+	public function getOptPrefix(): string
144
+	{
145
+		return $this->optPrefix;
146
+	}
147
+
148
+	/**
149
+	 * @param string $optPrefix
150
+	 * @return Config
151
+	 * @throws PhpfastcacheLogicException
152
+	 * @since 7.0.2
153
+	 */
154
+	public function setOptPrefix(string $optPrefix): static
155
+	{
156
+		return $this->setProperty('optPrefix', trim($optPrefix));
157
+	}
158
+
159
+	/**
160
+	 * @return int|null
161
+	 */
162
+	public function getSlaveFailover(): ?int
163
+	{
164
+		return $this->slaveFailover;
165
+	}
166
+
167
+	/**
168
+	 * @param int|null $slaveFailover
169
+	 * @return Config
170
+	 * @throws PhpfastcacheInvalidArgumentException
171
+	 */
172
+	public function setSlaveFailover(?int $slaveFailover): static
173
+	{
174
+		if (
175
+			$slaveFailover !== null && !in_array($slaveFailover, [
176
+			RedisClusterClient::FAILOVER_NONE,
177
+			RedisClusterClient::FAILOVER_ERROR,
178
+			RedisClusterClient::FAILOVER_DISTRIBUTE,
179
+			RedisClusterClient::FAILOVER_DISTRIBUTE_SLAVES,
180
+			])
181
+		) {
182
+			throw new PhpfastcacheInvalidArgumentException('Invalid Slave Failover option: ' . $slaveFailover);
183
+		}
184
+		return $this->setProperty('slaveFailover', $slaveFailover);
185
+	}
186 186
 }
Please login to merge, or discard this patch.
vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Wincache/Item.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@
 block discarded – undo
24 24
  */
25 25
 class Item implements ExtendedCacheItemInterface
26 26
 {
27
-    use TaggableCacheItemTrait;
27
+	use TaggableCacheItemTrait;
28 28
 
29
-    protected function getDriverClass(): string
30
-    {
31
-        return Driver::class;
32
-    }
29
+	protected function getDriverClass(): string
30
+	{
31
+		return Driver::class;
32
+	}
33 33
 }
Please login to merge, or discard this patch.
phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Wincache/Driver.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -31,89 +31,89 @@
 block discarded – undo
31 31
  */
32 32
 class Driver implements AggregatablePoolInterface
33 33
 {
34
-    use TaggableCacheItemPoolTrait;
35
-
36
-    /**
37
-     * @return bool
38
-     */
39
-    public function driverCheck(): bool
40
-    {
41
-        return extension_loaded('wincache') && function_exists('wincache_ucache_set');
42
-    }
43
-
44
-    public function getHelp(): string
45
-    {
46
-        return <<<HELP
34
+	use TaggableCacheItemPoolTrait;
35
+
36
+	/**
37
+	 * @return bool
38
+	 */
39
+	public function driverCheck(): bool
40
+	{
41
+		return extension_loaded('wincache') && function_exists('wincache_ucache_set');
42
+	}
43
+
44
+	public function getHelp(): string
45
+	{
46
+		return <<<HELP
47 47
 Wincache PECL extension is not maintained anymore and has been superseded. Check sourceforge for more informations: https://sourceforge.net/projects/wincache/'
48 48
 HELP;
49
-    }
50
-
51
-    /**
52
-     * @return DriverStatistic
53
-     */
54
-    public function getStats(): DriverStatistic
55
-    {
56
-        $memInfo = wincache_ucache_meminfo();
57
-        $info = wincache_ucache_info();
58
-        $date = (new DateTime())->setTimestamp(time() - $info['total_cache_uptime']);
59
-
60
-        return (new DriverStatistic())
61
-            ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
62
-            ->setSize($memInfo['memory_free'] - $memInfo['memory_total'])
63
-            ->setData(implode(', ', array_keys($this->itemInstances)))
64
-            ->setRawData($memInfo);
65
-    }
66
-
67
-    /**
68
-     * @return bool
69
-     */
70
-    protected function driverConnect(): bool
71
-    {
72
-        return true;
73
-    }
74
-
75
-    /**
76
-     * @param ExtendedCacheItemInterface $item
77
-     * @return ?array<string, mixed>
78
-     */
79
-    protected function driverRead(ExtendedCacheItemInterface $item): ?array
80
-    {
81
-        $val = wincache_ucache_get($item->getKey(), $suc);
82
-
83
-        if ($suc === false || empty($val)) {
84
-            return null;
85
-        }
86
-
87
-        return $val;
88
-    }
89
-
90
-    /**
91
-     * @param ExtendedCacheItemInterface $item
92
-     * @return mixed
93
-     * @throws PhpfastcacheInvalidArgumentException
94
-     * @throws PhpfastcacheLogicException
95
-     */
96
-    protected function driverWrite(ExtendedCacheItemInterface $item): bool
97
-    {
98
-
99
-        return wincache_ucache_set($item->getKey(), $this->driverPreWrap($item), $item->getTtl());
100
-    }
101
-
102
-    /**
103
-     * @param string $key
104
-     * @param string $encodedKey
105
-     * @return bool
106
-     */
107
-    protected function driverDelete(string $key, string $encodedKey): bool
108
-    {
109
-        return wincache_ucache_delete($key);
110
-    }
111
-
112
-    /**
113
-     * @return bool
114
-     */
115
-    protected function driverClear(): bool
116
-    {
117
-        return wincache_ucache_clear();
118
-    }
49
+	}
50
+
51
+	/**
52
+	 * @return DriverStatistic
53
+	 */
54
+	public function getStats(): DriverStatistic
55
+	{
56
+		$memInfo = wincache_ucache_meminfo();
57
+		$info = wincache_ucache_info();
58
+		$date = (new DateTime())->setTimestamp(time() - $info['total_cache_uptime']);
59
+
60
+		return (new DriverStatistic())
61
+			->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822)))
62
+			->setSize($memInfo['memory_free'] - $memInfo['memory_total'])
63
+			->setData(implode(', ', array_keys($this->itemInstances)))
64
+			->setRawData($memInfo);
65
+	}
66
+
67
+	/**
68
+	 * @return bool
69
+	 */
70
+	protected function driverConnect(): bool
71
+	{
72
+		return true;
73
+	}
74
+
75
+	/**
76
+	 * @param ExtendedCacheItemInterface $item
77
+	 * @return ?array<string, mixed>
78
+	 */
79
+	protected function driverRead(ExtendedCacheItemInterface $item): ?array
80
+	{
81
+		$val = wincache_ucache_get($item->getKey(), $suc);
82
+
83
+		if ($suc === false || empty($val)) {
84
+			return null;
85
+		}
86
+
87
+		return $val;
88
+	}
89
+
90
+	/**
91
+	 * @param ExtendedCacheItemInterface $item
92
+	 * @return mixed
93
+	 * @throws PhpfastcacheInvalidArgumentException
94
+	 * @throws PhpfastcacheLogicException
95
+	 */
96
+	protected function driverWrite(ExtendedCacheItemInterface $item): bool
97
+	{
98
+
99
+		return wincache_ucache_set($item->getKey(), $this->driverPreWrap($item), $item->getTtl());
100
+	}
101
+
102
+	/**
103
+	 * @param string $key
104
+	 * @param string $encodedKey
105
+	 * @return bool
106
+	 */
107
+	protected function driverDelete(string $key, string $encodedKey): bool
108
+	{
109
+		return wincache_ucache_delete($key);
110
+	}
111
+
112
+	/**
113
+	 * @return bool
114
+	 */
115
+	protected function driverClear(): bool
116
+	{
117
+		return wincache_ucache_clear();
118
+	}
119 119
 }
Please login to merge, or discard this patch.
phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Wincache/Config.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@
 block discarded – undo
23 23
  */
24 24
 class Config extends ConfigurationOption
25 25
 {
26
-    public function __construct(array $parameters = [])
27
-    {
28
-        trigger_error(
29
-            'Wincache is now deprecated and will be removed as of v10 due to the lack of updates to PHP8 as officially stated by PHP:
26
+	public function __construct(array $parameters = [])
27
+	{
28
+		trigger_error(
29
+			'Wincache is now deprecated and will be removed as of v10 due to the lack of updates to PHP8 as officially stated by PHP:
30 30
             https://www.php.net/manual/en/install.windows.recommended.php',
31
-            E_USER_DEPRECATED
32
-        );
33
-        parent::__construct($parameters);
34
-    }
31
+			E_USER_DEPRECATED
32
+		);
33
+		parent::__construct($parameters);
34
+	}
35 35
 }
Please login to merge, or discard this patch.
phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Devnull/Driver.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -29,73 +29,73 @@
 block discarded – undo
29 29
  */
30 30
 class Driver implements ExtendedCacheItemPoolInterface
31 31
 {
32
-    use TaggableCacheItemPoolTrait;
32
+	use TaggableCacheItemPoolTrait;
33 33
 
34
-    /**
35
-     * @return bool
36
-     */
37
-    public function driverCheck(): bool
38
-    {
39
-        return true;
40
-    }
34
+	/**
35
+	 * @return bool
36
+	 */
37
+	public function driverCheck(): bool
38
+	{
39
+		return true;
40
+	}
41 41
 
42
-    /**
43
-     * @return DriverStatistic
44
-     */
45
-    public function getStats(): DriverStatistic
46
-    {
47
-        $stat = new DriverStatistic();
48
-        $stat->setInfo('[Devnull] A void info string')
49
-            ->setSize(0)
50
-            ->setData(implode(', ', array_keys($this->itemInstances)))
51
-            ->setRawData(null);
42
+	/**
43
+	 * @return DriverStatistic
44
+	 */
45
+	public function getStats(): DriverStatistic
46
+	{
47
+		$stat = new DriverStatistic();
48
+		$stat->setInfo('[Devnull] A void info string')
49
+			->setSize(0)
50
+			->setData(implode(', ', array_keys($this->itemInstances)))
51
+			->setRawData(null);
52 52
 
53
-        return $stat;
54
-    }
53
+		return $stat;
54
+	}
55 55
 
56
-    /**
57
-     * @param ExtendedCacheItemInterface $item
58
-     * @return mixed
59
-     * @throws PhpfastcacheInvalidArgumentException
60
-     */
61
-    protected function driverWrite(ExtendedCacheItemInterface $item): bool
62
-    {
56
+	/**
57
+	 * @param ExtendedCacheItemInterface $item
58
+	 * @return mixed
59
+	 * @throws PhpfastcacheInvalidArgumentException
60
+	 */
61
+	protected function driverWrite(ExtendedCacheItemInterface $item): bool
62
+	{
63 63
 
64
-        return true;
65
-    }
64
+		return true;
65
+	}
66 66
 
67
-    /**
68
-     * @param ExtendedCacheItemInterface $item
69
-     * @return ?array<string, mixed>
70
-     */
71
-    protected function driverRead(CacheItemInterface $item): ?array
72
-    {
73
-        return null;
74
-    }
67
+	/**
68
+	 * @param ExtendedCacheItemInterface $item
69
+	 * @return ?array<string, mixed>
70
+	 */
71
+	protected function driverRead(CacheItemInterface $item): ?array
72
+	{
73
+		return null;
74
+	}
75 75
 
76
-    /**
77
-     * @param string $key
78
-     * @param string $encodedKey
79
-     * @return bool
80
-     */
81
-    protected function driverDelete(string $key, string $encodedKey): bool
82
-    {
83
-        return true;
84
-    }
76
+	/**
77
+	 * @param string $key
78
+	 * @param string $encodedKey
79
+	 * @return bool
80
+	 */
81
+	protected function driverDelete(string $key, string $encodedKey): bool
82
+	{
83
+		return true;
84
+	}
85 85
 
86
-    /**
87
-     * @return bool
88
-     */
89
-    protected function driverClear(): bool
90
-    {
91
-        return true;
92
-    }
86
+	/**
87
+	 * @return bool
88
+	 */
89
+	protected function driverClear(): bool
90
+	{
91
+		return true;
92
+	}
93 93
 
94
-    /**
95
-     * @return bool
96
-     */
97
-    protected function driverConnect(): bool
98
-    {
99
-        return true;
100
-    }
94
+	/**
95
+	 * @return bool
96
+	 */
97
+	protected function driverConnect(): bool
98
+	{
99
+		return true;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Memory/Driver.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -31,98 +31,98 @@
 block discarded – undo
31 31
  */
32 32
 class Driver implements ExtendedCacheItemPoolInterface
33 33
 {
34
-    use TaggableCacheItemPoolTrait;
35
-
36
-    /**
37
-     * @var array<string, array<string, mixed>>
38
-     */
39
-    protected array $staticStack = [];
40
-
41
-    /**
42
-     * @return bool
43
-     */
44
-    public function driverCheck(): bool
45
-    {
46
-        return true;
47
-    }
48
-
49
-    /**
50
-     * @return bool
51
-     */
52
-    protected function driverConnect(): bool
53
-    {
54
-        return true;
55
-    }
56
-
57
-    /**
58
-     * @param ExtendedCacheItemInterface $item
59
-     * @return ?array<string, mixed>
60
-     */
61
-    protected function driverRead(ExtendedCacheItemInterface $item): ?array
62
-    {
63
-        return $this->staticStack[$item->getKey()] ?? null;
64
-    }
65
-
66
-    /**
67
-     * @return array<int, string>
68
-     */
69
-    protected function driverReadAllKeys(string $pattern = ''): iterable
70
-    {
71
-        return array_filter(array_keys($this->staticStack), function (string $key) use ($pattern) {
72
-            return $pattern
73
-                ? preg_match('/' . str_replace('*', '(.*)', $pattern) . '/', $key)
74
-                : true;
75
-        });
76
-    }
77
-
78
-    /**
79
-     * @param ExtendedCacheItemInterface $item
80
-     * @return bool
81
-     * @throws PhpfastcacheInvalidArgumentException
82
-     * @throws PhpfastcacheLogicException
83
-     */
84
-    protected function driverWrite(ExtendedCacheItemInterface $item): bool
85
-    {
86
-
87
-        $this->staticStack[$item->getKey()] = $this->driverPreWrap($item);
88
-        return true;
89
-    }
90
-
91
-    /**
92
-     * @param string $key
93
-     * @param string $encodedKey
94
-     * @return bool
95
-     */
96
-    protected function driverDelete(string $key, string $encodedKey): bool
97
-    {
98
-        if (isset($this->staticStack[$key])) {
99
-            unset($this->staticStack[$key]);
100
-            return true;
101
-        }
102
-        return false;
103
-    }
104
-
105
-    /**
106
-     * @return bool
107
-     */
108
-    protected function driverClear(): bool
109
-    {
110
-        unset($this->staticStack);
111
-        $this->staticStack = [];
112
-        return true;
113
-    }
114
-
115
-    /**
116
-     * @return DriverStatistic
117
-     */
118
-    public function getStats(): DriverStatistic
119
-    {
120
-        $stat = new DriverStatistic();
121
-        $stat->setInfo('[Memstatic] A memory static driver')
122
-            ->setSize(mb_strlen(serialize($this->staticStack)))
123
-            ->setData(implode(', ', array_keys($this->itemInstances)))
124
-            ->setRawData($this->staticStack);
125
-
126
-        return $stat;
127
-    }
34
+	use TaggableCacheItemPoolTrait;
35
+
36
+	/**
37
+	 * @var array<string, array<string, mixed>>
38
+	 */
39
+	protected array $staticStack = [];
40
+
41
+	/**
42
+	 * @return bool
43
+	 */
44
+	public function driverCheck(): bool
45
+	{
46
+		return true;
47
+	}
48
+
49
+	/**
50
+	 * @return bool
51
+	 */
52
+	protected function driverConnect(): bool
53
+	{
54
+		return true;
55
+	}
56
+
57
+	/**
58
+	 * @param ExtendedCacheItemInterface $item
59
+	 * @return ?array<string, mixed>
60
+	 */
61
+	protected function driverRead(ExtendedCacheItemInterface $item): ?array
62
+	{
63
+		return $this->staticStack[$item->getKey()] ?? null;
64
+	}
65
+
66
+	/**
67
+	 * @return array<int, string>
68
+	 */
69
+	protected function driverReadAllKeys(string $pattern = ''): iterable
70
+	{
71
+		return array_filter(array_keys($this->staticStack), function (string $key) use ($pattern) {
72
+			return $pattern
73
+				? preg_match('/' . str_replace('*', '(.*)', $pattern) . '/', $key)
74
+				: true;
75
+		});
76
+	}
77
+
78
+	/**
79
+	 * @param ExtendedCacheItemInterface $item
80
+	 * @return bool
81
+	 * @throws PhpfastcacheInvalidArgumentException
82
+	 * @throws PhpfastcacheLogicException
83
+	 */
84
+	protected function driverWrite(ExtendedCacheItemInterface $item): bool
85
+	{
86
+
87
+		$this->staticStack[$item->getKey()] = $this->driverPreWrap($item);
88
+		return true;
89
+	}
90
+
91
+	/**
92
+	 * @param string $key
93
+	 * @param string $encodedKey
94
+	 * @return bool
95
+	 */
96
+	protected function driverDelete(string $key, string $encodedKey): bool
97
+	{
98
+		if (isset($this->staticStack[$key])) {
99
+			unset($this->staticStack[$key]);
100
+			return true;
101
+		}
102
+		return false;
103
+	}
104
+
105
+	/**
106
+	 * @return bool
107
+	 */
108
+	protected function driverClear(): bool
109
+	{
110
+		unset($this->staticStack);
111
+		$this->staticStack = [];
112
+		return true;
113
+	}
114
+
115
+	/**
116
+	 * @return DriverStatistic
117
+	 */
118
+	public function getStats(): DriverStatistic
119
+	{
120
+		$stat = new DriverStatistic();
121
+		$stat->setInfo('[Memstatic] A memory static driver')
122
+			->setSize(mb_strlen(serialize($this->staticStack)))
123
+			->setData(implode(', ', array_keys($this->itemInstances)))
124
+			->setRawData($this->staticStack);
125
+
126
+		return $stat;
127
+	}
128 128
 }
Please login to merge, or discard this patch.
vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Redis/Driver.php 1 patch
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -30,115 +30,115 @@
 block discarded – undo
30 30
  */
31 31
 class Driver implements AggregatablePoolInterface
32 32
 {
33
-    use RedisDriverTrait, TaggableCacheItemPoolTrait {
34
-        RedisDriverTrait::driverReadMultiple insteadof TaggableCacheItemPoolTrait;
35
-        RedisDriverTrait::driverDeleteMultiple insteadof TaggableCacheItemPoolTrait;
36
-    }
37
-
38
-
39
-    /**
40
-     * @return bool
41
-     */
42
-    public function driverCheck(): bool
43
-    {
44
-        return extension_loaded('Redis') && class_exists(RedisClient::class);
45
-    }
46
-
47
-    /**
48
-     * @return DriverStatistic
49
-     */
50
-    public function getStats(): DriverStatistic
51
-    {
52
-        // used_memory
53
-        $info = $this->instance->info();
54
-        $date = (new DateTime())->setTimestamp(time() - $info['uptime_in_seconds']);
55
-
56
-        return (new DriverStatistic())
57
-            ->setData(implode(', ', array_keys($this->itemInstances)))
58
-            ->setRawData($info)
59
-            ->setSize((int)$info['used_memory_dataset'])
60
-            ->setInfo(
61
-                sprintf(
62
-                    "The Redis daemon v%s, php-ext v%s, is up since %s.\n For more information see RawData.",
63
-                    $info['redis_version'],
64
-                    \phpversion("redis"),
65
-                    $date->format(DATE_RFC2822)
66
-                )
67
-            );
68
-    }
69
-
70
-    /**
71
-     * @return bool
72
-     * @throws PhpfastcacheLogicException
73
-     */
74
-    protected function driverConnect(): bool
75
-    {
76
-        if (isset($this->instance) && $this->instance instanceof RedisClient) {
77
-            throw new PhpfastcacheLogicException('Already connected to Redis server');
78
-        }
79
-
80
-        /**
81
-         * In case of an user-provided
82
-         * Redis client just return here
83
-         */
84
-        if ($this->getConfig()->getRedisClient() instanceof RedisClient) {
85
-            /**
86
-             * Unlike Predis, we can't test if we're connected
87
-             * or not, so let's just assume that we are
88
-             */
89
-            $this->instance = $this->getConfig()->getRedisClient();
90
-            return true;
91
-        }
92
-
93
-        $this->instance = $this->instance ?? new RedisClient();
94
-
95
-        /**
96
-         * If path is provided we consider it as a UNIX Socket
97
-         */
98
-        if ($this->getConfig()->getPath()) {
99
-            $isConnected = $this->instance->connect($this->getConfig()->getPath());
100
-        } else {
101
-            $isConnected = $this->instance->connect($this->getConfig()->getHost(), $this->getConfig()->getPort(), $this->getConfig()->getTimeout());
102
-        }
103
-
104
-        if (!$isConnected && $this->getConfig()->getPath()) {
105
-            return false;
106
-        }
107
-
108
-        if ($this->getConfig()->getOptPrefix()) {
109
-            $this->instance->setOption(RedisClient::OPT_PREFIX, $this->getConfig()->getOptPrefix());
110
-        }
111
-
112
-        if ($this->getConfig()->getPassword() && !$this->instance->auth($this->getConfig()->getPassword())) {
113
-            return false;
114
-        }
115
-
116
-        if ($this->getConfig()->getDatabase() !== null) {
117
-            $this->instance->select($this->getConfig()->getDatabase());
118
-        }
119
-        return true;
120
-    }
121
-
122
-    /**
123
-     * @return array<int, string>
124
-     * @throws \RedisException
125
-     */
126
-    protected function driverReadAllKeys(string $pattern = '*'): iterable
127
-    {
128
-        $i = -1;
129
-        $keys = $this->instance->scan($i, $pattern === '' ? '*' : $pattern, ExtendedCacheItemPoolInterface::MAX_ALL_KEYS_COUNT);
130
-        if (is_iterable($keys)) {
131
-            return $keys;
132
-        } else {
133
-            return [];
134
-        }
135
-    }
136
-
137
-    /**
138
-     * @return bool
139
-     */
140
-    protected function driverClear(): bool
141
-    {
142
-        return $this->instance->flushDB();
143
-    }
33
+	use RedisDriverTrait, TaggableCacheItemPoolTrait {
34
+		RedisDriverTrait::driverReadMultiple insteadof TaggableCacheItemPoolTrait;
35
+		RedisDriverTrait::driverDeleteMultiple insteadof TaggableCacheItemPoolTrait;
36
+	}
37
+
38
+
39
+	/**
40
+	 * @return bool
41
+	 */
42
+	public function driverCheck(): bool
43
+	{
44
+		return extension_loaded('Redis') && class_exists(RedisClient::class);
45
+	}
46
+
47
+	/**
48
+	 * @return DriverStatistic
49
+	 */
50
+	public function getStats(): DriverStatistic
51
+	{
52
+		// used_memory
53
+		$info = $this->instance->info();
54
+		$date = (new DateTime())->setTimestamp(time() - $info['uptime_in_seconds']);
55
+
56
+		return (new DriverStatistic())
57
+			->setData(implode(', ', array_keys($this->itemInstances)))
58
+			->setRawData($info)
59
+			->setSize((int)$info['used_memory_dataset'])
60
+			->setInfo(
61
+				sprintf(
62
+					"The Redis daemon v%s, php-ext v%s, is up since %s.\n For more information see RawData.",
63
+					$info['redis_version'],
64
+					\phpversion("redis"),
65
+					$date->format(DATE_RFC2822)
66
+				)
67
+			);
68
+	}
69
+
70
+	/**
71
+	 * @return bool
72
+	 * @throws PhpfastcacheLogicException
73
+	 */
74
+	protected function driverConnect(): bool
75
+	{
76
+		if (isset($this->instance) && $this->instance instanceof RedisClient) {
77
+			throw new PhpfastcacheLogicException('Already connected to Redis server');
78
+		}
79
+
80
+		/**
81
+		 * In case of an user-provided
82
+		 * Redis client just return here
83
+		 */
84
+		if ($this->getConfig()->getRedisClient() instanceof RedisClient) {
85
+			/**
86
+			 * Unlike Predis, we can't test if we're connected
87
+			 * or not, so let's just assume that we are
88
+			 */
89
+			$this->instance = $this->getConfig()->getRedisClient();
90
+			return true;
91
+		}
92
+
93
+		$this->instance = $this->instance ?? new RedisClient();
94
+
95
+		/**
96
+		 * If path is provided we consider it as a UNIX Socket
97
+		 */
98
+		if ($this->getConfig()->getPath()) {
99
+			$isConnected = $this->instance->connect($this->getConfig()->getPath());
100
+		} else {
101
+			$isConnected = $this->instance->connect($this->getConfig()->getHost(), $this->getConfig()->getPort(), $this->getConfig()->getTimeout());
102
+		}
103
+
104
+		if (!$isConnected && $this->getConfig()->getPath()) {
105
+			return false;
106
+		}
107
+
108
+		if ($this->getConfig()->getOptPrefix()) {
109
+			$this->instance->setOption(RedisClient::OPT_PREFIX, $this->getConfig()->getOptPrefix());
110
+		}
111
+
112
+		if ($this->getConfig()->getPassword() && !$this->instance->auth($this->getConfig()->getPassword())) {
113
+			return false;
114
+		}
115
+
116
+		if ($this->getConfig()->getDatabase() !== null) {
117
+			$this->instance->select($this->getConfig()->getDatabase());
118
+		}
119
+		return true;
120
+	}
121
+
122
+	/**
123
+	 * @return array<int, string>
124
+	 * @throws \RedisException
125
+	 */
126
+	protected function driverReadAllKeys(string $pattern = '*'): iterable
127
+	{
128
+		$i = -1;
129
+		$keys = $this->instance->scan($i, $pattern === '' ? '*' : $pattern, ExtendedCacheItemPoolInterface::MAX_ALL_KEYS_COUNT);
130
+		if (is_iterable($keys)) {
131
+			return $keys;
132
+		} else {
133
+			return [];
134
+		}
135
+	}
136
+
137
+	/**
138
+	 * @return bool
139
+	 */
140
+	protected function driverClear(): bool
141
+	{
142
+		return $this->instance->flushDB();
143
+	}
144 144
 }
Please login to merge, or discard this patch.
phpfastcache/lib/Phpfastcache/Drivers/Redis/RedisDriverTrait.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -28,76 +28,76 @@
 block discarded – undo
28 28
  */
29 29
 trait RedisDriverTrait
30 30
 {
31
-    /**
32
-     * @param ExtendedCacheItemInterface $item
33
-     * @return ?array<string, mixed>
34
-     */
35
-    protected function driverRead(ExtendedCacheItemInterface $item): ?array
36
-    {
37
-        $val = $this->instance->get($item->getKey());
38
-        if (!$val) {
39
-            return null;
40
-        }
31
+	/**
32
+	 * @param ExtendedCacheItemInterface $item
33
+	 * @return ?array<string, mixed>
34
+	 */
35
+	protected function driverRead(ExtendedCacheItemInterface $item): ?array
36
+	{
37
+		$val = $this->instance->get($item->getKey());
38
+		if (!$val) {
39
+			return null;
40
+		}
41 41
 
42
-        return $this->decode($val);
43
-    }
42
+		return $this->decode($val);
43
+	}
44 44
 
45
-    /**
46
-     * @param ExtendedCacheItemInterface ...$items
47
-     * @return array<array<string, mixed>>
48
-     * @throws \Phpfastcache\Exceptions\PhpfastcacheDriverException
49
-     * @throws \RedisException
50
-     */
51
-    protected function driverReadMultiple(ExtendedCacheItemInterface ...$items): array
52
-    {
53
-        $keys = $this->getKeys($items);
45
+	/**
46
+	 * @param ExtendedCacheItemInterface ...$items
47
+	 * @return array<array<string, mixed>>
48
+	 * @throws \Phpfastcache\Exceptions\PhpfastcacheDriverException
49
+	 * @throws \RedisException
50
+	 */
51
+	protected function driverReadMultiple(ExtendedCacheItemInterface ...$items): array
52
+	{
53
+		$keys = $this->getKeys($items);
54 54
 
55
-        return array_combine($keys, array_map(
56
-            fn($val) => $val ? $this->decode($val) : null,
57
-            $this->instance->mGet($keys)
58
-        ));
59
-    }
55
+		return array_combine($keys, array_map(
56
+			fn($val) => $val ? $this->decode($val) : null,
57
+			$this->instance->mGet($keys)
58
+		));
59
+	}
60 60
 
61
-    /**
62
-     * @param ExtendedCacheItemInterface $item
63
-     * @return mixed
64
-     * @throws PhpfastcacheInvalidArgumentException
65
-     * @throws PhpfastcacheLogicException
66
-     */
67
-    protected function driverWrite(ExtendedCacheItemInterface $item): bool
68
-    {
69
-        $this->assertCacheItemType($item, self::getItemClass());
61
+	/**
62
+	 * @param ExtendedCacheItemInterface $item
63
+	 * @return mixed
64
+	 * @throws PhpfastcacheInvalidArgumentException
65
+	 * @throws PhpfastcacheLogicException
66
+	 */
67
+	protected function driverWrite(ExtendedCacheItemInterface $item): bool
68
+	{
69
+		$this->assertCacheItemType($item, self::getItemClass());
70 70
 
71
-        $ttl = $item->getExpirationDate()->getTimestamp() - time();
71
+		$ttl = $item->getExpirationDate()->getTimestamp() - time();
72 72
 
73
-        /**
74
-         * @see https://redis.io/commands/setex
75
-         * @see https://redis.io/commands/expire
76
-         */
77
-        if ($ttl <= 0) {
78
-            return $this->instance->expire($item->getKey(), 0);
79
-        }
73
+		/**
74
+		 * @see https://redis.io/commands/setex
75
+		 * @see https://redis.io/commands/expire
76
+		 */
77
+		if ($ttl <= 0) {
78
+			return $this->instance->expire($item->getKey(), 0);
79
+		}
80 80
 
81
-        return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)));
82
-    }
81
+		return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)));
82
+	}
83 83
 
84
-    /**
85
-     * @param string $key
86
-     * @param string $encodedKey
87
-     * @return bool
88
-     * @throws \RedisException
89
-     */
90
-    protected function driverDelete(string $key, string $encodedKey): bool
91
-    {
92
-        return (bool) $this->instance->del($key);
93
-    }
84
+	/**
85
+	 * @param string $key
86
+	 * @param string $encodedKey
87
+	 * @return bool
88
+	 * @throws \RedisException
89
+	 */
90
+	protected function driverDelete(string $key, string $encodedKey): bool
91
+	{
92
+		return (bool) $this->instance->del($key);
93
+	}
94 94
 
95
-    /**
96
-     * @param string[] $keys
97
-     * @return bool
98
-     */
99
-    protected function driverDeleteMultiple(array $keys): bool
100
-    {
101
-        return (bool) $this->instance->del(...$keys);
102
-    }
95
+	/**
96
+	 * @param string[] $keys
97
+	 * @return bool
98
+	 */
99
+	protected function driverDeleteMultiple(array $keys): bool
100
+	{
101
+		return (bool) $this->instance->del(...$keys);
102
+	}
103 103
 }
Please login to merge, or discard this patch.
vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Redis/Config.php 1 patch
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -22,140 +22,140 @@
 block discarded – undo
22 22
 
23 23
 class Config extends ConfigurationOption
24 24
 {
25
-    protected string $host = '127.0.0.1';
26
-    protected int $port = 6379;
27
-    protected string $password = '';
28
-    protected int $database = 0;
29
-    protected int $timeout = 5;
30
-    protected ?RedisClient $redisClient = null;
31
-    protected string $optPrefix = '';
25
+	protected string $host = '127.0.0.1';
26
+	protected int $port = 6379;
27
+	protected string $password = '';
28
+	protected int $database = 0;
29
+	protected int $timeout = 5;
30
+	protected ?RedisClient $redisClient = null;
31
+	protected string $optPrefix = '';
32 32
 /**
33
-     * @return string
34
-     */
35
-    public function getHost(): string
36
-    {
37
-        return $this->host;
38
-    }
39
-
40
-    /**
41
-     * @param string $host
42
-     * @return static
43
-     * @throws PhpfastcacheLogicException
44
-     */
45
-    public function setHost(string $host): static
46
-    {
47
-        return $this->setProperty('host', $host);
48
-    }
49
-
50
-    /**
51
-     * @return int
52
-     */
53
-    public function getPort(): int
54
-    {
55
-        return $this->port;
56
-    }
57
-
58
-    /**
59
-     * @param int $port
60
-     * @return static
61
-     * @throws PhpfastcacheLogicException
62
-     */
63
-    public function setPort(int $port): static
64
-    {
65
-        return $this->setProperty('port', $port);
66
-    }
67
-
68
-    /**
69
-     * @return string
70
-     */
71
-    public function getPassword(): string
72
-    {
73
-        return $this->password;
74
-    }
75
-
76
-    /**
77
-     * @param string $password
78
-     *
79
-     * @return static
80
-     * @throws PhpfastcacheLogicException
81
-     */
82
-    public function setPassword(string $password): static
83
-    {
84
-        return $this->setProperty('password', $password);
85
-    }
86
-
87
-    /**
88
-     * @return null|int
89
-     */
90
-    public function getDatabase(): ?int
91
-    {
92
-        return $this->database;
93
-    }
94
-
95
-    /**
96
-     * @param int|null $database
97
-     *
98
-     * @return static
99
-     * @throws PhpfastcacheLogicException
100
-     */
101
-    public function setDatabase(int $database = null): static
102
-    {
103
-        return $this->setProperty('database', $database);
104
-    }
105
-
106
-    /**
107
-     * @return int
108
-     */
109
-    public function getTimeout(): int
110
-    {
111
-        return $this->timeout;
112
-    }
113
-
114
-    /**
115
-     * @param int $timeout
116
-     * @return static
117
-     * @throws PhpfastcacheLogicException
118
-     */
119
-    public function setTimeout(int $timeout): static
120
-    {
121
-        return $this->setProperty('timeout', $timeout);
122
-    }
123
-
124
-    /**
125
-     * @return RedisClient|null
126
-     */
127
-    public function getRedisClient(): ?RedisClient
128
-    {
129
-        return $this->redisClient;
130
-    }
131
-
132
-    /**
133
-     * @param RedisClient|null $redisClient
134
-     * @return Config
135
-     * @throws PhpfastcacheLogicException
136
-     */
137
-    public function setRedisClient(?RedisClient $redisClient): Config
138
-    {
139
-        return $this->setProperty('redisClient', $redisClient);
140
-    }
141
-
142
-    /**
143
-     * @return string
144
-     * @since 7.0.2
145
-     */
146
-    public function getOptPrefix(): string
147
-    {
148
-        return $this->optPrefix;
149
-    }
150
-
151
-    /**
152
-     * @param string $optPrefix
153
-     * @return Config
154
-     * @throws PhpfastcacheLogicException
155
-     * @since 7.0.2
156
-     */
157
-    public function setOptPrefix(string $optPrefix): Config
158
-    {
159
-        return $this->setProperty('optPrefix', trim($optPrefix));
160
-    }
33
+	 * @return string
34
+	 */
35
+	public function getHost(): string
36
+	{
37
+		return $this->host;
38
+	}
39
+
40
+	/**
41
+	 * @param string $host
42
+	 * @return static
43
+	 * @throws PhpfastcacheLogicException
44
+	 */
45
+	public function setHost(string $host): static
46
+	{
47
+		return $this->setProperty('host', $host);
48
+	}
49
+
50
+	/**
51
+	 * @return int
52
+	 */
53
+	public function getPort(): int
54
+	{
55
+		return $this->port;
56
+	}
57
+
58
+	/**
59
+	 * @param int $port
60
+	 * @return static
61
+	 * @throws PhpfastcacheLogicException
62
+	 */
63
+	public function setPort(int $port): static
64
+	{
65
+		return $this->setProperty('port', $port);
66
+	}
67
+
68
+	/**
69
+	 * @return string
70
+	 */
71
+	public function getPassword(): string
72
+	{
73
+		return $this->password;
74
+	}
75
+
76
+	/**
77
+	 * @param string $password
78
+	 *
79
+	 * @return static
80
+	 * @throws PhpfastcacheLogicException
81
+	 */
82
+	public function setPassword(string $password): static
83
+	{
84
+		return $this->setProperty('password', $password);
85
+	}
86
+
87
+	/**
88
+	 * @return null|int
89
+	 */
90
+	public function getDatabase(): ?int
91
+	{
92
+		return $this->database;
93
+	}
94
+
95
+	/**
96
+	 * @param int|null $database
97
+	 *
98
+	 * @return static
99
+	 * @throws PhpfastcacheLogicException
100
+	 */
101
+	public function setDatabase(int $database = null): static
102
+	{
103
+		return $this->setProperty('database', $database);
104
+	}
105
+
106
+	/**
107
+	 * @return int
108
+	 */
109
+	public function getTimeout(): int
110
+	{
111
+		return $this->timeout;
112
+	}
113
+
114
+	/**
115
+	 * @param int $timeout
116
+	 * @return static
117
+	 * @throws PhpfastcacheLogicException
118
+	 */
119
+	public function setTimeout(int $timeout): static
120
+	{
121
+		return $this->setProperty('timeout', $timeout);
122
+	}
123
+
124
+	/**
125
+	 * @return RedisClient|null
126
+	 */
127
+	public function getRedisClient(): ?RedisClient
128
+	{
129
+		return $this->redisClient;
130
+	}
131
+
132
+	/**
133
+	 * @param RedisClient|null $redisClient
134
+	 * @return Config
135
+	 * @throws PhpfastcacheLogicException
136
+	 */
137
+	public function setRedisClient(?RedisClient $redisClient): Config
138
+	{
139
+		return $this->setProperty('redisClient', $redisClient);
140
+	}
141
+
142
+	/**
143
+	 * @return string
144
+	 * @since 7.0.2
145
+	 */
146
+	public function getOptPrefix(): string
147
+	{
148
+		return $this->optPrefix;
149
+	}
150
+
151
+	/**
152
+	 * @param string $optPrefix
153
+	 * @return Config
154
+	 * @throws PhpfastcacheLogicException
155
+	 * @since 7.0.2
156
+	 */
157
+	public function setOptPrefix(string $optPrefix): Config
158
+	{
159
+		return $this->setProperty('optPrefix', trim($optPrefix));
160
+	}
161 161
 }
Please login to merge, or discard this patch.