Completed
Push — master ( 6c7828...2041e7 )
by Ron
03:38
created
src/Databases/MySQL/MySQLExceptionInterpreter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@
 block discarded – undo
16 16
 	public function throwMoreConcreteException(PDOException $exception) {
17 17
 		$code = $exception->getCode();
18 18
 		$message = (string) $exception->getMessage();
19
-		switch($code) {
19
+		switch ($code) {
20 20
 			case 2006: throw new DatabaseHasGoneAwayException($message, $code, $exception);
21 21
 			case 1213: throw new SqlDeadLockException($message, $code, $exception);
22 22
 			case 1205: throw new LockWaitTimeoutExceededException($message, $code, $exception);
23 23
 			case 1062: throw new DuplicateUniqueKeyException($message, $code, $exception);
24 24
 		}
25 25
 		/** @link http://php.net/manual/en/class.exception.php#Hcom115813 (cHao's comment) */
26
-		if(!is_string($message) || !is_int($code)) {
26
+		if (!is_string($message) || !is_int($code)) {
27 27
 			throw new SqlException((string) $message, (int) $code, $exception);
28 28
 		}
29 29
 		throw $exception;
Please login to merge, or discard this patch.
src/Databases/MySQL.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param array $options
38 38
 	 */
39 39
 	public function __construct(PDO $pdo, array $options = []) {
40
-		if($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
40
+		if ($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
41 41
 			$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
42 42
 		}
43 43
 		$this->pdo = $pdo;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @return QueryStatement
74 74
 	 */
75 75
 	public function query($query) {
76
-		return $this->buildQueryStatement($query, function ($query) {
76
+		return $this->buildQueryStatement($query, function($query) {
77 77
 			$stmt = $this->pdo->query($query);
78 78
 			return $stmt;
79 79
 		});
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @return QueryStatement
86 86
 	 */
87 87
 	public function prepare($query) {
88
-		return $this->buildQueryStatement((string) $query, function ($query) {
88
+		return $this->buildQueryStatement((string) $query, function($query) {
89 89
 			$stmt = $this->pdo->prepare($query);
90 90
 			return $stmt;
91 91
 		});
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	 * @return int
98 98
 	 */
99 99
 	public function exec($query, array $params = array()) {
100
-		return $this->exceptionHandler(function () use ($query, $params) {
100
+		return $this->exceptionHandler(function() use ($query, $params) {
101 101
 			$stmt = $this->pdo->prepare($query);
102 102
 			$timer = microtime(true);
103 103
 			$stmt->execute($params);
104
-			$this->queryLoggers->log($query, microtime(true) - $timer);
104
+			$this->queryLoggers->log($query, microtime(true)-$timer);
105 105
 			$result = $stmt->rowCount();
106 106
 			$stmt->closeCursor();
107 107
 			return $result;
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function getTableFields($table) {
123 123
 		$table = $this->select()->aliasReplacer()->replace($table);
124
-		if(array_key_exists($table, self::$tableFields)) {
124
+		if (array_key_exists($table, self::$tableFields)) {
125 125
 			return self::$tableFields[$table];
126 126
 		}
127 127
 		$stmt = $this->pdo->query("DESCRIBE {$table}");
128 128
 		$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
129
-		self::$tableFields[$table] = array_map(function ($row) { return $row['Field']; }, $rows);
129
+		self::$tableFields[$table] = array_map(function($row) { return $row['Field']; }, $rows);
130 130
 		$stmt->closeCursor();
131 131
 		return self::$tableFields[$table];
132 132
 	}
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 	 * @return string
138 138
 	 */
139 139
 	public function quoteExpression($expression, array $arguments = array()) {
140
-		$func = function () use ($arguments) {
140
+		$func = function() use ($arguments) {
141 141
 			static $idx = -1;
142 142
 			$idx++;
143 143
 			$index = $idx;
144
-			if(array_key_exists($index, $arguments)) {
144
+			if (array_key_exists($index, $arguments)) {
145 145
 				$argument = $arguments[$index];
146 146
 				$value = $this->quote($argument);
147 147
 			} else {
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 	 * @return string
159 159
 	 */
160 160
 	public function quote($value) {
161
-		if(is_null($value)) {
161
+		if (is_null($value)) {
162 162
 			$result = 'NULL';
163
-		} elseif($value instanceof Builder\DBExpr) {
163
+		} elseif ($value instanceof Builder\DBExpr) {
164 164
 			$result = $value->getExpression();
165
-		} elseif($value instanceof Builder\Select) {
165
+		} elseif ($value instanceof Builder\Select) {
166 166
 			$result = sprintf('(%s)', (string) $value);
167
-		} elseif(is_array($value)) {
168
-			$result = join(', ', array_map(function ($value) { return $this->quote($value); }, $value));
167
+		} elseif (is_array($value)) {
168
+			$result = join(', ', array_map(function($value) { return $this->quote($value); }, $value));
169 169
 		} else {
170 170
 			$result = $this->pdo->quote($value);
171 171
 		}
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		if (is_numeric($field) || !is_string($field)) {
181 181
 			throw new UnexpectedValueException('Field name is invalid');
182 182
 		}
183
-		if(strpos($field, '`') !== false) {
183
+		if (strpos($field, '`') !== false) {
184 184
 			return (string) $field;
185 185
 		}
186 186
 		$parts = explode('.', $field);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		$select = array_key_exists('select-factory', $this->options)
196 196
 			? call_user_func($this->options['select-factory'], $this, $this->options['select-options'])
197 197
 			: new Builder\RunnableSelect($this, $this->options['select-options']);
198
-		if($fields !== null) {
198
+		if ($fields !== null) {
199 199
 			$select->fields($fields);
200 200
 		}
201 201
 		return $select;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		$insert = array_key_exists('insert-factory', $this->options)
210 210
 			? call_user_func($this->options['insert-factory'], $this, $this->options['insert-options'])
211 211
 			: new Builder\RunnableInsert($this, $this->options['insert-options']);
212
-		if($fields !== null) {
212
+		if ($fields !== null) {
213 213
 			$insert->addAll($fields);
214 214
 		}
215 215
 		return $insert;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		$update = array_key_exists('update-factory', $this->options)
224 224
 			? call_user_func($this->options['update-factory'], $this, $this->options['update-options'])
225 225
 			: new Builder\RunnableUpdate($this, $this->options['update-options']);
226
-		if($fields !== null) {
226
+		if ($fields !== null) {
227 227
 			$update->setAll($fields);
228 228
 		}
229 229
 		return $update;
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
 	 * @return $this
243 243
 	 */
244 244
 	public function transactionStart() {
245
-		if((int) $this->transactionLevel === 0) {
246
-			if($this->pdo->inTransaction()) {
245
+		if ((int) $this->transactionLevel === 0) {
246
+			if ($this->pdo->inTransaction()) {
247 247
 				$this->outerTransaction = true;
248 248
 			} else {
249 249
 				$this->pdo->beginTransaction();
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @throws \Exception
259 259
 	 */
260 260
 	public function transactionCommit() {
261
-		return $this->transactionEnd(function () {
261
+		return $this->transactionEnd(function() {
262 262
 			$this->pdo->commit();
263 263
 		});
264 264
 	}
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @throws \Exception
269 269
 	 */
270 270
 	public function transactionRollback() {
271
-		return $this->transactionEnd(function () {
271
+		return $this->transactionEnd(function() {
272 272
 			$this->pdo->rollBack();
273 273
 		});
274 274
 	}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	public function dryRun($callback = null) {
283 283
 		$result = null;
284 284
 		$exception = null;
285
-		if(!$this->pdo->inTransaction()) {
285
+		if (!$this->pdo->inTransaction()) {
286 286
 			$this->transactionStart();
287 287
 			try {
288 288
 				$result = call_user_func($callback, $this);
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 				$exception = $e;
291 291
 			}
292 292
 			$this->transactionRollback();
293
-			if($exception !== null) {
293
+			if ($exception !== null) {
294 294
 				throw $exception;
295 295
 			}
296 296
 		} else {
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 				$exception = $e;
303 303
 			}
304 304
 			$this->exec("ROLLBACK TO {$uniqueId}");
305
-			if($exception !== null) {
305
+			if ($exception !== null) {
306 306
 				throw $exception;
307 307
 			}
308 308
 		}
@@ -317,15 +317,15 @@  discard block
 block discarded – undo
317 317
 	 * @throws null
318 318
 	 */
319 319
 	public function transaction($tries = 1, $callback = null) {
320
-		if(is_callable($tries)) {
320
+		if (is_callable($tries)) {
321 321
 			$callback = $tries;
322 322
 			$tries = 1;
323
-		} elseif(!is_callable($callback)) {
323
+		} elseif (!is_callable($callback)) {
324 324
 			throw new \Exception('$callback must be a callable');
325 325
 		}
326 326
 		$e = null;
327
-		if(!$this->pdo->inTransaction()) {
328
-			for(; $tries--;) {
327
+		if (!$this->pdo->inTransaction()) {
328
+			for (; $tries--;) {
329 329
 				try {
330 330
 					$this->transactionStart();
331 331
 					$result = call_user_func($callback, $this);
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 	 */
357 357
 	private function transactionEnd($fn) {
358 358
 		$this->transactionLevel--;
359
-		if($this->transactionLevel < 0) {
359
+		if ($this->transactionLevel < 0) {
360 360
 			throw new \Exception("Transaction-Nesting-Problem: Trying to invoke commit on a already closed transaction");
361 361
 		}
362
-		if((int) $this->transactionLevel === 0) {
363
-			if($this->outerTransaction) {
362
+		if ((int) $this->transactionLevel === 0) {
363
+			if ($this->outerTransaction) {
364 364
 				$this->outerTransaction = false;
365 365
 			} else {
366 366
 				call_user_func($fn);
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 */
378 378
 	private function buildQueryStatement($query, $fn) {
379 379
 		$stmt = call_user_func($fn, $query);
380
-		if(!$stmt) {
380
+		if (!$stmt) {
381 381
 			throw new Exception("Could not execute statement:\n{$query}");
382 382
 		}
383 383
 		$stmtWrapper = new QueryStatement($stmt, $query, $this->exceptionInterpreter, $this->queryLoggers);
Please login to merge, or discard this patch.
src/Builder/RunnableSelect.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	/**
244 244
 	 * @param Closure $callback
245 245
 	 * @param int $mode
246
-	 * @param mixed $arg0
246
+	 * @param string $arg0
247 247
 	 * @return mixed
248 248
 	 * @throws RuntimeException
249 249
 	 */
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	/**
278 278
 	 * @param Closure $callback
279 279
 	 * @param int $mode
280
-	 * @param mixed $arg0
280
+	 * @param string $arg0
281 281
 	 * @return Traversable|YieldPolyfillIterator|mixed[]
282 282
 	 */
283 283
 	private function fetchLazy(Closure $callback = null, $mode, $arg0 = null) {
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	/**
298 298
 	 * @param Closure $callback
299 299
 	 * @param int $mode
300
-	 * @param mixed $arg0
300
+	 * @param null|string $arg0
301 301
 	 * @param Closure $resultValidator
302 302
 	 * @return mixed
303 303
 	 * @throws \Exception
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @throws \Exception
95 95
 	 */
96 96
 	public function fetchRow(Closure $callback = null) {
97
-		return $this->fetch($callback, PDO::FETCH_ASSOC, null, function ($row) {
97
+		return $this->fetch($callback, PDO::FETCH_ASSOC, null, function($row) {
98 98
 			return ['valid' => is_array($row), 'default' => []];
99 99
 		});
100 100
 	}
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @throws \Exception
126 126
 	 */
127 127
 	public function fetchObject($className = null, Closure $callback = null) {
128
-		return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, function ($row) {
128
+		return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, function($row) {
129 129
 			return ['valid' => is_object($row), 'default' => null];
130 130
 		});
131 131
 	}
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 * @return mixed[]
136 136
 	 */
137 137
 	public function fetchKeyValue($treatValueAsArray = false) {
138
-		return $this->createTempStatement(function (QueryStatement $statement) use ($treatValueAsArray) {
139
-			if($treatValueAsArray) {
138
+		return $this->createTempStatement(function(QueryStatement $statement) use ($treatValueAsArray) {
139
+			if ($treatValueAsArray) {
140 140
 				$rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
141 141
 				$result = array();
142
-				foreach($rows as $row) {
142
+				foreach ($rows as $row) {
143 143
 					list($key) = array_values($row);
144 144
 					$result[$key] = $row;
145 145
 				}
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 	public function fetchGroups(array $fields) {
157 157
 		$rows = $this->fetchRows();
158 158
 		$result = array();
159
-		foreach($rows as $row) {
159
+		foreach ($rows as $row) {
160 160
 			$tmp = &$result;
161
-			foreach($fields as $field) {
161
+			foreach ($fields as $field) {
162 162
 				$value = $row[$field];
163
-				if(!array_key_exists($value, $tmp)) {
163
+				if (!array_key_exists($value, $tmp)) {
164 164
 					$tmp[$value] = [];
165 165
 				}
166 166
 				$tmp = &$tmp[$value];
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @return string[]
175 175
 	 */
176 176
 	public function fetchArray() {
177
-		return $this->createTempStatement(function (QueryStatement $stmt) {
177
+		return $this->createTempStatement(function(QueryStatement $stmt) {
178 178
 			return $stmt->fetchAll(\PDO::FETCH_COLUMN);
179 179
 		});
180 180
 	}
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
 	 * @return null|bool|string|int|float
185 185
 	 */
186 186
 	public function fetchValue($default = null) {
187
-		return $this->createTempStatement(function (QueryStatement $stmt) use ($default) {
187
+		return $this->createTempStatement(function(QueryStatement $stmt) use ($default) {
188 188
 			$result = $stmt->fetch(\PDO::FETCH_NUM);
189
-			if($result !== false) {
189
+			if ($result !== false) {
190 190
 				return $result[0];
191 191
 			}
192 192
 			return $default;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		$query = $this->__toString();
228 228
 		$statement = $db->prepare($query);
229 229
 		$statement->execute($this->values);
230
-		if($this->getCalcFoundRows()) {
230
+		if ($this->getCalcFoundRows()) {
231 231
 			$this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn();
232 232
 		}
233 233
 		return $statement;
@@ -248,20 +248,20 @@  discard block
 block discarded – undo
248 248
 	 * @throws RuntimeException
249 249
 	 */
250 250
 	private function fetchAll(Closure $callback = null, $mode, $arg0 = null) {
251
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) {
251
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) {
252 252
 			$statement->setFetchMode($mode, $arg0);
253 253
 			$data = $statement->fetchAll();
254
-			if($this->preserveTypes) {
254
+			if ($this->preserveTypes) {
255 255
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
256
-				foreach($data as &$row) {
256
+				foreach ($data as &$row) {
257 257
 					$row = FieldValueConverter::convertValues($row, $columnDefinitions);
258 258
 				}
259 259
 			}
260
-			if($callback !== null) {
261
-				return call_user_func(function ($resultData = []) use ($data, $callback) {
262
-					foreach($data as $row) {
260
+			if ($callback !== null) {
261
+				return call_user_func(function($resultData = []) use ($data, $callback) {
262
+					foreach ($data as $row) {
263 263
 						$result = $callback($row);
264
-						if($result !== null && !($result instanceof DBIgnoreRow)) {
264
+						if ($result !== null && !($result instanceof DBIgnoreRow)) {
265 265
 							$resultData[] = $result;
266 266
 						} else {
267 267
 							$resultData[] = $row;
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @return Traversable|YieldPolyfillIterator|mixed[]
282 282
 	 */
283 283
 	private function fetchLazy(Closure $callback = null, $mode, $arg0 = null) {
284
-		if(version_compare(PHP_VERSION, '5.5', '<')) {
285
-			return new YieldPolyfillIterator($callback, $this->preserveTypes, function () use ($mode, $arg0) {
284
+		if (version_compare(PHP_VERSION, '5.5', '<')) {
285
+			return new YieldPolyfillIterator($callback, $this->preserveTypes, function() use ($mode, $arg0) {
286 286
 				$statement = $this->createStatement();
287 287
 				$statement->setFetchMode($mode, $arg0);
288 288
 				return $statement;
@@ -303,20 +303,20 @@  discard block
 block discarded – undo
303 303
 	 * @throws \Exception
304 304
 	 */
305 305
 	private function fetch(Closure $callback = null, $mode, $arg0 = null, Closure $resultValidator = null) {
306
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
306
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
307 307
 			$statement->setFetchMode($mode, $arg0);
308 308
 			$row = $statement->fetch();
309 309
 			$result = $resultValidator($row);
310
-			if(!$result['valid']) {
310
+			if (!$result['valid']) {
311 311
 				return $result['default'];
312 312
 			}
313
-			if($this->preserveTypes) {
313
+			if ($this->preserveTypes) {
314 314
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
315 315
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
316 316
 			}
317
-			if($callback !== null) {
317
+			if ($callback !== null) {
318 318
 				$result = $callback($row);
319
-				if($result !== null) {
319
+				if ($result !== null) {
320 320
 					$row = $result;
321 321
 				}
322 322
 			}
Please login to merge, or discard this patch.
src/Builder/Insert.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @return $this
89 89
 	 */
90 90
 	public function addExpr($str, $_) {
91
-		if(count(func_get_args()) > 1) {
91
+		if (count(func_get_args()) > 1) {
92 92
 			$this->fields[] = func_get_args();
93 93
 		} else {
94 94
 			$this->fields[] = $str;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @return $this
103 103
 	 */
104 104
 	public function updateExpr($str, $_) {
105
-		if(count(func_get_args()) > 1) {
105
+		if (count(func_get_args()) > 1) {
106 106
 			$this->update[] = func_get_args();
107 107
 		} else {
108 108
 			$this->update[] = $str;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @return $this
116 116
 	 */
117 117
 	public function addOrUpdateExpr($str) {
118
-		if(count(func_get_args()) > 1) {
118
+		if (count(func_get_args()) > 1) {
119 119
 			$this->fields[] = func_get_args();
120 120
 			$this->update[] = func_get_args();
121 121
 		} else {
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @return $this
133 133
 	 */
134 134
 	public function addAll(array $data, array $mask = null, array $excludeFields = null) {
135
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
135
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
136 136
 			$this->add($field, $value);
137 137
 		});
138 138
 		return $this;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return $this
146 146
 	 */
147 147
 	public function updateAll(array $data, array $mask = null, array $excludeFields = null) {
148
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
148
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
149 149
 			if ($field !== $this->keyField) {
150 150
 				$this->update($field, $value);
151 151
 			}
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		$ignoreStr = $this->ignore ? ' IGNORE' : '';
190 190
 		$queryArr[] = "INSERT{$ignoreStr} INTO\n\t{$tableName}\n";
191 191
 
192
-		if($this->from !== null) {
192
+		if ($this->from !== null) {
193 193
 			$fields = $this->from->getFields();
194 194
 			$queryArr[] = sprintf("\t(%s)\n", join(', ', array_keys($fields)));
195 195
 			$queryArr[] = $this->from;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		$updateData = $this->buildUpdate();
206
-		if($updateData) {
206
+		if ($updateData) {
207 207
 			$queryArr[] = "{$updateData}\n";
208 208
 		}
209 209
 
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 	 * @return $this
237 237
 	 */
238 238
 	private function addAllTo(array $data, array $mask = null, array $excludeFields = null, $fn) {
239
-		if($mask !== null) {
239
+		if ($mask !== null) {
240 240
 			$data = array_intersect_key($data, array_combine($mask, $mask));
241 241
 		}
242
-		if($excludeFields !== null) {
243
-			foreach($excludeFields as $excludeField) {
244
-				if(array_key_exists($excludeField, $data)) {
242
+		if ($excludeFields !== null) {
243
+			foreach ($excludeFields as $excludeField) {
244
+				if (array_key_exists($excludeField, $data)) {
245 245
 					unset($data[$excludeField]);
246 246
 				}
247 247
 			}
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 	 */
259 259
 	private function buildUpdate() {
260 260
 		$queryArr = array();
261
-		if(!empty($this->update)) {
261
+		if (!empty($this->update)) {
262 262
 			$queryArr[] = "ON DUPLICATE KEY UPDATE\n";
263 263
 			$updateArr = array();
264
-			if($this->keyField !== null) {
264
+			if ($this->keyField !== null) {
265 265
 				$updateArr[] = "\t`{$this->keyField}` = LAST_INSERT_ID({$this->keyField})";
266 266
 			}
267 267
 			$updateArr = $this->buildFieldList($this->update, $updateArr);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * @throws Exception
286 286
 	 */
287 287
 	private function clearValues(array $values) {
288
-		if(!count($values)) {
288
+		if (!count($values)) {
289 289
 			return [];
290 290
 		}
291 291
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		$result = array();
295 295
 
296 296
 		foreach ($values as $fieldName => $fieldValue) {
297
-			if(in_array($fieldName, $fields)) {
297
+			if (in_array($fieldName, $fields)) {
298 298
 				$result[$fieldName] = $fieldValue;
299 299
 			}
300 300
 		}
Please login to merge, or discard this patch.
src/Builder/Traits/HavingBuilder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@
 block discarded – undo
16 16
 	 * @return $this
17 17
 	 */
18 18
 	public function having($expression, $_) {
19
-		if($expression instanceof OptionalExpression) {
20
-			if($expression->isValid()) {
19
+		if ($expression instanceof OptionalExpression) {
20
+			if ($expression->isValid()) {
21 21
 				$this->having[] = [$expression->getExpression(), $expression->getValue()];
22 22
 			}
23 23
 		} else {
Please login to merge, or discard this patch.
src/Builder/Traits/WhereBuilder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@
 block discarded – undo
16 16
 	 * @return $this
17 17
 	 */
18 18
 	public function where($expression, $_) {
19
-		if($expression instanceof OptionalExpression) {
20
-			if($expression->isValid()) {
19
+		if ($expression instanceof OptionalExpression) {
20
+			if ($expression->isValid()) {
21 21
 				$this->where[] = [$expression->getExpression(), $expression->getValue()];
22 22
 			}
23 23
 		} else {
Please login to merge, or discard this patch.