Test Failed
Branch master (2f190b)
by Mike
11:47
created
files/php/lib/phpfastcache/lib/Phpfastcache/Drivers/Memcache/Driver.php 1 patch
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -37,170 +37,170 @@
 block discarded – undo
37 37
  */
38 38
 class Driver implements ExtendedCacheItemPoolInterface, AggregatablePoolInterface
39 39
 {
40
-    use DriverBaseTrait {
41
-        __construct as protected __parentConstruct;
42
-    }
43
-    use MemcacheDriverCollisionDetectorTrait;
44
-
45
-    /**
46
-     * @var int
47
-     */
48
-    protected $memcacheFlags = 0;
49
-
50
-    /**
51
-     * Driver constructor.
52
-     * @param ConfigurationOption $config
53
-     * @param string $instanceId
54
-     * @throws PhpfastcacheDriverException
55
-     */
56
-    public function __construct(ConfigurationOption $config, string $instanceId)
57
-    {
58
-        self::checkCollision('Memcache');
59
-        $this->__parentConstruct($config, $instanceId);
60
-    }
61
-
62
-    /**
63
-     * @return bool
64
-     */
65
-    public function driverCheck(): bool
66
-    {
67
-        return class_exists('Memcache');
68
-    }
69
-
70
-    /**
71
-     * @return DriverStatistic
72
-     */
73
-    public function getStats(): DriverStatistic
74
-    {
75
-        $stats = (array)$this->instance->getstats();
76
-        $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0);
77
-        $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion');
78
-        $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0);
79
-
80
-        $date = (new DateTime())->setTimestamp(time() - $stats['uptime']);
81
-
82
-        return (new DriverStatistic())
83
-            ->setData(implode(', ', array_keys($this->itemInstances)))
84
-            ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822)))
85
-            ->setRawData($stats)
86
-            ->setSize((int)$stats['bytes']);
87
-    }
88
-
89
-    /**
90
-     * @return bool
91
-     */
92
-    protected function driverConnect(): bool
93
-    {
94
-        $this->instance = new MemcacheSoftware();
95
-
96
-        if (count($this->getConfig()->getServers()) < 1) {
97
-            $this->getConfig()->setServers(
98
-               [
99
-                    [
100
-                        'host' => $this->getConfig()->getHost(),
101
-                        'path' => $this->getConfig()->getPath(),
102
-                        'port' => $this->getConfig()->getPort(),
103
-                    ]
104
-                ]
105
-            );
106
-        }
107
-
108
-        foreach ($this->getConfig()->getServers() as $server) {
109
-            try {
110
-                /**
111
-                 * If path is provided we consider it as an UNIX Socket
112
-                 */
113
-                if (!empty($server['path']) && !$this->instance->addServer($server['path'], 0)) {
114
-                    $this->fallback = true;
115
-                } elseif (!empty($server['host']) && !$this->instance->addServer($server['host'], $server['port'])) {
116
-                    $this->fallback = true;
117
-                }
118
-            } catch (Exception $e) {
119
-                $this->fallback = true;
120
-            }
121
-
122
-            /**
123
-             * Since Memcached does not throw
124
-             * any error if not connected ...
125
-             */
126
-            if (!$this->instance->getServerStatus(
127
-                !empty($server['path']) ? $server['path'] : $server['host'],
128
-                !empty($server['port']) ? $server['port'] : 0
129
-            )) {
130
-                throw new PhpfastcacheDriverException('Memcache seems to not be connected');
131
-            }
132
-        }
133
-
134
-        return true;
135
-    }
136
-
137
-    /**
138
-     * @param CacheItemInterface $item
139
-     * @return null|array
140
-     */
141
-    protected function driverRead(CacheItemInterface $item)
142
-    {
143
-        $val = $this->instance->get($item->getKey());
144
-
145
-        if ($val === false) {
146
-            return null;
147
-        }
148
-
149
-        return $val;
150
-    }
151
-
152
-    /**
153
-     * @param CacheItemInterface $item
154
-     * @return mixed
155
-     * @throws PhpfastcacheInvalidArgumentException
156
-     */
157
-    protected function driverWrite(CacheItemInterface $item): bool
158
-    {
159
-        /**
160
-         * Check for Cross-Driver type confusion
161
-         */
162
-        if ($item instanceof Item) {
163
-            $ttl = $item->getExpirationDate()->getTimestamp() - time();
164
-
165
-            // Memcache will only allow a expiration timer less than 2592000 seconds,
166
-            // otherwise, it will assume you're giving it a UNIX timestamp.
167
-            if ($ttl > 2592000) {
168
-                $ttl = time() + $ttl;
169
-            }
170
-            return $this->instance->set($item->getKey(), $this->driverPreWrap($item), $this->memcacheFlags, $ttl);
171
-        }
172
-
173
-        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
174
-    }
175
-
176
-    /**
177
-     * @param CacheItemInterface $item
178
-     * @return bool
179
-     * @throws PhpfastcacheInvalidArgumentException
180
-     */
181
-    protected function driverDelete(CacheItemInterface $item): bool
182
-    {
183
-        /**
184
-         * Check for Cross-Driver type confusion
185
-         */
186
-        if ($item instanceof Item) {
187
-            return $this->instance->delete($item->getKey());
188
-        }
189
-
190
-        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
191
-    }
192
-
193
-    /********************
40
+	use DriverBaseTrait {
41
+		__construct as protected __parentConstruct;
42
+	}
43
+	use MemcacheDriverCollisionDetectorTrait;
44
+
45
+	/**
46
+	 * @var int
47
+	 */
48
+	protected $memcacheFlags = 0;
49
+
50
+	/**
51
+	 * Driver constructor.
52
+	 * @param ConfigurationOption $config
53
+	 * @param string $instanceId
54
+	 * @throws PhpfastcacheDriverException
55
+	 */
56
+	public function __construct(ConfigurationOption $config, string $instanceId)
57
+	{
58
+		self::checkCollision('Memcache');
59
+		$this->__parentConstruct($config, $instanceId);
60
+	}
61
+
62
+	/**
63
+	 * @return bool
64
+	 */
65
+	public function driverCheck(): bool
66
+	{
67
+		return class_exists('Memcache');
68
+	}
69
+
70
+	/**
71
+	 * @return DriverStatistic
72
+	 */
73
+	public function getStats(): DriverStatistic
74
+	{
75
+		$stats = (array)$this->instance->getstats();
76
+		$stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0);
77
+		$stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion');
78
+		$stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0);
79
+
80
+		$date = (new DateTime())->setTimestamp(time() - $stats['uptime']);
81
+
82
+		return (new DriverStatistic())
83
+			->setData(implode(', ', array_keys($this->itemInstances)))
84
+			->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822)))
85
+			->setRawData($stats)
86
+			->setSize((int)$stats['bytes']);
87
+	}
88
+
89
+	/**
90
+	 * @return bool
91
+	 */
92
+	protected function driverConnect(): bool
93
+	{
94
+		$this->instance = new MemcacheSoftware();
95
+
96
+		if (count($this->getConfig()->getServers()) < 1) {
97
+			$this->getConfig()->setServers(
98
+			   [
99
+					[
100
+						'host' => $this->getConfig()->getHost(),
101
+						'path' => $this->getConfig()->getPath(),
102
+						'port' => $this->getConfig()->getPort(),
103
+					]
104
+				]
105
+			);
106
+		}
107
+
108
+		foreach ($this->getConfig()->getServers() as $server) {
109
+			try {
110
+				/**
111
+				 * If path is provided we consider it as an UNIX Socket
112
+				 */
113
+				if (!empty($server['path']) && !$this->instance->addServer($server['path'], 0)) {
114
+					$this->fallback = true;
115
+				} elseif (!empty($server['host']) && !$this->instance->addServer($server['host'], $server['port'])) {
116
+					$this->fallback = true;
117
+				}
118
+			} catch (Exception $e) {
119
+				$this->fallback = true;
120
+			}
121
+
122
+			/**
123
+			 * Since Memcached does not throw
124
+			 * any error if not connected ...
125
+			 */
126
+			if (!$this->instance->getServerStatus(
127
+				!empty($server['path']) ? $server['path'] : $server['host'],
128
+				!empty($server['port']) ? $server['port'] : 0
129
+			)) {
130
+				throw new PhpfastcacheDriverException('Memcache seems to not be connected');
131
+			}
132
+		}
133
+
134
+		return true;
135
+	}
136
+
137
+	/**
138
+	 * @param CacheItemInterface $item
139
+	 * @return null|array
140
+	 */
141
+	protected function driverRead(CacheItemInterface $item)
142
+	{
143
+		$val = $this->instance->get($item->getKey());
144
+
145
+		if ($val === false) {
146
+			return null;
147
+		}
148
+
149
+		return $val;
150
+	}
151
+
152
+	/**
153
+	 * @param CacheItemInterface $item
154
+	 * @return mixed
155
+	 * @throws PhpfastcacheInvalidArgumentException
156
+	 */
157
+	protected function driverWrite(CacheItemInterface $item): bool
158
+	{
159
+		/**
160
+		 * Check for Cross-Driver type confusion
161
+		 */
162
+		if ($item instanceof Item) {
163
+			$ttl = $item->getExpirationDate()->getTimestamp() - time();
164
+
165
+			// Memcache will only allow a expiration timer less than 2592000 seconds,
166
+			// otherwise, it will assume you're giving it a UNIX timestamp.
167
+			if ($ttl > 2592000) {
168
+				$ttl = time() + $ttl;
169
+			}
170
+			return $this->instance->set($item->getKey(), $this->driverPreWrap($item), $this->memcacheFlags, $ttl);
171
+		}
172
+
173
+		throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
174
+	}
175
+
176
+	/**
177
+	 * @param CacheItemInterface $item
178
+	 * @return bool
179
+	 * @throws PhpfastcacheInvalidArgumentException
180
+	 */
181
+	protected function driverDelete(CacheItemInterface $item): bool
182
+	{
183
+		/**
184
+		 * Check for Cross-Driver type confusion
185
+		 */
186
+		if ($item instanceof Item) {
187
+			return $this->instance->delete($item->getKey());
188
+		}
189
+
190
+		throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
191
+	}
192
+
193
+	/********************
194 194
      *
195 195
      * PSR-6 Extended Methods
196 196
      *
197 197
      *******************/
