Passed
Push — master ( 112334...e680d4 )
by Ron
03:37
created
src/Builder/QueryStatement.php 1 patch
Spacing   +7 added lines, -7 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);
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	public function execute(array $params = []) {
66 66
 		$this->exceptionHandler($this->query, function() use ($params) {
67 67
 			$response = $this->statement->execute($params);
68
-			if(!$response) {
68
+			if (!$response) {
69 69
 				throw new SqlException('Execution returned with "false".');
70 70
 			}
71 71
 		});
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function fetchAll($fetchStyle = PDO::FETCH_ASSOC, $fetchArgument = null, array $ctorArgs = []): array {
82 82
 		$result = $this->exceptionHandler($this->query, function() use ($fetchStyle, $fetchArgument, $ctorArgs) {
83
-			if($fetchArgument !== null) {
83
+			if ($fetchArgument !== null) {
84 84
 				return $this->statement->fetchAll($fetchStyle, $fetchArgument, ...$ctorArgs);
85 85
 			}
86 86
 			return $this->statement->fetchAll($fetchStyle);
87 87
 		});
88
-		if(is_bool($result)) {
88
+		if (is_bool($result)) {
89 89
 			return [];
90 90
 		}
91 91
 		return $result;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	public function getColumnMeta(int $columnNo): ?array {
139 139
 		return $this->exceptionHandler($this->query, function() use ($columnNo) {
140 140
 			$columnMeta = $this->statement->getColumnMeta($columnNo);
141
-			if($columnMeta === false) {
141
+			if ($columnMeta === false) {
142 142
 				return null;
143 143
 			}
144 144
 			return $columnMeta;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @return T
152 152
 	 */
153 153
 	private function exceptionHandler(string $query, callable $fn) {
154
-		return $this->queryLoggers->logRegion($query, function () use ($fn) {
154
+		return $this->queryLoggers->logRegion($query, function() use ($fn) {
155 155
 			try {
156 156
 				return $fn();
157 157
 			} catch (PDOException $exception) {
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,14 +30,14 @@  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 = function() {
35 35
 				return true;
36 36
 			};
37 37
 		}
38 38
 		$this->validator = $validator;
39
-		if($validationResultHandler === null) {
40
-			$validationResultHandler = static function () {};
39
+		if ($validationResultHandler === null) {
40
+			$validationResultHandler = static function() {};
41 41
 		}
42 42
 		$this->validationResultHandler = $validationResultHandler;
43 43
 	}
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 * @return bool
54 54
 	 */
55 55
 	public function isValid(): bool {
56
-		if(!$this->hasValue) {
56
+		if (!$this->hasValue) {
57 57
 			return false;
58 58
 		}
59
-		if($this->validator !== null) {
59
+		if ($this->validator !== null) {
60 60
 			$result = call_user_func($this->validator, $this->value);
61 61
 			call_user_func($this->validationResultHandler, $result, [
62 62
 				'value' => $this->value,
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 	 * @return string[]
80 80
 	 */
81 81
 	private function buildKey($keyPath): array {
82
-		if(is_string($keyPath)) {
82
+		if (is_string($keyPath)) {
83 83
 			$keyPath = explode('.', $keyPath);
84 84
 		}
85
-		if(!is_array($keyPath)) {
85
+		if (!is_array($keyPath)) {
86 86
 			throw new RuntimeException('Invalid key');
87 87
 		}
88 88
 		return $keyPath;
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
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param array<string, mixed> $options
49 49
 	 */
50 50
 	public function __construct(PDO $pdo, array $options = []) {
51
-		if($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
51
+		if ($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
52 52
 			$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
53 53
 		}
54 54
 		$this->pdo = $pdo;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @return VirtualTables
83 83
 	 */
84 84
 	public function getVirtualTables(): VirtualTables {
85
-		if($this->virtualTables === null) {
85
+		if ($this->virtualTables === null) {
86 86
 			$this->virtualTables = new VirtualTables();
87 87
 		}
88 88
 		return $this->virtualTables;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function query(string $query) {
96 96
 		return $this->getQueryLoggers()->logRegion($query, function() use ($query) {
97
-			return $this->buildQueryStatement($query, function ($query) {
97
+			return $this->buildQueryStatement($query, function($query) {
98 98
 				return $this->pdo->query($query);
99 99
 			});
100 100
 		});
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @return QueryStatement
106 106
 	 */
107 107
 	public function prepare(string $query) {
108
-		return $this->buildQueryStatement((string) $query, function ($query) {
108
+		return $this->buildQueryStatement((string) $query, function($query) {
109 109
 			return $this->pdo->prepare($query);
110 110
 		});
111 111
 	}
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function exec(string $query, array $params = []): int {
119 119
 		return $this->getQueryLoggers()->logRegion($query, function() use ($query, $params) {
120
-			return $this->exceptionHandler(function () use ($query, $params) {
120
+			return $this->exceptionHandler(function() use ($query, $params) {
121 121
 				$stmt = $this->pdo->prepare($query);
122 122
 				$timer = microtime(true);
123 123
 				$stmt->execute($params);
124
-				$this->queryLoggers->log($query, microtime(true) - $timer);
124
+				$this->queryLoggers->log($query, microtime(true)-$timer);
125 125
 				$result = $stmt->rowCount();
126 126
 				$stmt->closeCursor();
127 127
 				return $result;
@@ -143,19 +143,19 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function getTableFields(string $table): array {
145 145
 		$fqTable = $this->select()->aliasReplacer()->replace($table);
146
-		if(array_key_exists($fqTable, $this->tableFields)) {
146
+		if (array_key_exists($fqTable, $this->tableFields)) {
147 147
 			return $this->tableFields[$fqTable];
148 148
 		}
149 149
 		$query = "DESCRIBE {$fqTable}";
150 150
 		return $this->getQueryLoggers()->logRegion($query, function() use ($query, $fqTable) {
151
-			return $this->exceptionHandler(function () use ($query, $fqTable) {
151
+			return $this->exceptionHandler(function() use ($query, $fqTable) {
152 152
 				$stmt = $this->pdo->query($query);
153 153
 				try {
154
-					if($stmt === false) {
154
+					if ($stmt === false) {
155 155
 						throw new RuntimeException('Invalid return type');
156 156
 					}
157 157
 					$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
158
-					$this->tableFields[$fqTable] = array_map(static function ($row) { return $row['Field']; }, $rows ?: []);
158
+					$this->tableFields[$fqTable] = array_map(static function($row) { return $row['Field']; }, $rows ?: []);
159 159
 					return $this->tableFields[$fqTable];
160 160
 				} finally {
161 161
 					try {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 		$select = array_key_exists('select-factory', $this->options)
200 200
 			? call_user_func($this->options['select-factory'], $this, $this->options['select-options'])
201 201
 			: new MySQL\MySQLRunnableSelect($this, $this->options['select-options']);
202
-		if($fields !== null) {
202
+		if ($fields !== null) {
203 203
 			$select->fields($fields);
204 204
 		}
205 205
 		return $select;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 		$insert = array_key_exists('insert-factory', $this->options)
214 214
 			? call_user_func($this->options['insert-factory'], $this, $this->options['insert-options'])
215 215
 			: new Builder\RunnableInsert($this, $this->options['insert-options']);
216
-		if($fields !== null) {
216
+		if ($fields !== null) {
217 217
 			$insert->addAll($fields);
218 218
 		}
219 219
 		return $insert;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		$update = array_key_exists('update-factory', $this->options)
228 228
 			? call_user_func($this->options['update-factory'], $this, $this->options['update-options'])
229 229
 			: new Builder\RunnableUpdate($this, $this->options['update-options']);
230
-		if($fields !== null) {
230
+		if ($fields !== null) {
231 231
 			$update->setAll($fields);
232 232
 		}
233 233
 		return $update;
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 * @return $this
247 247
 	 */
248 248
 	public function transactionStart() {
249
-		if($this->transactionLevel === 0) {
250
-			if($this->pdo->inTransaction()) {
249
+		if ($this->transactionLevel === 0) {
250
+			if ($this->pdo->inTransaction()) {
251 251
 				$this->outerTransaction = true;
252 252
 			} else {
253 253
 				$this->pdo->beginTransaction();
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @return $this
262 262
 	 */
263 263
 	public function transactionCommit() {
264
-		return $this->transactionEnd(function () {
264
+		return $this->transactionEnd(function() {
265 265
 			$this->pdo->commit();
266 266
 		});
267 267
 	}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @return $this
271 271
 	 */
272 272
 	public function transactionRollback() {
273
-		return $this->transactionEnd(function () {
273
+		return $this->transactionEnd(function() {
274 274
 			$this->pdo->rollBack();
275 275
 		});
276 276
 	}
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	 * @return T
282 282
 	 */
283 283
 	public function dryRun(callable $callback) {
284
-		if(!$this->pdo->inTransaction()) {
284
+		if (!$this->pdo->inTransaction()) {
285 285
 			$this->transactionStart();
286 286
 			try {
287 287
 				return $callback($this);
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @throws Throwable
307 307
 	 */
308 308
 	public function transaction(callable $callback) {
309
-		if(!$this->pdo->inTransaction()) {
309
+		if (!$this->pdo->inTransaction()) {
310 310
 			$this->transactionStart();
311 311
 			try {
312 312
 				$result = $callback($this);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 				return $result;
315 315
 			} catch (Throwable $e) {
316 316
 				// @phpstan-ignore-next-line; If condition is always false as it is not.
317
-				if($this->pdo->inTransaction()) {
317
+				if ($this->pdo->inTransaction()) {
318 318
 					$this->transactionRollback();
319 319
 				}
320 320
 				throw $e;
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	private function transactionEnd($fn): self {
340 340
 		$this->transactionLevel--;
341
-		if($this->transactionLevel < 0) {
341
+		if ($this->transactionLevel < 0) {
342 342
 			throw new RuntimeException("Transaction-Nesting-Problem: Trying to invoke commit on a already closed transaction");
343 343
 		}
344
-		if($this->transactionLevel < 1) {
345
-			if($this->outerTransaction) {
344
+		if ($this->transactionLevel < 1) {
345
+			if ($this->outerTransaction) {
346 346
 				$this->outerTransaction = false;
347 347
 			} else {
348 348
 				$fn();
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	 */
360 360
 	private function buildQueryStatement(string $query, callable $fn): QueryStatement {
361 361
 		$stmt = $fn($query);
362
-		if(!$stmt) {
362
+		if (!$stmt) {
363 363
 			throw new RuntimeException("Could not execute statement:\n{$query}");
364 364
 		}
365 365
 		return new QueryStatement($stmt, $query, $this->exceptionInterpreter, $this->queryLoggers);
Please login to merge, or discard this patch.