@@ -49,12 +49,14 @@ |
||
49 | 49 | if ($item->get() != $poolItemData) { |
50 | 50 | $poolsToResync[] = $driverPool; |
51 | 51 | } |
52 | - } else { |
|
52 | + } |
|
53 | + else { |
|
53 | 54 | if ($item->get() !== $poolItemData) { |
54 | 55 | $poolsToResync[] = $driverPool; |
55 | 56 | } |
56 | 57 | } |
57 | - } else { |
|
58 | + } |
|
59 | + else { |
|
58 | 60 | $poolsToResync[] = $driverPool; |
59 | 61 | } |
60 | 62 | } |
@@ -58,8 +58,7 @@ |
||
58 | 58 | * @param callable $operation |
59 | 59 | * @return mixed |
60 | 60 | */ |
61 | - protected function makeOperation(callable $operation) |
|
62 | - { |
|
61 | + protected function makeOperation(callable $operation) { |
|
63 | 62 | return $operation($this->getMasterPool()); |
64 | 63 | } |
65 | 64 | } |
@@ -43,7 +43,8 @@ discard block |
||
43 | 43 | $item = $poolItem; |
44 | 44 | break; |
45 | 45 | } |
46 | - } catch (PhpfastcacheExceptionInterface) { |
|
46 | + } |
|
47 | + catch (PhpfastcacheExceptionInterface) { |
|
47 | 48 | $eCount++; |
48 | 49 | } |
49 | 50 | } |
@@ -73,7 +74,8 @@ discard block |
||
73 | 74 | if ($poolItem->isHit()) { |
74 | 75 | return true; |
75 | 76 | } |
76 | - } catch (PhpfastcacheExceptionInterface) { |
|
77 | + } |
|
78 | + catch (PhpfastcacheExceptionInterface) { |
|
77 | 79 | $eCount++; |
78 | 80 | } |
79 | 81 | } |
@@ -99,7 +101,8 @@ discard block |
||
99 | 101 | if ($result = $driverPool->clear()) { |
100 | 102 | $hasClearedOnce = $result; |
101 | 103 | } |
102 | - } catch (PhpfastcacheExceptionInterface) { |
|
104 | + } |
|
105 | + catch (PhpfastcacheExceptionInterface) { |
|
103 | 106 | $eCount++; |
104 | 107 | } |
105 | 108 | } |
@@ -127,7 +130,8 @@ discard block |
||
127 | 130 | if ($result = $driverPool->deleteItem($key)) { |
128 | 131 | $hasDeletedOnce = $result; |
129 | 132 | } |
130 | - } catch (PhpfastcacheExceptionInterface) { |
|
133 | + } |
|
134 | + catch (PhpfastcacheExceptionInterface) { |
|
131 | 135 | $eCount++; |
132 | 136 | } |
133 | 137 | } |
@@ -157,7 +161,8 @@ discard block |
||
157 | 161 | if ($result = $driverPool->save($poolItem)) { |
158 | 162 | $hasSavedOnce = $result; |
159 | 163 | } |
160 | - } catch (PhpfastcacheExceptionInterface) { |
|
164 | + } |
|
165 | + catch (PhpfastcacheExceptionInterface) { |
|
161 | 166 | $eCount++; |
162 | 167 | } |
163 | 168 | } |
@@ -183,7 +188,8 @@ discard block |
||
183 | 188 | if ($result = $driverPool->commit()) { |
184 | 189 | $hasCommitOnce = $result; |
185 | 190 | } |
186 | - } catch (PhpfastcacheExceptionInterface) { |
|
191 | + } |
|
192 | + catch (PhpfastcacheExceptionInterface) { |
|
187 | 193 | $eCount++; |
188 | 194 | } |
189 | 195 | } |
@@ -46,8 +46,7 @@ discard block |
||
46 | 46 | * @throws PhpfastcacheDriverException |
47 | 47 | * @throws PhpfastcacheIOException |
48 | 48 | */ |
49 | - public function __construct(string $clusterName, EventManagerInterface $em, AggregatablePoolInterface ...$driverPools) |
|
50 | - { |
|
49 | + public function __construct(string $clusterName, EventManagerInterface $em, AggregatablePoolInterface ...$driverPools) { |
|
51 | 50 | if (\count($driverPools) !== 2) { |
52 | 51 | throw new PhpfastcacheInvalidArgumentException('A "master/slave" cluster requires exactly two pools to be working.'); |
53 | 52 | } |
@@ -73,11 +72,11 @@ discard block |
||
73 | 72 | * @return mixed |
74 | 73 | * @throws PhpfastcacheReplicationException |
75 | 74 | */ |
76 | - protected function makeOperation(callable $operation) |
|
77 | - { |
|
75 | + protected function makeOperation(callable $operation) { |
|
78 | 76 | try { |
79 | 77 | return $operation($this->getMasterPool()); |
80 | - } catch (PhpfastcacheExceptionInterface $e) { |
|
78 | + } |
|
79 | + catch (PhpfastcacheExceptionInterface $e) { |
|
81 | 80 | try { |
82 | 81 | $this->eventManager->dispatch( |
83 | 82 | Event::CACHE_REPLICATION_SLAVE_FALLBACK, |
@@ -85,7 +84,8 @@ discard block |
||
85 | 84 | \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function'] |
86 | 85 | ); |
87 | 86 | return $operation($this->getSlavePool()); |
88 | - } catch (PhpfastcacheExceptionInterface $e) { |
|
87 | + } |
|
88 | + catch (PhpfastcacheExceptionInterface $e) { |
|
89 | 89 | throw new PhpfastcacheReplicationException('Master and Slave thrown an exception !'); |
90 | 90 | } |
91 | 91 | } |
@@ -69,8 +69,7 @@ |
||
69 | 69 | * @throws PhpfastcacheDriverException |
70 | 70 | * @throws PhpfastcacheIOException |
71 | 71 | */ |
72 | - public function __construct(string $clusterName, EventManagerInterface $em, AggregatablePoolInterface ...$driverPools) |
|
73 | - { |
|
72 | + public function __construct(string $clusterName, EventManagerInterface $em, AggregatablePoolInterface ...$driverPools) { |
|
74 | 73 | if (count($driverPools) < 2) { |
75 | 74 | throw new PhpfastcacheInvalidArgumentException('A cluster requires at least two pools to be working.'); |
76 | 75 | } |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | * @param array<AggregatablePoolInterface> $driverPools |
46 | 46 | * @throws PhpfastcacheLogicException |
47 | 47 | */ |
48 | - public function __construct(string $clusterAggregatorName = '', AggregatablePoolInterface ...$driverPools) |
|
49 | - { |
|
48 | + public function __construct(string $clusterAggregatorName = '', AggregatablePoolInterface ...$driverPools) { |
|
50 | 49 | $clusterAggregatorName = trim($clusterAggregatorName); |
51 | 50 | if (empty($clusterAggregatorName)) { |
52 | 51 | try { |
53 | 52 | $clusterAggregatorName = 'cluster_' . \bin2hex(\random_bytes(15)); |
54 | - } catch (Exception) { |
|
53 | + } |
|
54 | + catch (Exception) { |
|
55 | 55 | $clusterAggregatorName = 'cluster_' . \str_shuffle(\spl_object_hash(new stdClass())); |
56 | 56 | } |
57 | 57 | } |
@@ -81,7 +81,8 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | $this->driverPools[$splHash] = $driverPool; |
84 | - } else { |
|
84 | + } |
|
85 | + else { |
|
85 | 86 | throw new PhpfastcacheLogicException('This pool has been already aggregated !'); |
86 | 87 | } |
87 | 88 | } |
@@ -129,7 +130,8 @@ discard block |
||
129 | 130 | $splHash = \spl_object_hash($driverPool); |
130 | 131 | if (isset($this->driverPools[$splHash])) { |
131 | 132 | unset($this->driverPools[$splHash]); |
132 | - } else { |
|
133 | + } |
|
134 | + else { |
|
133 | 135 | throw new PhpfastcacheLogicException('This pool was not aggregated !'); |
134 | 136 | } |
135 | 137 | } |
@@ -153,7 +155,8 @@ discard block |
||
153 | 155 | |
154 | 156 | $this->cluster->getEventManager()->dispatch(Event::CACHE_CLUSTER_BUILT, $this, $this->cluster); |
155 | 157 | } |
156 | - } else { |
|
158 | + } |
|
159 | + else { |
|
157 | 160 | throw new PhpfastcacheInvalidArgumentException('Unknown cluster strategy'); |
158 | 161 | } |
159 | 162 |
@@ -20,8 +20,7 @@ |
||
20 | 20 | |
21 | 21 | class EventReferenceParameter |
22 | 22 | { |
23 | - public function __construct(protected mixed &$parameter, protected bool $allowTypeChange = false) |
|
24 | - { |
|
23 | + public function __construct(protected mixed &$parameter, protected bool $allowTypeChange = false) { |
|
25 | 24 | } |
26 | 25 | |
27 | 26 | public function getParameterValue(): mixed |
@@ -46,8 +46,7 @@ |
||
46 | 46 | * @throws PhpfastcacheDriverNotFoundException |
47 | 47 | * @throws PhpfastcacheLogicException |
48 | 48 | */ |
49 | - public function __construct(string $driver, ?ConfigurationOptionInterface $config = null) |
|
50 | - { |
|
49 | + public function __construct(string $driver, ?ConfigurationOptionInterface $config = null) { |
|
51 | 50 | $this->instance = CacheManager::getInstance($driver, $config); |
52 | 51 | } |
53 | 52 |
@@ -104,7 +104,8 @@ discard block |
||
104 | 104 | { |
105 | 105 | if (\class_exists($driver) && \str_starts_with($driver, 'Phpfastcache')) { |
106 | 106 | $driverClass = $driver; |
107 | - } else { |
|
107 | + } |
|
108 | + else { |
|
108 | 109 | $driver = self::normalizeDriverName($driver); |
109 | 110 | $driverClass = self::getDriverClass($driver); |
110 | 111 | } |
@@ -121,11 +122,13 @@ discard block |
||
121 | 122 | $instanceId, |
122 | 123 | EventManager::getInstance() |
123 | 124 | ); |
124 | - } else { |
|
125 | + } |
|
126 | + else { |
|
125 | 127 | try { |
126 | 128 | self::$driverExtensions[$driver] = ExtensionManager::getExtension($driver); |
127 | 129 | return CacheManager::getInstance($driver, $config, $instanceId); |
128 | - } catch (PhpfastcacheExtensionNotFoundException) { |
|
130 | + } |
|
131 | + catch (PhpfastcacheExtensionNotFoundException) { |
|
129 | 132 | if (in_array($driver, ExtensionManager::KNOWN_EXTENSION_NAMES, true)) { |
130 | 133 | throw new PhpfastcacheExtensionNotInstalledException(sprintf( |
131 | 134 | 'You requested a driver which is now an extension. Run the following command to solve this issue: %s', |
@@ -197,11 +200,14 @@ discard block |
||
197 | 200 | { |
198 | 201 | if (!empty(self::$driverExtensions[$driverName])) { |
199 | 202 | $driverClass = self::$driverExtensions[$driverName]; |
200 | - } elseif (!empty(self::$driverCustoms[$driverName])) { |
|
203 | + } |
|
204 | + elseif (!empty(self::$driverCustoms[$driverName])) { |
|
201 | 205 | $driverClass = self::$driverCustoms[$driverName]; |
202 | - } elseif (!empty(self::$driverOverrides[$driverName])) { |
|
206 | + } |
|
207 | + elseif (!empty(self::$driverOverrides[$driverName])) { |
|
203 | 208 | $driverClass = self::$driverOverrides[$driverName]; |
204 | - } else { |
|
209 | + } |
|
210 | + else { |
|
205 | 211 | $driverClass = self::getNamespacePath() . $driverName . '\Driver'; |
206 | 212 | } |
207 | 213 |