198 198
 
199
-    /**
200
-     * @return bool
201
-     */
202
-    protected function driverClear(): bool
203
-    {
204
-        return $this->instance->flush();
205
-    }
199
+	/**
200
+	 * @return bool
201
+	 */
202
+	protected function driverClear(): bool
203
+	{
204
+		return $this->instance->flush();
205
+	}
206 206
 }
Please login to merge, or discard this patch.
files/php/lib/phpfastcache/lib/Phpfastcache/Drivers/Devfalse/Item.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -28,34 +28,34 @@
 block discarded – undo
28 28
  */
29 29
 class Item implements ExtendedCacheItemInterface
30 30
 {
31
-    use ItemBaseTrait {
32
-        ItemBaseTrait::__construct as __BaseConstruct;
33
-    }
34
-
35
-    /**
36
-     * Item constructor.
37
-     * @param Driver $driver
38
-     * @param $key
39
-     * @throws PhpfastcacheInvalidArgumentException
40
-     */
41
-    public function __construct(DevfalseDriver $driver, $key)
42
-    {
43
-        $this->__BaseConstruct($driver, $key);
44
-    }
45
-
46
-    /**
47
-     * @param ExtendedCacheItemPoolInterface $driver
48
-     * @return static
49
-     * @throws PhpfastcacheInvalidArgumentException
50
-     */
51
-    public function setDriver(ExtendedCacheItemPoolInterface $driver)
52
-    {
53
-        if ($driver instanceof DevfalseDriver) {
54
-            $this->driver = $driver;
55
-
56
-            return $this;
57
-        }
58
-
59
-        throw new PhpfastcacheInvalidArgumentException('Invalid driver instance');
60
-    }
31
+	use ItemBaseTrait {
32
+		ItemBaseTrait::__construct as __BaseConstruct;
33
+	}
34
+
35
+	/**
36
+	 * Item constructor.
37
+	 * @param Driver $driver
38
+	 * @param $key
39
+	 * @throws PhpfastcacheInvalidArgumentException
40
+	 */
41
+	public function __construct(DevfalseDriver $driver, $key)
42
+	{
43
+		$this->__BaseConstruct($driver, $key);
44
+	}
45
+
46
+	/**
47
+	 * @param ExtendedCacheItemPoolInterface $driver
48
+	 * @return static
49
+	 * @throws PhpfastcacheInvalidArgumentException
50
+	 */
51
+	public function setDriver(ExtendedCacheItemPoolInterface $driver)
52
+	{
53
+		if ($driver instanceof DevfalseDriver) {
54
+			$this->driver = $driver;
55
+
56
+			return $this;
57
+		}
58
+
59
+		throw new PhpfastcacheInvalidArgumentException('Invalid driver instance');
60
+	}
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
files/php/lib/phpfastcache/lib/Phpfastcache/Drivers/Devfalse/Driver.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -31,96 +31,96 @@
 block discarded – undo
31 31
  */
32 32
 class Driver implements ExtendedCacheItemPoolInterface
33 33
 {
34
-    use DriverBaseTrait;
35
-
36
-    /**
37
-     * @return bool
38
-     */
39
-    public function driverCheck(): bool
40
-    {
41
-        return true;
42
-    }
43
-
44
-    /**
45
-     * @return DriverStatistic
46
-     */
47
-    public function getStats(): DriverStatistic
48
-    {
49
-        $stat = new DriverStatistic();
50
-        $stat->setInfo('[Devfalse] A void info string')
51
-            ->setSize(0)
52
-            ->setData(implode(', ', array_keys($this->itemInstances)))
53
-            ->setRawData(false);
54
-
55
-        return $stat;
56
-    }
57
-
58
-    /**
59
-     * @param CacheItemInterface $item
60
-     * @return bool
61
-     * @throws PhpfastcacheInvalidArgumentException
62
-     */
63
-    protected function driverWrite(CacheItemInterface $item): bool
64
-    {
65
-        /**
66
-         * Check for Cross-Driver type confusion
67
-         */
68
-        if ($item instanceof Item) {
69
-            return true;
70
-        }
71
-
72
-        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
73
-    }
74
-
75
-    /**
76
-     * @param CacheItemInterface $item
77
-     * @return array
78
-     */
79
-    protected function driverRead(CacheItemInterface $item): array
80
-    {
81
-        return [
82
-            self::DRIVER_DATA_WRAPPER_INDEX => false,
83
-            self::DRIVER_TAGS_WRAPPER_INDEX => [],
84
-            self::DRIVER_EDATE_WRAPPER_INDEX => new DateTime(),
85
-        ];
86
-    }
87
-
88
-    /**
89
-     * @param CacheItemInterface $item
90
-     * @return bool
91
-     * @throws PhpfastcacheInvalidArgumentException
92
-     */
93
-    protected function driverDelete(CacheItemInterface $item): bool
94
-    {
95
-        /**
96
-         * Check for Cross-Driver type confusion
97
-         */
98
-        if ($item instanceof Item) {
99
-            return true;
100
-        }
101
-
102
-        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
103
-    }
104
-
105
-    /**
106
-     * @return bool
107
-     */
108
-    protected function driverClear(): bool
109
-    {
110
-        return true;
111
-    }
112
-
113
-    /********************
34
+	use DriverBaseTrait;
35
+
36
+	/**
37
+	 * @return bool
38
+	 */
39
+	public function driverCheck(): bool
40
+	{
41
+		return true;
42
+	}
43
+
44
+	/**
45
+	 * @return DriverStatistic
46
+	 */
47
+	public function getStats(): DriverStatistic
48
+	{
49
+		$stat = new DriverStatistic();
50
+		$stat->setInfo('[Devfalse] A void info string')
51
+			->setSize(0)
52
+			->setData(implode(', ', array_keys($this->itemInstances)))
53
+			->setRawData(false);
54
+
55
+		return $stat;
56
+	}
57
+
58
+	/**
59
+	 * @param CacheItemInterface $item
60
+	 * @return bool
61
+	 * @throws PhpfastcacheInvalidArgumentException
62
+	 */
63
+	protected function driverWrite(CacheItemInterface $item): bool
64
+	{
65
+		/**
66
+		 * Check for Cross-Driver type confusion
67
+		 */
68
+		if ($item instanceof Item) {
69
+			return true;
70
+		}
71
+
72
+		throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
73
+	}
74
+
75
+	/**
76
+	 * @param CacheItemInterface $item
77
+	 * @return array
78
+	 */
79
+	protected function driverRead(CacheItemInterface $item): array
80
+	{
81
+		return [
82
+			self::DRIVER_DATA_WRAPPER_INDEX => false,
83
+			self::DRIVER_TAGS_WRAPPER_INDEX => [],
84
+			self::DRIVER_EDATE_WRAPPER_INDEX => new DateTime(),
85
+		];
86
+	}
87
+
88
+	/**
89
+	 * @param CacheItemInterface $item
90
+	 * @return bool
91
+	 * @throws PhpfastcacheInvalidArgumentException
92
+	 */
93
+	protected function driverDelete(CacheItemInterface $item): bool
94
+	{
95
+		/**
96
+		 * Check for Cross-Driver type confusion
97
+		 */
98
+		if ($item instanceof Item) {
99
+			return true;
100
+		}
101
+
102
+		throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
103
+	}
104
+
105
+	/**
106
+	 * @return bool
107
+	 */
108
+	protected function driverClear(): bool
109
+	{
110
+		return true;
111
+	}
112
+
113
+	/********************
114 114
      *
115 115
      * PSR-6 Extended Methods
116 116
      *
117 117
      *******************/
118 118
 
119
-    /**
120
-     * @return bool
121
-     */
122
-    protected function driverConnect(): bool
123
-    {
124
-        return true;
125
-    }
119
+	/**
120
+	 * @return bool
121
+	 */
122
+	protected function driverConnect(): bool
123
+	{
124
+		return true;
125
+	}
126 126
 }
127 127
\ No newline at end of file
Please login to merge, or discard this patch.
plugins/files/php/lib/phpfastcache/lib/Phpfastcache/Drivers/Apcu/Item.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -27,34 +27,34 @@
 block discarded – undo
27 27
  */
28 28
 class Item implements ExtendedCacheItemInterface
29 29
 {
30
-    use ItemBaseTrait {
31
-        ItemBaseTrait::__construct as __BaseConstruct;
32
-    }
33
-
34
-    /**
35
-     * Item constructor.
36
-     * @param Driver $driver
37
-     * @param $key
38
-     * @throws PhpfastcacheInvalidArgumentException
39
-     */
40
-    public function __construct(ApcuDriver $driver, $key)
41
-    {
42
-        $this->__BaseConstruct($driver, $key);
43
-    }
44
-
45
-    /**
46
-     * @param ExtendedCacheItemPoolInterface $driver
47
-     * @return static
48
-     * @throws PhpfastcacheInvalidArgumentException
49
-     */
50
-    public function setDriver(ExtendedCacheItemPoolInterface $driver)
51
-    {
52
-        if ($driver instanceof ApcuDriver) {
53
-            $this->driver = $driver;
54
-
55
-            return $this;
56
-        }
57
-
58
-        throw new PhpfastcacheInvalidArgumentException('Invalid driver instance');
59
-    }
30
+	use ItemBaseTrait {
31
+		ItemBaseTrait::__construct as __BaseConstruct;
32
+	}
33
+
34
+	/**
35
+	 * Item constructor.
36
+	 * @param Driver $driver
37
+	 * @param $key
38
+	 * @throws PhpfastcacheInvalidArgumentException
39
+	 */
40
+	public function __construct(ApcuDriver $driver, $key)
41
+	{
42
+		$this->__BaseConstruct($driver, $key);
43
+	}
44
+
45
+	/**
46
+	 * @param ExtendedCacheItemPoolInterface $driver
47
+	 * @return static
48
+	 * @throws PhpfastcacheInvalidArgumentException
49
+	 */
50
+	public function setDriver(ExtendedCacheItemPoolInterface $driver)
51
+	{
52
+		if ($driver instanceof ApcuDriver) {
53
+			$this->driver = $driver;
54
+
55
+			return $this;
56
+		}
57
+
58
+		throw new PhpfastcacheInvalidArgumentException('Invalid driver instance');
59
+	}
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
plugins/files/php/lib/phpfastcache/lib/Phpfastcache/Drivers/Apcu/Driver.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -32,105 +32,105 @@
 block discarded – undo
32 32
  */
33 33
 class Driver implements ExtendedCacheItemPoolInterface, AggregatablePoolInterface
34 34
 {
35
-    use DriverBaseTrait;
36
-
37
-    /**
38
-     * @return bool
39
-     */
40
-    public function driverCheck(): bool
41
-    {
42
-        return extension_loaded('apcu') && ini_get('apc.enabled');
43
-    }
44
-
45
-    /**
46
-     * @return DriverStatistic
47
-     */
48
-    public function getStats(): DriverStatistic
49
-    {
50
-        $stats = (array)apcu_cache_info();
51
-        $date = (new DateTime())->setTimestamp($stats['start_time']);
52
-
53
-        return (new DriverStatistic())
54
-            ->setData(implode(', ', array_keys($this->itemInstances)))
55
-            ->setInfo(
56
-                sprintf(
57
-                    "The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.",
58
-                    $date->format(DATE_RFC2822),
59
-                    $stats['num_entries']
60
-                )
61
-            )
62
-            ->setRawData($stats)
63
-            ->setSize((int)$stats['mem_size']);
64
-    }
65
-
66
-    /**
67
-     * @return bool
68
-     */
69
-    protected function driverConnect(): bool
70
-    {
71
-        return true;
72
-    }
73
-
74
-    /**
75
-     * @param CacheItemInterface $item
76
-     * @return bool
77
-     * @throws PhpfastcacheInvalidArgumentException
78
-     */
79
-    protected function driverWrite(CacheItemInterface $item): bool
80
-    {
81
-        /**
82
-         * Check for Cross-Driver type confusion
83
-         */
84
-        if ($item instanceof Item) {
85
-            return (bool)apcu_store($item->getKey(), $this->driverPreWrap($item), $item->getTtl());
86
-        }
87
-
88
-        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
89
-    }
90
-
91
-    /**
92
-     * @param CacheItemInterface $item
93
-     * @return null|array
94
-     */
95
-    protected function driverRead(CacheItemInterface $item)
96
-    {
97
-        $data = apcu_fetch($item->getKey(), $success);
98
-
99
-        if ($success === false) {
100
-            return null;
101
-        }
102
-
103
-        return $data;
104
-    }
105
-
106
-    /**
107
-     * @param CacheItemInterface $item
108
-     * @return bool
109
-     * @throws PhpfastcacheInvalidArgumentException
110
-     */
111
-    protected function driverDelete(CacheItemInterface $item): bool
112
-    {
113
-        /**
114
-         * Check for Cross-Driver type confusion
115
-         */
116
-        if ($item instanceof Item) {
117
-            return (bool)apcu_delete($item->getKey());
118
-        }
119
-
120
-        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
121
-    }
122
-
123
-    /********************
35
+	use DriverBaseTrait;
36
+
37
+	/**
38
+	 * @return bool
39
+	 */
40
+	public function driverCheck(): bool
41
+	{
42
+		return extension_loaded('apcu') && ini_get('apc.enabled');
43
+	}
44
+
45
+	/**
46
+	 * @return DriverStatistic
47
+	 */
48
+	public function getStats(): DriverStatistic
49
+	{
50
+		$stats = (array)apcu_cache_info();
51
+		$date = (new DateTime())->setTimestamp($stats['start_time']);
52
+
53
+		return (new DriverStatistic())
54
+			->setData(implode(', ', array_keys($this->itemInstances)))
55
+			->setInfo(
56
+				sprintf(
57
+					"The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.",
58
+					$date->format(DATE_RFC2822),
59
+					$stats['num_entries']
60
+				)
61
+			)
62
+			->setRawData($stats)
63
+			->setSize((int)$stats['mem_size']);
64
+	}
65
+
66
+	/**
67
+	 * @return bool
68
+	 */
69
+	protected function driverConnect(): bool
70
+	{
71
+		return true;
72
+	}
73
+
74
+	/**
75
+	 * @param CacheItemInterface $item
76
+	 * @return bool
77
+	 * @throws PhpfastcacheInvalidArgumentException
78
+	 */
79
+	protected function driverWrite(CacheItemInterface $item): bool
80
+	{
81
+		/**
82
+		 * Check for Cross-Driver type confusion
83
+		 */
84
+		if ($item instanceof Item) {
85
+			return (bool)apcu_store($item->getKey(), $this->driverPreWrap($item), $item->getTtl());
86
+		}
87
+
88
+		throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
89
+	}
90
+
91
+	/**
92
+	 * @param CacheItemInterface $item
93
+	 * @return null|array
94
+	 */
95
+	protected function driverRead(CacheItemInterface $item)
96
+	{
97
+		$data = apcu_fetch($item->getKey(), $success);
98
+
99
+		if ($success === false) {
100
+			return null;
101
+		}
102
+
103
+		return $data;
104
+	}
105
+
106
+	/**
107
+	 * @param CacheItemInterface $item
108
+	 * @return bool
109
+	 * @throws PhpfastcacheInvalidArgumentException
110
+	 */
111
+	protected function driverDelete(CacheItemInterface $item): bool
112
+	{
113
+		/**
114
+		 * Check for Cross-Driver type confusion
115
+		 */
116
+		if ($item instanceof Item) {
117
+			return (bool)apcu_delete($item->getKey());
118
+		}
119
+
120
+		throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
121
+	}
122
+
123
+	/********************
124 124
      *
125 125
      * PSR-6 Extended Methods
126 126
      *
127 127
      *******************/
128 128
 
129
-    /**
130
-     * @return bool
131
-     */
132
-    protected function driverClear(): bool
133
-    {
134
-        return @apcu_clear_cache();
135
-    }
129
+	/**
130
+	 * @return bool
131
+	 */
132
+	protected function driverClear(): bool
133
+	{
134
+		return @apcu_clear_cache();
135
+	}
136 136
 }
Please login to merge, or discard this patch.
files/php/lib/phpfastcache/lib/Phpfastcache/Drivers/Zendshm/Item.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -26,34 +26,34 @@
 block discarded – undo
26 26
  */
27 27
 class Item implements ExtendedCacheItemInterface
28 28
 {
29
-    use ItemBaseTrait {
30
-        ItemBaseTrait::__construct as __BaseConstruct;
31
-    }
32
-
33
-    /**
34
-     * Item constructor.
35
-     * @param Driver $driver
36
-     * @param $key
37
-     * @throws PhpfastcacheInvalidArgumentException
38
-     */
39
-    public function __construct(ZendSHMDriver $driver, $key)
40
-    {
41
-        $this->__BaseConstruct($driver, $key);
42
-    }
43
-
44
-    /**
45
-     * @param ExtendedCacheItemPoolInterface $driver
46
-     * @return static
47
-     * @throws PhpfastcacheInvalidArgumentException
48
-     */
49
-    public function setDriver(ExtendedCacheItemPoolInterface $driver)
50
-    {
51
-        if ($driver instanceof ZendSHMDriver) {
52
-            $this->driver = $driver;
53
-
54
-            return $this;
55
-        }
56
-
57
-        throw new PhpfastcacheInvalidArgumentException('Invalid driver instance');
58
-    }
29
+	use ItemBaseTrait {
30
+		ItemBaseTrait::__construct as __BaseConstruct;
31
+	}
32
+
33
+	/**
34
+	 * Item constructor.
35
+	 * @param Driver $driver
36
+	 * @param $key
37
+	 * @throws PhpfastcacheInvalidArgumentException
38
+	 */
39
+	public function __construct(ZendSHMDriver $driver, $key)
40
+	{
41
+		$this->__BaseConstruct($driver, $key);
42
+	}
43
+
44
+	/**
45
+	 * @param ExtendedCacheItemPoolInterface $driver
46
+	 * @return static
47
+	 * @throws PhpfastcacheInvalidArgumentException
48
+	 */
49
+	public function setDriver(ExtendedCacheItemPoolInterface $driver)
50
+	{
51
+		if ($driver instanceof ZendSHMDriver) {
52
+			$this->driver = $driver;
53
+
54
+			return $this;
55
+		}
56
+
57
+		throw new PhpfastcacheInvalidArgumentException('Invalid driver instance');
58
+	}
59 59
 }
60 60
\ No newline at end of file
Please login to merge, or discard this patch.
files/php/lib/phpfastcache/lib/Phpfastcache/Drivers/Zendshm/Driver.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -31,110 +31,110 @@
 block discarded – undo
31 31
  */
32 32
 class Driver implements ExtendedCacheItemPoolInterface, AggregatablePoolInterface
33 33
 {
34
-    use DriverBaseTrait;
35
-
36
-    /**
37
-     * @return bool
38
-     */
39
-    public function driverCheck(): bool
40
-    {
41
-        return extension_loaded('Zend Data Cache') && function_exists('zend_shm_cache_store');
42
-    }
43
-
44
-    /**
45
-     * @return string
46
-     */
47
-    public function getHelp(): string
48
-    {
49
-        return <<<HELP
34
+	use DriverBaseTrait;
35
+
36
+	/**
37
+	 * @return bool
38
+	 */
39
+	public function driverCheck(): bool
40
+	{
41
+		return extension_loaded('Zend Data Cache') && function_exists('zend_shm_cache_store');
42
+	}
43
+
44
+	/**
45
+	 * @return string
46
+	 */
47
+	public function getHelp(): string
48
+	{
49
+		return <<<HELP
50 50
 <p>
51 51
 This driver rely on Zend Server 8.5+, see: https://www.zend.com/en/products/zend_server
52 52
 </p>
53 53
 HELP;
54
-    }
55
-
56
-    /**
57
-     * @return DriverStatistic
58
-     */
59
-    public function getStats(): DriverStatistic
60
-    {
61
-        $stats = (array)zend_shm_cache_info();
62
-        return (new DriverStatistic())
63
-            ->setData(implode(', ', array_keys($this->itemInstances)))
64
-            ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total']))
65
-            ->setRawData($stats)
66
-            ->setSize($stats['memory_total']);
67
-    }
68
-
69
-    /**
70
-     * @return bool
71
-     */
72
-    protected function driverConnect(): bool
73
-    {
74
-        return true;
75
-    }
76
-
77
-    /**
78
-     * @param CacheItemInterface $item
79
-     * @return null|array
80
-     */
81
-    protected function driverRead(CacheItemInterface $item)
82
-    {
83
-        $data = zend_shm_cache_fetch($item->getKey());
84
-        if ($data === false) {
85
-            return null;
86
-        }
87
-
88
-        return $data;
89
-    }
90
-
91
-    /**
92
-     * @param CacheItemInterface $item
93
-     * @return mixed
94
-     * @throws PhpfastcacheInvalidArgumentException
95
-     */
96
-    protected function driverWrite(CacheItemInterface $item): bool
97
-    {
98
-        /**
99
-         * Check for Cross-Driver type confusion
100
-         */
101
-        if ($item instanceof Item) {
102
-            $ttl = $item->getExpirationDate()->getTimestamp() - time();
103
-
104
-            return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0));
105
-        }
106
-
107
-        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
108
-    }
109
-
110
-    /********************
54
+	}
55
+
56
+	/**
57
+	 * @return DriverStatistic
58
+	 */
59
+	public function getStats(): DriverStatistic
60
+	{
61
+		$stats = (array)zend_shm_cache_info();
62
+		return (new DriverStatistic())
63
+			->setData(implode(', ', array_keys($this->itemInstances)))
64
+			->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total']))
65
+			->setRawData($stats)
66
+			->setSize($stats['memory_total']);
67
+	}
68
+
69
+	/**
70
+	 * @return bool
71
+	 */
72
+	protected function driverConnect(): bool
73
+	{
74
+		return true;
75
+	}
76
+
77
+	/**
78
+	 * @param CacheItemInterface $item
79
+	 * @return null|array
80
+	 */
81
+	protected function driverRead(CacheItemInterface $item)
82
+	{
83
+		$data = zend_shm_cache_fetch($item->getKey());
84
+		if ($data === false) {
85
+			return null;
86
+		}
87
+
88
+		return $data;
89
+	}
90
+
91
+	/**
92
+	 * @param CacheItemInterface $item
93
+	 * @return mixed
94
+	 * @throws PhpfastcacheInvalidArgumentException
95
+	 */
96
+	protected function driverWrite(CacheItemInterface $item): bool
97
+	{
98
+		/**
99
+		 * Check for Cross-Driver type confusion
100
+		 */
101
+		if ($item instanceof Item) {
102
+			$ttl = $item->getExpirationDate()->getTimestamp() - time();
103
+
104
+			return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0));
105
+		}
106
+
107
+		throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
108
+	}
109
+
110
+	/********************
111 111
      *
112 112
      * PSR-6 Extended Methods
113 113
      *
114 114
      *******************/
