Passed
Push — master ( 0570dc...14956b )
by Ron
02:29
created
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.
rector.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
8 8
 use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
9 9
 use Rector\Set\ValueObject\LevelSetList;
10 10
 
11
-return static function (RectorConfig $rectorConfig): void {
11
+return static function(RectorConfig $rectorConfig): void {
12 12
     $rectorConfig->paths([
13
-        __DIR__ . '/src',
14
-        __DIR__ . '/tests',
13
+        __DIR__.'/src',
14
+        __DIR__.'/tests',
15 15
     ]);
16 16
 
17 17
     // register a single rule
Please login to merge, or discard this patch.
src/Builder/Internal/ConditionBuilder.php 1 patch
Spacing   +6 added lines, -6 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,7 +55,7 @@  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);
Please login to merge, or discard this patch.
src/Builder/Traits/TableNameBuilder.php 1 patch
Spacing   +9 added lines, -9 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 20
 			$lines = array_map(static fn(string $line) => "\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.
src/Builder/Delete.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
 	 * @param null|string|Select $table
29 29
 	 * @return $this
30 30
 	 */
31
-	public function from(string $alias, null|string|Select $table = null) {
32
-		if($table !== null) {
31
+	public function from(string $alias, null | string | Select $table = null) {
32
+		if ($table !== null) {
33 33
 			$this->aliases[] = $alias;
34 34
 		}
35
-		if($table === null) {
35
+		if ($table === null) {
36 36
 			[$alias, $table] = [$table, $alias];
37 37
 		}
38 38
 		$this->addTable($alias, $table);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	public function __toString(): string {
52 52
 		$query = 'DELETE ';
53 53
 		$query .= implode(', ', $this->aliases);
54
-		$query = trim($query) . " FROM\n";
54
+		$query = trim($query)." FROM\n";
55 55
 		$query = $this->buildTables($query);
56 56
 		$query = $this->buildJoins($query);
57 57
 		$query = $this->buildWhereConditions($query);
Please login to merge, or discard this patch.
src/Builder/Expr/DBExprFilter.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 		$this->keyPath = $this->buildKey($keyPath);
31 31
 		$this->value = RecursiveStructureAccess::recursiveGet($data, $this->keyPath, null);
32 32
 		$this->hasValue = is_scalar($this->value) ? trim((string) $this->value) !== '' : !empty($this->value);
33
-		if($validator === null) {
33
+		if ($validator === null) {
34 34
 			$validator = static fn() => true;
35 35
 		}
36 36
 		$this->validator = $validator;
37
-		if($validationResultHandler === null) {
38
-			$validationResultHandler = static function () {};
37
+		if ($validationResultHandler === null) {
38
+			$validationResultHandler = static function() {};
39 39
 		}
40 40
 		$this->validationResultHandler = $validationResultHandler;
41 41
 	}
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	 * @return bool
52 52
 	 */
53 53
 	public function isValid(): bool {
54
-		if(!$this->hasValue) {
54
+		if (!$this->hasValue) {
55 55
 			return false;
56 56
 		}
57
-		if($this->validator !== null) {
57
+		if ($this->validator !== null) {
58 58
 			$result = call_user_func($this->validator, $this->value);
59 59
 			call_user_func($this->validationResultHandler, $result, [
60 60
 				'value' => $this->value,
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
 	 * @return string[]
78 78
 	 */
79 79
 	private function buildKey($keyPath): array {
80
-		if(is_string($keyPath)) {
80
+		if (is_string($keyPath)) {
81 81
 			$keyPath = explode('.', $keyPath);
82 82
 		}
83
-		if(!is_array($keyPath)) {
83
+		if (!is_array($keyPath)) {
84 84
 			throw new RuntimeException('Invalid key');
85 85
 		}
86 86
 		return $keyPath;
Please login to merge, or discard this patch.
src/Databases/MySQL/MySQLRunnableSelect.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
 	 * @inheritDoc
102 102
 	 */
103 103
 	public function fetchObjects(string $className = 'stdClass', $callback = null): array {
104
-		return $this->createTempStatement(function (QueryStatement $statement) use ($className, $callback) {
104
+		return $this->createTempStatement(function(QueryStatement $statement) use ($className, $callback) {
105 105
 			$data = $statement->fetchAll(PDO::FETCH_CLASS, $className);
106
-			if($this->preserveTypes) {
106
+			if ($this->preserveTypes) {
107 107
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
108 108
 				$data = array_map(static fn($row) => FieldValueConverter::convertValues($row, $columnDefinitions), $data);
109 109
 			}
110
-			if($callback !== null) {
111
-				return call_user_func(static function ($resultData = []) use ($data, $callback) {
112
-					foreach($data as $row) {
110
+			if ($callback !== null) {
111
+				return call_user_func(static function($resultData = []) use ($data, $callback) {
112
+					foreach ($data as $row) {
113 113
 						$result = $callback($row);
114
-						if($result !== null && !($result instanceof DBIgnoreRow)) {
114
+						if ($result !== null && !($result instanceof DBIgnoreRow)) {
115 115
 							$resultData[] = $result;
116 116
 						} else {
117 117
 							$resultData[] = $row;
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	 * @inheritDoc
148 148
 	 */
149 149
 	public function fetchKeyValue($treatValueAsArray = false): array {
150
-		return $this->createTempStatement(static function (QueryStatement $statement) use ($treatValueAsArray) {
151
-			if($treatValueAsArray) {
150
+		return $this->createTempStatement(static function(QueryStatement $statement) use ($treatValueAsArray) {
151
+			if ($treatValueAsArray) {
152 152
 				$rows = $statement->fetchAll(PDO::FETCH_ASSOC);
153 153
 				$result = [];
154
-				foreach($rows as $row) {
154
+				foreach ($rows as $row) {
155 155
 					[$key] = array_values($row);
156 156
 					$result[$key] = $row;
157 157
 				}
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
 	public function fetchGroups(array $fields): array {
168 168
 		$rows = $this->fetchRows();
169 169
 		$result = [];
170
-		foreach($rows as $row) {
170
+		foreach ($rows as $row) {
171 171
 			/** @var array<string, mixed> $tmp */
172 172
 			$tmp = &$result;
173
-			foreach($fields as $field) {
173
+			foreach ($fields as $field) {
174 174
 				$value = (string) $row[$field];
175
-				if(!array_key_exists($value, $tmp)) {
175
+				if (!array_key_exists($value, $tmp)) {
176 176
 					$tmp[$value] = [];
177 177
 				}
178 178
 				$tmp = &$tmp[$value];
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 * @inheritDoc
187 187
 	 */
188 188
 	public function fetchArray(?callable $fn = null): array {
189
-		return $this->createTempStatement(static function (QueryStatement $stmt) use ($fn) {
190
-			if($fn !== null) {
189
+		return $this->createTempStatement(static function(QueryStatement $stmt) use ($fn) {
190
+			if ($fn !== null) {
191 191
 				return $stmt->fetchAll(PDO::FETCH_FUNC, $fn);
192 192
 			}
193 193
 			return $stmt->fetchAll(PDO::FETCH_COLUMN);
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 	 * @inheritDoc
199 199
 	 */
200 200
 	public function fetchValue($default = null, ?callable $fn = null) {
201
-		return $this->createTempStatement(static function (QueryStatement $stmt) use ($default, $fn) {
201
+		return $this->createTempStatement(static function(QueryStatement $stmt) use ($default, $fn) {
202 202
 			$result = $stmt->fetchAll(PDO::FETCH_COLUMN);
203
-			if($result !== false && array_key_exists(0, $result)) {
203
+			if ($result !== false && array_key_exists(0, $result)) {
204 204
 				return $fn !== null ? $fn($result[0]) : $result[0];
205 205
 			}
206 206
 			return $default;
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 		$query = $this->__toString();
236 236
 		$statement = $db->prepare($query);
237 237
 		$statement->execute($this->values);
238
-		if($this->getCalcFoundRows()) {
238
+		if ($this->getCalcFoundRows()) {
239 239
 			$this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn();
240 240
 		}
241 241
 		return $statement;
@@ -256,21 +256,21 @@  discard block
 block discarded – undo
256 256
 	 * @return ($callback is null ? array<int, ($mode is PDO::FETCH_NUM ? array<int, null|scalar> : array<string, null|scalar>)> : array<int, TFnReturnType>)
257 257
 	 */
258 258
 	private function fetchAll($callback = null, int $mode = 0, $arg0 = null) {
259
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) {
259
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) {
260 260
 			$statement->setFetchMode($mode, $arg0);
261 261
 			$data = $statement->fetchAll();
262
-			if($this->preserveTypes) {
262
+			if ($this->preserveTypes) {
263 263
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
264 264
 				$data = array_map(static fn($row) => FieldValueConverter::convertValues($row, $columnDefinitions), $data);
265 265
 			}
266
-			if($callback !== null) {
267
-				return call_user_func(static function ($resultData = []) use ($data, $callback) {
268
-					foreach($data as $row) {
266
+			if ($callback !== null) {
267
+				return call_user_func(static function($resultData = []) use ($data, $callback) {
268
+					foreach ($data as $row) {
269 269
 						$result = $callback($row);
270
-						if($result instanceof DBIgnoreRow) {
270
+						if ($result instanceof DBIgnoreRow) {
271 271
 							continue;
272 272
 						}
273
-						if($result !== null) {
273
+						if ($result !== null) {
274 274
 							$resultData[] = $result;
275 275
 						} else {
276 276
 							$resultData[] = $row;
@@ -294,18 +294,18 @@  discard block
 block discarded – undo
294 294
 		$statement = $this->createStatement();
295 295
 		$statement->setFetchMode($mode, $arg0);
296 296
 		try {
297
-			while($row = $statement->fetch()) {
297
+			while ($row = $statement->fetch()) {
298 298
 				/** @var T $row */
299 299
 //				if($this->preserveTypes) {
300 300
 //					$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
301 301
 //					$row = FieldValueConverter::convertValues($row, $columnDefinitions);
302 302
 //				}
303 303
 				$result = $callback($row);
304
-				if($result instanceof DBIgnoreRow) {
304
+				if ($result instanceof DBIgnoreRow) {
305 305
 					// Skip row in this case
306 306
 					continue;
307 307
 				}
308
-				if($result !== null) {
308
+				if ($result !== null) {
309 309
 					yield $result;
310 310
 				} else {
311 311
 					yield $row;
@@ -326,20 +326,20 @@  discard block
 block discarded – undo
326 326
 	 * @return T|U|array<string, mixed>
327 327
 	 */
328 328
 	private function fetch($callback, int $mode = PDO::FETCH_ASSOC, $arg0 = null, ?Closure $resultValidator = null) {
329
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
329
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
330 330
 			$statement->setFetchMode($mode, $arg0);
331 331
 			$row = $statement->fetch();
332 332
 			$result = $resultValidator === null ? ['valid' => true] : $resultValidator($row);
333
-			if(!$result['valid']) {
333
+			if (!$result['valid']) {
334 334
 				return $result['default'];
335 335
 			}
336
-			if($this->preserveTypes) {
336
+			if ($this->preserveTypes) {
337 337
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
338 338
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
339 339
 			}
340
-			if($callback !== null) {
340
+			if ($callback !== null) {
341 341
 				$result = $callback($row);
342
-				if($result !== null) {
342
+				if ($result !== null) {
343 343
 					$row = $result;
344 344
 				}
345 345
 			}
Please login to merge, or discard this patch.
src/Databases/MySQL/MySQLQuoter.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,31 +19,31 @@  discard block
 block discarded – undo
19 19
 	 * @return string
20 20
 	 */
21 21
 	public function quote($value): string {
22
-		if(is_null($value)) {
22
+		if (is_null($value)) {
23 23
 			return 'NULL';
24 24
 		}
25 25
 
26
-		if(is_bool($value)) {
26
+		if (is_bool($value)) {
27 27
 			return $value ? '1' : '0';
28 28
 		}
29 29
 
30
-		if(is_array($value)) {
30
+		if (is_array($value)) {
31 31
 			return implode(', ', array_map([$this, __FUNCTION__], $value));
32 32
 		}
33 33
 
34
-		if($value instanceof DBExpr) {
34
+		if ($value instanceof DBExpr) {
35 35
 			return $value->getExpression();
36 36
 		}
37 37
 
38
-		if($value instanceof Select) {
38
+		if ($value instanceof Select) {
39 39
 			return sprintf('(%s)', (string) $value);
40 40
 		}
41 41
 
42
-		if(is_int($value) || is_float($value)) {
42
+		if (is_int($value) || is_float($value)) {
43 43
 			return (string) $value;
44 44
 		}
45 45
 
46
-		if($value instanceof DateTimeInterface) {
46
+		if ($value instanceof DateTimeInterface) {
47 47
 			$value = (new DateTimeImmutable($value->format('c')))->setTimezone($this->timeZone)->format('Y-m-d H:i:s');
48 48
 		}
49 49
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function quoteExpression(string $expression, array $arguments = []): string {
59 59
 		$index = -1;
60
-		$func = function () use ($arguments, &$index) {
60
+		$func = function() use ($arguments, &$index) {
61 61
 			$index++;
62
-			if(array_key_exists($index, $arguments)) {
62
+			if (array_key_exists($index, $arguments)) {
63 63
 				$argument = $arguments[$index];
64 64
 				$value = $this->quote($argument);
65
-			} elseif(count($arguments) > 0) {
65
+			} elseif (count($arguments) > 0) {
66 66
 				$args = $arguments;
67 67
 				$value = array_pop($args);
68 68
 				$value = $this->quote($value);
Please login to merge, or discard this patch.
src/Databases/MySQL.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param array<string, mixed> $options
53 53
 	 */
54 54
 	public function __construct(PDO $pdo, array $options = []) {
55
-		if($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
55
+		if ($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
56 56
 			$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
57 57
 		}
58 58
 		$this->pdo = $pdo;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		];
68 68
 		$this->options = array_merge($defaultOptions, $options);
69 69
 		$this->options['timezone'] ??= date_default_timezone_get();
70
-		if(!($this->options['timezone'] instanceof DateTimeZone)) {
70
+		if (!($this->options['timezone'] instanceof DateTimeZone)) {
71 71
 			$this->options['timezone'] = new DateTimeZone((string) $this->options['timezone']);
72 72
 		}
73 73
 		$this->quoter = new MySQLQuoter($pdo, $this->options['timezone']);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @return VirtualTables
92 92
 	 */
93 93
 	public function getVirtualTables(): VirtualTables {
94
-		if($this->virtualTables === null) {
94
+		if ($this->virtualTables === null) {
95 95
 			$this->virtualTables = new VirtualTables();
96 96
 		}
97 97
 		return $this->virtualTables;
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 		array $params = []
137 137
 	): int {
138 138
 		return $this->getQueryLoggers()->logRegion($query, fn() =>
139
-			$this->exceptionHandler(function () use ($query, $params) {
139
+			$this->exceptionHandler(function() use ($query, $params) {
140 140
 				$stmt = $this->pdo->prepare($query);
141 141
 				$timer = microtime(true);
142 142
 				$stmt->execute($params);
143
-				$this->queryLoggers->log($query, microtime(true) - $timer);
143
+				$this->queryLoggers->log($query, microtime(true)-$timer);
144 144
 				$result = $stmt->rowCount();
145 145
 				$stmt->closeCursor();
146 146
 				return $result;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public function getLastInsertId(?string $name = null): ?string {
156 156
 		$result = $this->pdo->lastInsertId();
157
-		if($result === false) {
157
+		if ($result === false) {
158 158
 			return null;
159 159
 		}
160 160
 		return $result;
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function getTableFields(string $table): array {
168 168
 		$fqTable = $this->select()->aliasReplacer()->replace($table);
169
-		if(array_key_exists($fqTable, $this->tableFields)) {
169
+		if (array_key_exists($fqTable, $this->tableFields)) {
170 170
 			return $this->tableFields[$fqTable];
171 171
 		}
172 172
 		$query = "DESCRIBE {$fqTable}";
173 173
 		return $this->getQueryLoggers()->logRegion($query, fn() =>
174
-			$this->exceptionHandler(function () use ($query, $fqTable) {
174
+			$this->exceptionHandler(function() use ($query, $fqTable) {
175 175
 				$stmt = $this->pdo->query($query);
176 176
 				try {
177
-					if($stmt === false) {
177
+					if ($stmt === false) {
178 178
 						throw new RuntimeException('Invalid return type');
179 179
 					}
180 180
 					$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 					return $this->tableFields[$fqTable];
183 183
 				} finally {
184 184
 					try {
185
-						if($stmt instanceof PDOStatement) {
185
+						if ($stmt instanceof PDOStatement) {
186 186
 							$stmt->closeCursor();
187 187
 						}
188 188
 					} catch (Throwable $e) {}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		$select = array_key_exists('select-factory', $this->options)
225 225
 			? call_user_func($this->options['select-factory'], $this, $this->options['select-options'])
226 226
 			: new MySQL\MySQLRunnableSelect($this, $this->options['select-options']);
227
-		if($fields !== null) {
227
+		if ($fields !== null) {
228 228
 			$select->fields($fields);
229 229
 		}
230 230
 		return $select;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		$insert = array_key_exists('insert-factory', $this->options)
239 239
 			? call_user_func($this->options['insert-factory'], $this, $this->options['insert-options'])
240 240
 			: new Builder\RunnableInsert($this, $this->options['insert-options']);
241
-		if($fields !== null) {
241
+		if ($fields !== null) {
242 242
 			$insert->addAll($fields);
243 243
 		}
244 244
 		return $insert;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		$update = array_key_exists('update-factory', $this->options)
253 253
 			? call_user_func($this->options['update-factory'], $this, $this->options['update-options'])
254 254
 			: new Builder\RunnableUpdate($this, $this->options['update-options']);
255
-		if($fields !== null) {
255
+		if ($fields !== null) {
256 256
 			$update->setAll($fields);
257 257
 		}
258 258
 		return $update;
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 	 * @return $this
272 272
 	 */
273 273
 	public function transactionStart() {
274
-		if($this->transactionLevel === 0) {
275
-			if($this->pdo->inTransaction()) {
274
+		if ($this->transactionLevel === 0) {
275
+			if ($this->pdo->inTransaction()) {
276 276
 				$this->outerTransaction = true;
277 277
 			} else {
278 278
 				$this->pdo->beginTransaction();
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * @return $this
287 287
 	 */
288 288
 	public function transactionCommit() {
289
-		return $this->transactionEnd(function () {
289
+		return $this->transactionEnd(function() {
290 290
 			$this->pdo->commit();
291 291
 		});
292 292
 	}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	 * @return $this
296 296
 	 */
297 297
 	public function transactionRollback() {
298
-		return $this->transactionEnd(function () {
298
+		return $this->transactionEnd(function() {
299 299
 			$this->pdo->rollBack();
300 300
 		});
301 301
 	}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @return T
307 307
 	 */
308 308
 	public function dryRun(callable $callback) {
309
-		if(!$this->pdo->inTransaction()) {
309
+		if (!$this->pdo->inTransaction()) {
310 310
 			$this->transactionStart();
311 311
 			try {
312 312
 				return $callback($this);
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 	 * @throws Throwable
332 332
 	 */
333 333
 	public function transaction(callable $callback) {
334
-		if(!$this->pdo->inTransaction()) {
334
+		if (!$this->pdo->inTransaction()) {
335 335
 			$this->transactionStart();
336 336
 			try {
337 337
 				$result = $callback($this);
338 338
 				$this->transactionCommit();
339 339
 				return $result;
340 340
 			} catch (Throwable $e) {
341
-				if($this->pdo->inTransaction()) {
341
+				if ($this->pdo->inTransaction()) {
342 342
 					$this->transactionRollback();
343 343
 				}
344 344
 				throw $e;
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
 	 */
363 363
 	private function transactionEnd($fn): self {
364 364
 		$this->transactionLevel--;
365
-		if($this->transactionLevel < 0) {
365
+		if ($this->transactionLevel < 0) {
366 366
 			throw new RuntimeException("Transaction-Nesting-Problem: Trying to invoke commit on a already closed transaction");
367 367
 		}
368
-		if($this->transactionLevel < 1) {
369
-			if($this->outerTransaction) {
368
+		if ($this->transactionLevel < 1) {
369
+			if ($this->outerTransaction) {
370 370
 				$this->outerTransaction = false;
371 371
 			} else {
372 372
 				$fn();
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 */
384 384
 	private function buildQueryStatement(string $query, callable $fn): QueryStatement {
385 385
 		$stmt = $fn($query);
386
-		if(!$stmt) {
386
+		if (!$stmt) {
387 387
 			throw new RuntimeException("Could not execute statement:\n{$query}");
388 388
 		}
389 389
 		return new QueryStatement($stmt, $query, $this->exceptionInterpreter, $this->queryLoggers);
Please login to merge, or discard this patch.