Passed
Push — master ( 16ffdb...34016b )
by Ron
02:28
created
src/Builder/Internal/ConditionBuilder.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
 	 * @return string
15 15
 	 */
16 16
 	public static function build(Database $db, string $query, array $conditions, string $token): string {
17
-		if(!count($conditions)) {
17
+		if (!count($conditions)) {
18 18
 			return $query;
19 19
 		}
20 20
 		$query .= "{$token}\n";
21 21
 		$arr = [];
22
-		foreach($conditions as [$expression, $arguments]) {
23
-			if(is_array($expression)) {
24
-				foreach($expression as $key => $value) {
22
+		foreach ($conditions as [$expression, $arguments]) {
23
+			if (is_array($expression)) {
24
+				foreach ($expression as $key => $value) {
25 25
 					$key = self::formatKey($key);
26
-					if($value === null) {
26
+					if ($value === null) {
27 27
 						$arr = self::buildCondition($arr, "ISNULL({$key})", [$value], $db);
28 28
 					} else {
29 29
 						$arr = self::buildCondition($arr, "{$key}=?", [$value], $db);
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 	 * @return string
56 56
 	 */
57 57
 	private static function formatKey(string $key): string {
58
-		if(strpos($key, '`') !== false || strpos($key, '(') !== false) {
58
+		if (strpos($key, '`') !== false || strpos($key, '(') !== false) {
59 59
 			return $key;
60 60
 		}
61 61
 		$keyParts = explode('.', $key);
62
-		$fn = static function (string $part) {
62
+		$fn = static function(string $part) {
63 63
 			return "`{$part}`";
64 64
 		};
65 65
 		$enclosedKeyParts = array_map($fn, $keyParts);
Please login to merge, or discard this patch.
src/Databases/MySQL/MySQLRunnableSelect.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @inheritDoc
87 87
 	 */
88 88
 	public function fetchRowsLazy($callback = null) {
89
-		$callback = $callback ?? (static function ($row) { return $row; });
89
+		$callback = $callback ?? (static function($row) { return $row; });
90 90
 		yield from $this->fetchLazy($callback, PDO::FETCH_ASSOC);
91 91
 	}
92 92
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 	 * @inheritDoc
95 95
 	 */
96 96
 	public function fetchRow($callback = null): array {
97
-		$callback = $callback ?? (static function ($row) { return $row; });
98
-		return $this->fetch($callback, PDO::FETCH_ASSOC, null, static function ($row) {
97
+		$callback = $callback ?? (static function($row) { return $row; });
98
+		return $this->fetch($callback, PDO::FETCH_ASSOC, null, static function($row) {
99 99
 			return ['valid' => is_array($row), 'default' => []];
100 100
 		});
101 101
 	}
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
 	 * @inheritDoc
105 105
 	 */
106 106
 	public function fetchObjects(string $className = 'stdClass', $callback = null): array {
107
-		return $this->createTempStatement(function (QueryStatement $statement) use ($className, $callback) {
107
+		return $this->createTempStatement(function(QueryStatement $statement) use ($className, $callback) {
108 108
 			$data = $statement->fetchAll(PDO::FETCH_CLASS, $className);
109
-			if($this->preserveTypes) {
109
+			if ($this->preserveTypes) {
110 110
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
111
-				$data = array_map(static function ($row) use ($columnDefinitions) { return FieldValueConverter::convertValues($row, $columnDefinitions); }, $data);
111
+				$data = array_map(static function($row) use ($columnDefinitions) { return FieldValueConverter::convertValues($row, $columnDefinitions); }, $data);
112 112
 			}
113
-			if($callback !== null) {
114
-				return call_user_func(static function ($resultData = []) use ($data, $callback) {
115
-					foreach($data as $row) {
113
+			if ($callback !== null) {
114
+				return call_user_func(static function($resultData = []) use ($data, $callback) {
115
+					foreach ($data as $row) {
116 116
 						$result = $callback($row);
117
-						if($result !== null && !($result instanceof DBIgnoreRow)) {
117
+						if ($result !== null && !($result instanceof DBIgnoreRow)) {
118 118
 							$resultData[] = $result;
119 119
 						} else {
120 120
 							$resultData[] = $row;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @inheritDoc
132 132
 	 */
133 133
 	public function fetchObjectsLazy($className = null, $callback = null) {
134
-		$callback = $callback ?? (static function ($row) { return $row; });
134
+		$callback = $callback ?? (static function($row) { return $row; });
135 135
 		yield from $this->fetchLazy($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName);
136 136
 	}
137 137
 
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @inheritDoc
140 140
 	 */
141 141
 	public function fetchObject($className = null, $callback = null) {
142
-		$callback = $callback ?? (static function ($row) { return $row; });
143
-		return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, static function ($row) {
142
+		$callback = $callback ?? (static function($row) { return $row; });
143
+		return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, static function($row) {
144 144
 			return ['valid' => is_object($row), 'default' => null];
145 145
 		});
146 146
 	}
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
 	 * @inheritDoc
150 150
 	 */
151 151
 	public function fetchKeyValue($treatValueAsArray = false): array {
152
-		return $this->createTempStatement(static function (QueryStatement $statement) use ($treatValueAsArray) {
153
-			if($treatValueAsArray) {
152
+		return $this->createTempStatement(static function(QueryStatement $statement) use ($treatValueAsArray) {
153
+			if ($treatValueAsArray) {
154 154
 				$rows = $statement->fetchAll(PDO::FETCH_ASSOC);
155 155
 				$result = [];
156
-				foreach($rows as $row) {
156
+				foreach ($rows as $row) {
157 157
 					[$key] = array_values($row);
158 158
 					$result[$key] = $row;
159 159
 				}
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
 	public function fetchGroups(array $fields): array {
170 170
 		$rows = $this->fetchRows();
171 171
 		$result = [];
172
-		foreach($rows as $row) {
172
+		foreach ($rows as $row) {
173 173
 			/** @var array<string, mixed> $tmp */
174 174
 			$tmp = &$result;
175
-			foreach($fields as $field) {
175
+			foreach ($fields as $field) {
176 176
 				$value = (string) $row[$field];
177
-				if(!array_key_exists($value, $tmp)) {
177
+				if (!array_key_exists($value, $tmp)) {
178 178
 					$tmp[$value] = [];
179 179
 				}
180 180
 				$tmp = &$tmp[$value];
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @inheritDoc
189 189
 	 */
190 190
 	public function fetchArray(?callable $fn = null): array {
191
-		return $this->createTempStatement(static function (QueryStatement $stmt) use ($fn) {
192
-			if($fn !== null) {
191
+		return $this->createTempStatement(static function(QueryStatement $stmt) use ($fn) {
192
+			if ($fn !== null) {
193 193
 				return $stmt->fetchAll(PDO::FETCH_FUNC, $fn);
194 194
 			}
195 195
 			return $stmt->fetchAll(PDO::FETCH_COLUMN);
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 	 * @inheritDoc
201 201
 	 */
202 202
 	public function fetchValue($default = null, ?callable $fn = null) {
203
-		return $this->createTempStatement(static function (QueryStatement $stmt) use ($default, $fn) {
203
+		return $this->createTempStatement(static function(QueryStatement $stmt) use ($default, $fn) {
204 204
 			$result = $stmt->fetchAll(PDO::FETCH_COLUMN);
205
-			if($result !== false && array_key_exists(0, $result)) {
205
+			if ($result !== false && array_key_exists(0, $result)) {
206 206
 				return $fn !== null ? $fn($result[0]) : $result[0];
207 207
 			}
208 208
 			return $default;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		$query = $this->__toString();
238 238
 		$statement = $db->prepare($query);
239 239
 		$statement->execute($this->values);
240
-		if($this->getCalcFoundRows()) {
240
+		if ($this->getCalcFoundRows()) {
241 241
 			$this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn();
242 242
 		}
243 243
 		return $statement;
@@ -259,21 +259,21 @@  discard block
 block discarded – undo
259 259
 	 * @return ($callback is null ? array<int, ($mode is PDO::FETCH_NUM ? array<int, null|scalar> : array<string, null|scalar>)> : array<int, TFnReturnType|TFnParamType>)
260 260
 	 */
261 261
 	private function fetchAll($callback = null, int $mode = 0, $arg0 = null) {
262
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) {
262
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) {
263 263
 			$statement->setFetchMode($mode, $arg0);
264 264
 			$data = $statement->fetchAll();
265
-			if($this->preserveTypes) {
265
+			if ($this->preserveTypes) {
266 266
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
267
-				$data = array_map(static function ($row) use ($columnDefinitions) { return FieldValueConverter::convertValues($row, $columnDefinitions); }, $data);
267
+				$data = array_map(static function($row) use ($columnDefinitions) { return FieldValueConverter::convertValues($row, $columnDefinitions); }, $data);
268 268
 			}
269
-			if($callback !== null) {
270
-				return call_user_func(static function ($resultData = []) use ($data, $callback) {
271
-					foreach($data as $row) {
269
+			if ($callback !== null) {
270
+				return call_user_func(static function($resultData = []) use ($data, $callback) {
271
+					foreach ($data as $row) {
272 272
 						$result = $callback($row);
273
-						if($result instanceof DBIgnoreRow) {
273
+						if ($result instanceof DBIgnoreRow) {
274 274
 							continue;
275 275
 						}
276
-						if($result !== null) {
276
+						if ($result !== null) {
277 277
 							$resultData[] = $result;
278 278
 						} else {
279 279
 							$resultData[] = $row;
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
 		$statement = $this->createStatement();
299 299
 		$statement->setFetchMode($mode, $arg0);
300 300
 		try {
301
-			while($row = $statement->fetch()) {
301
+			while ($row = $statement->fetch()) {
302 302
 				/** @var T $row */
303 303
 //				if($this->preserveTypes) {
304 304
 //					$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
305 305
 //					$row = FieldValueConverter::convertValues($row, $columnDefinitions);
306 306
 //				}
307 307
 				$result = $callback($row);
308
-				if($result instanceof DBIgnoreRow) {
308
+				if ($result instanceof DBIgnoreRow) {
309 309
 					// Skip row in this case
310 310
 					continue;
311 311
 				}
312
-				if($result !== null) {
312
+				if ($result !== null) {
313 313
 					yield $result;
314 314
 				} else {
315 315
 					yield $row;
@@ -330,20 +330,20 @@  discard block
 block discarded – undo
330 330
 	 * @return T|U|array<string, mixed>
331 331
 	 */
332 332
 	private function fetch($callback, int $mode = PDO::FETCH_ASSOC, $arg0 = null, Closure $resultValidator = null) {
333
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
333
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
334 334
 			$statement->setFetchMode($mode, $arg0);
335 335
 			$row = $statement->fetch();
336 336
 			$result = $resultValidator === null ? ['valid' => true] : $resultValidator($row);
337
-			if(!$result['valid']) {
337
+			if (!$result['valid']) {
338 338
 				return $result['default'];
339 339
 			}
340
-			if($this->preserveTypes) {
340
+			if ($this->preserveTypes) {
341 341
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
342 342
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
343 343
 			}
344
-			if($callback !== null) {
344
+			if ($callback !== null) {
345 345
 				$result = $callback($row);
346
-				if($result !== null) {
346
+				if ($result !== null) {
347 347
 					$row = $result;
348 348
 				}
349 349
 			}
Please login to merge, or discard this patch.
src/Builder/QueryStatement.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function setFetchMode(int $mode = PDO::FETCH_ASSOC, $arg0 = null, ?array $arg1 = null) {
49 49
 		$args = [$mode];
50
-		if($arg0 !== null) {
50
+		if ($arg0 !== null) {
51 51
 			$args[] = $arg0;
52 52
 		}
53
-		if($arg1 !== null) {
53
+		if ($arg1 !== null) {
54 54
 			$args[] = $arg1;
55 55
 		}
56 56
 		$this->statement->setFetchMode(...$args);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		$this->exceptionHandler(function() use ($params) {
67 67
 			$this->queryLoggers->logRegion($this->query, function() use ($params) {
68 68
 				$response = $this->statement->execute($params);
69
-				if(!$response) {
69
+				if (!$response) {
70 70
 					throw new SqlException('Execution returned with "false".');
71 71
 				}
72 72
 			});
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function fetchAll($fetchStyle = PDO::FETCH_ASSOC, $fetchArgument = null, array $ctorArgs = []): array {
84 84
 		$result = $x = $this->exceptionHandler(function() use ($fetchStyle, $fetchArgument, $ctorArgs) {
85
-			if($fetchArgument !== null) {
85
+			if ($fetchArgument !== null) {
86 86
 				return $this->statement->fetchAll($fetchStyle, $fetchArgument, ...$ctorArgs);
87 87
 			}
88 88
 			return $this->statement->fetchAll($fetchStyle);
89 89
 		});
90 90
 		/** @var array<mixed, mixed>|false $x */
91
-		if($x === false) {
91
+		if ($x === false) {
92 92
 			return [];
93 93
 		}
94 94
 		return $result;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	public function getColumnMeta(int $columnNo): ?array {
142 142
 		return $this->exceptionHandler(function() use ($columnNo) {
143 143
 			$columnMeta = $this->statement->getColumnMeta($columnNo);
144
-			if($columnMeta === false) {
144
+			if ($columnMeta === false) {
145 145
 				return null;
146 146
 			}
147 147
 			return $columnMeta;
Please login to merge, or discard this patch.
src/Databases/MySQL.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param array<string, mixed> $options
52 52
 	 */
53 53
 	public function __construct(PDO $pdo, array $options = []) {
54
-		if($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
54
+		if ($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
55 55
 			$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
56 56
 		}
57 57
 		$this->pdo = $pdo;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		];
67 67
 		$this->options = array_merge($defaultOptions, $options);
68 68
 		$this->options['timezone'] = $this->options['timezone'] ?? date_default_timezone_get();
69
-		if(!($this->options['timezone'] instanceof DateTimeZone)) {
69
+		if (!($this->options['timezone'] instanceof DateTimeZone)) {
70 70
 			$this->options['timezone'] = new DateTimeZone((string) $this->options['timezone']);
71 71
 		}
72 72
 		$this->quoter = new MySQLQuoter($pdo, $this->options['timezone']);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @return VirtualTables
91 91
 	 */
92 92
 	public function getVirtualTables(): VirtualTables {
93
-		if($this->virtualTables === null) {
93
+		if ($this->virtualTables === null) {
94 94
 			$this->virtualTables = new VirtualTables();
95 95
 		}
96 96
 		return $this->virtualTables;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		string $query
106 106
 	) {
107 107
 		return $this->getQueryLoggers()->logRegion($query, function() use ($query) {
108
-			return $this->buildQueryStatement($query, function ($query) {
108
+			return $this->buildQueryStatement($query, function($query) {
109 109
 				return $this->pdo->query($query);
110 110
 			});
111 111
 		});
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		#[Language('MySQL')]
120 120
 		string $query
121 121
 	) {
122
-		return $this->buildQueryStatement((string) $query, function ($query) {
122
+		return $this->buildQueryStatement((string) $query, function($query) {
123 123
 			return $this->pdo->prepare($query);
124 124
 		});
125 125
 	}
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 		array $params = []
136 136
 	): int {
137 137
 		return $this->getQueryLoggers()->logRegion($query, function() use ($query, $params) {
138
-			return $this->exceptionHandler(function () use ($query, $params) {
138
+			return $this->exceptionHandler(function() use ($query, $params) {
139 139
 				$stmt = $this->pdo->prepare($query);
140 140
 				$timer = microtime(true);
141 141
 				$stmt->execute($params);
142
-				$this->queryLoggers->log($query, microtime(true) - $timer);
142
+				$this->queryLoggers->log($query, microtime(true)-$timer);
143 143
 				$result = $stmt->rowCount();
144 144
 				$stmt->closeCursor();
145 145
 				return $result;
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	public function getTableFields(string $table): array {
163 163
 		$fqTable = $this->select()->aliasReplacer()->replace($table);
164
-		if(array_key_exists($fqTable, $this->tableFields)) {
164
+		if (array_key_exists($fqTable, $this->tableFields)) {
165 165
 			return $this->tableFields[$fqTable];
166 166
 		}
167 167
 		$query = "DESCRIBE {$fqTable}";
168 168
 		return $this->getQueryLoggers()->logRegion($query, function() use ($query, $fqTable) {
169
-			return $this->exceptionHandler(function () use ($query, $fqTable) {
169
+			return $this->exceptionHandler(function() use ($query, $fqTable) {
170 170
 				$stmt = $this->pdo->query($query);
171 171
 				try {
172
-					if($stmt === false) {
172
+					if ($stmt === false) {
173 173
 						throw new RuntimeException('Invalid return type');
174 174
 					}
175 175
 					$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
176
-					$this->tableFields[$fqTable] = array_map(static function ($row) { return $row['Field']; }, $rows ?: []);
176
+					$this->tableFields[$fqTable] = array_map(static function($row) { return $row['Field']; }, $rows ?: []);
177 177
 					return $this->tableFields[$fqTable];
178 178
 				} finally {
179 179
 					try {
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		$select = array_key_exists('select-factory', $this->options)
218 218
 			? call_user_func($this->options['select-factory'], $this, $this->options['select-options'])
219 219
 			: new MySQL\MySQLRunnableSelect($this, $this->options['select-options']);
220
-		if($fields !== null) {
220
+		if ($fields !== null) {
221 221
 			$select->fields($fields);
222 222
 		}
223 223
 		return $select;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		$insert = array_key_exists('insert-factory', $this->options)
232 232
 			? call_user_func($this->options['insert-factory'], $this, $this->options['insert-options'])
233 233
 			: new Builder\RunnableInsert($this, $this->options['insert-options']);
234
-		if($fields !== null) {
234
+		if ($fields !== null) {
235 235
 			$insert->addAll($fields);
236 236
 		}
237 237
 		return $insert;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		$update = array_key_exists('update-factory', $this->options)
246 246
 			? call_user_func($this->options['update-factory'], $this, $this->options['update-options'])
247 247
 			: new Builder\RunnableUpdate($this, $this->options['update-options']);
248
-		if($fields !== null) {
248
+		if ($fields !== null) {
249 249
 			$update->setAll($fields);
250 250
 		}
251 251
 		return $update;
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 	 * @return $this
265 265
 	 */
266 266
 	public function transactionStart() {
267
-		if($this->transactionLevel === 0) {
268
-			if($this->pdo->inTransaction()) {
267
+		if ($this->transactionLevel === 0) {
268
+			if ($this->pdo->inTransaction()) {
269 269
 				$this->outerTransaction = true;
270 270
 			} else {
271 271
 				$this->pdo->beginTransaction();
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @return $this
280 280
 	 */
281 281
 	public function transactionCommit() {
282
-		return $this->transactionEnd(function () {
282
+		return $this->transactionEnd(function() {
283 283
 			$this->pdo->commit();
284 284
 		});
285 285
 	}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 * @return $this
289 289
 	 */
290 290
 	public function transactionRollback() {
291
-		return $this->transactionEnd(function () {
291
+		return $this->transactionEnd(function() {
292 292
 			$this->pdo->rollBack();
293 293
 		});
294 294
 	}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return T
300 300
 	 */
301 301
 	public function dryRun(callable $callback) {
302
-		if(!$this->pdo->inTransaction()) {
302
+		if (!$this->pdo->inTransaction()) {
303 303
 			$this->transactionStart();
304 304
 			try {
305 305
 				return $callback($this);
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @throws Throwable
325 325
 	 */
326 326
 	public function transaction(callable $callback) {
327
-		if(!$this->pdo->inTransaction()) {
327
+		if (!$this->pdo->inTransaction()) {
328 328
 			$this->transactionStart();
329 329
 			try {
330 330
 				$result = $callback($this);
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 				return $result;
333 333
 			} catch (Throwable $e) {
334 334
 				// @phpstan-ignore-next-line; If condition is always false as it is not.
335
-				if($this->pdo->inTransaction()) {
335
+				if ($this->pdo->inTransaction()) {
336 336
 					$this->transactionRollback();
337 337
 				}
338 338
 				throw $e;
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 	 */
357 357
 	private function transactionEnd($fn): self {
358 358
 		$this->transactionLevel--;
359
-		if($this->transactionLevel < 0) {
359
+		if ($this->transactionLevel < 0) {
360 360
 			throw new RuntimeException("Transaction-Nesting-Problem: Trying to invoke commit on a already closed transaction");
361 361
 		}
362
-		if($this->transactionLevel < 1) {
363
-			if($this->outerTransaction) {
362
+		if ($this->transactionLevel < 1) {
363
+			if ($this->outerTransaction) {
364 364
 				$this->outerTransaction = false;
365 365
 			} else {
366 366
 				$fn();
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 */
378 378
 	private function buildQueryStatement(string $query, callable $fn): QueryStatement {
379 379
 		$stmt = $fn($query);
380
-		if(!$stmt) {
380
+		if (!$stmt) {
381 381
 			throw new RuntimeException("Could not execute statement:\n{$query}");
382 382
 		}
383 383
 		return new QueryStatement($stmt, $query, $this->exceptionInterpreter, $this->queryLoggers);
Please login to merge, or discard this patch.
src/Builder/Traits/TableNameBuilder.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,34 +14,34 @@
 block discarded – undo
14 14
 	 * @return string
15 15
 	 */
16 16
 	protected function buildTableName(?string $alias, $name): string {
17
-		if(is_object($name) && !($name instanceof VirtualTable) && method_exists($name, '__toString')) {
17
+		if (is_object($name) && !($name instanceof VirtualTable) && method_exists($name, '__toString')) {
18 18
 			$name = (string) $name;
19 19
 			$lines = explode("\n", $name);
20
-			$lines = array_map(static function (string $line) { return "\t{$line}"; }, $lines);
20
+			$lines = array_map(static function(string $line) { return "\t{$line}"; }, $lines);
21 21
 			$name = implode("\n", $lines);
22
-			$name = '(' . trim(rtrim(trim($name), ';')) . ')';
22
+			$name = '('.trim(rtrim(trim($name), ';')).')';
23 23
 		}
24
-		if(is_array($name)) {
24
+		if (is_array($name)) {
25 25
 			$parts = [];
26
-			foreach($name as $index => $bucket) {
27
-				if(is_scalar($bucket) && ctype_digit((string) $index)) {
26
+			foreach ($name as $index => $bucket) {
27
+				if (is_scalar($bucket) && ctype_digit((string) $index)) {
28 28
 					$parts[] = "SELECT {$this->db()->quote($bucket)} AS {$this->db()->quoteField('value')}";
29 29
 				} else {
30 30
 					$values = [];
31
-					foreach($bucket as $field => $value) {
31
+					foreach ($bucket as $field => $value) {
32 32
 						$values[] = sprintf('%s AS %s', $this->db()->quote($value), $this->db()->quoteField($field));
33 33
 					}
34 34
 					$parts[] = sprintf("SELECT %s", implode(', ', $values));
35 35
 				}
36 36
 			}
37
-			$name = '(' . implode("\n\tUNION ALL\n\t", $parts) . ')';
37
+			$name = '('.implode("\n\tUNION ALL\n\t", $parts).')';
38 38
 		}
39
-		if((is_string($name) || $name instanceof VirtualTable) && $this->db()->getVirtualTables()->has($name)) {
39
+		if ((is_string($name) || $name instanceof VirtualTable) && $this->db()->getVirtualTables()->has($name)) {
40 40
 			$select = (string) $this->db()->getVirtualTables()->get($name);
41 41
 			$name = sprintf('(%s)', implode("\n\t", explode("\n", trim($select))));
42 42
 		}
43 43
 		$name = $this->aliasReplacer()->replace((string) $name);
44
-		if($alias !== null) {
44
+		if ($alias !== null) {
45 45
 			return sprintf("%s %s", $name, $alias);
46 46
 		}
47 47
 		return $name;
Please login to merge, or discard this patch.