115 115
 
116
-    /**
117
-     * @param CacheItemInterface $item
118
-     * @return bool
119
-     * @throws PhpfastcacheInvalidArgumentException
120
-     */
121
-    protected function driverDelete(CacheItemInterface $item): bool
122
-    {
123
-        /**
124
-         * Check for Cross-Driver type confusion
125
-         */
126
-        if ($item instanceof Item) {
127
-            return (bool)zend_shm_cache_delete($item->getKey());
128
-        }
129
-
130
-        throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
131
-    }
132
-
133
-    /**
134
-     * @return bool
135
-     */
136
-    protected function driverClear(): bool
137
-    {
138
-        return @zend_shm_cache_clear();
139
-    }
116
+	/**
117
+	 * @param CacheItemInterface $item
118
+	 * @return bool
119
+	 * @throws PhpfastcacheInvalidArgumentException
120
+	 */
121
+	protected function driverDelete(CacheItemInterface $item): bool
122
+	{
123
+		/**
124
+		 * Check for Cross-Driver type confusion
125
+		 */
126
+		if ($item instanceof Item) {
127
+			return (bool)zend_shm_cache_delete($item->getKey());
128
+		}
129
+
130
+		throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');
131
+	}
132
+
133
+	/**
134
+	 * @return bool
135
+	 */
136
+	protected function driverClear(): bool
137
+	{
138
+		return @zend_shm_cache_clear();
139
+	}
140 140
 }
Please login to merge, or discard this patch.