Completed
Push — master ( 353d0e...6c7828 )
by Ron
01:57
created
src/Builder/Helpers/FieldTypeProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 	 */
11 11
 	public static function getFieldTypes(QueryStatement $statement) {
12 12
 		$fieldTypes = array();
13
-		for($i = 0; $column = $statement->getColumnMeta($i); $i++) {
13
+		for ($i = 0; $column = $statement->getColumnMeta($i); $i++) {
14 14
 			$fieldTypes[$column['name']] = self::getTypeFromNativeType($column['native_type']);
15 15
 		}
16 16
 		return $fieldTypes;
Please login to merge, or discard this patch.
src/Builder/Expr/RequiredDBFilterMap.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@
 block discarded – undo
27 27
 	 * @return DBExprFilter
28 28
 	 */
29 29
 	public function __invoke($expression, $keyPath, $validator = null) {
30
-		return new DBExprFilter($expression, $this->map, $keyPath, $validator, function ($result, array $data) {
31
-			if(!$result) {
30
+		return new DBExprFilter($expression, $this->map, $keyPath, $validator, function($result, array $data) {
31
+			if (!$result) {
32 32
 				throw new RequiredValueNotFoundException(sprintf("Required value %s not found", $data['key']));
33 33
 			}
34 34
 		});
Please login to merge, or discard this patch.
src/Builder/Expr/DBExprFilter.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -28,16 +28,16 @@  discard block
 block discarded – undo
28 28
 		$this->value = $data;
29 29
 		$this->keyPath = $this->buildKey($keyPath);
30 30
 		$this->value = $this->recursiveGet($data, $this->keyPath, null);
31
-		if($validator === null) {
32
-			$validator = function ($data) {
33
-				if(is_array($data)) {
31
+		if ($validator === null) {
32
+			$validator = function($data) {
33
+				if (is_array($data)) {
34 34
 					return $this->isValidArray($data);
35 35
 				}
36 36
 				return (string) $data !== '';
37 37
 			};
38 38
 		}
39
-		if($validationResultHandler === null) {
40
-			$validationResultHandler = function () {};
39
+		if ($validationResultHandler === null) {
40
+			$validationResultHandler = function() {};
41 41
 		}
42 42
 		$this->validator = $validator;
43 43
 		$this->validationResultHandler = $validationResultHandler;
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	 * @throws Exception
76 76
 	 */
77 77
 	private function buildKey($keyPath) {
78
-		if(is_string($keyPath)) {
78
+		if (is_string($keyPath)) {
79 79
 			$keyPath = explode('.', $keyPath);
80 80
 		}
81
-		if(!is_array($keyPath)) {
81
+		if (!is_array($keyPath)) {
82 82
 			throw new Exception('Invalid key');
83 83
 		}
84 84
 		return $keyPath;
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 	 * @return bool
90 90
 	 */
91 91
 	private function isValidArray(array $array) {
92
-		$data = array_filter($array, function ($value) {
93
-			if(is_array($value)) {
92
+		$data = array_filter($array, function($value) {
93
+			if (is_array($value)) {
94 94
 				return $this->isValidArray($value);
95 95
 			}
96 96
 			return (string) $value !== '';
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 		if (!$count) {
110 110
 			return $default;
111 111
 		}
112
-		for($idx = 0; $idx < $count; $idx++) {
112
+		for ($idx = 0; $idx < $count; $idx++) {
113 113
 			$part = $path[$idx];
114
-			if(!array_key_exists($part, $array)) {
114
+			if (!array_key_exists($part, $array)) {
115 115
 				return $default;
116 116
 			}
117 117
 			$array = $array[$part];
Please login to merge, or discard this patch.
src/Builder/Helpers/YieldPolyfillIterator.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
 	}
75 75
 
76 76
 	/**
77
-	 * @return mixed
77
+	 * @return integer
78 78
 	 */
79 79
 	public function key() {
80 80
 		return $this->idx;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function current() {
49 49
 		$row = $this->currentItem;
50
-		if($this->preserveTypes) {
50
+		if ($this->preserveTypes) {
51 51
 			$columnDefinitions = FieldTypeProvider::getFieldTypes($this->getStmt());
52 52
 			$row = FieldValueConverter::convertValues($row, $columnDefinitions);
53 53
 		}
54 54
 		$callback = $this->callback;
55
-		if($callback !== null) {
55
+		if ($callback !== null) {
56 56
 			$result = $callback($row);
57
-			if($result instanceof DBIgnoreRow) {
57
+			if ($result instanceof DBIgnoreRow) {
58 58
 				// Do nothing in this case
59
-			} elseif($result !== null) {
59
+			} elseif ($result !== null) {
60 60
 				return $result;
61 61
 			} else {
62 62
 				return $row;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function valid() {
87 87
 		$result = !!$this->currentItem;
88
-		if(!$result) {
88
+		if (!$result) {
89 89
 			$this->closeCursor();
90 90
 		}
91 91
 		return $result;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	/**
95 95
 	 */
96 96
 	public function rewind() {
97
-		if($this->stmt !== null) {
97
+		if ($this->stmt !== null) {
98 98
 			throw new \Exception("It's not possible to rewind this iterator");
99 99
 		}
100 100
 		$this->stmt = call_user_func($this->statementFactory);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @return QueryStatement
107 107
 	 */
108 108
 	private function getStmt() {
109
-		if($this->stmt === null) {
109
+		if ($this->stmt === null) {
110 110
 			$this->rewind();
111 111
 		}
112 112
 		return $this->stmt;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	/**
116 116
 	 */
117 117
 	private function closeCursor() {
118
-		if($this->stmt instanceof QueryStatement) {
118
+		if ($this->stmt instanceof QueryStatement) {
119 119
 			$this->stmt->closeCursor();
120 120
 		}
121 121
 		$this->stmt = null;
Please login to merge, or discard this patch.
src/Builder/Select.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 	}
79 79
 
80 80
 	/**
81
-	 * @return array
81
+	 * @return string[]
82 82
 	 */
83 83
 	public function getFields() {
84 84
 		return $this->fields;
Please login to merge, or discard this patch.
src/Builder/Traits/LimitBuilder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
28 28
 	 */
29 29
 	protected function buildLimit($query, $offset = null) {
30 30
 		$limit = $this->limit;
31
-		if($limit === null && $offset !== null) {
31
+		if ($limit === null && $offset !== null) {
32 32
 			$limit = '18446744073709551615';
33 33
 		}
34
-		if($limit !== null) {
34
+		if ($limit !== null) {
35 35
 			$query .= "LIMIT\n\t{$limit}\n";
36 36
 		}
37 37
 		return $query;
Please login to merge, or discard this patch.
src/Builder/Helpers/LazyRowGenerator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@
 block discarded – undo
21 21
 	 * @return array[]|\Generator
22 22
 	 */
23 23
 	public function generate(QueryStatement $statement, Closure $callback = null) {
24
-		while($row = $statement->fetch()) {
25
-			if($this->preserveTypes) {
24
+		while ($row = $statement->fetch()) {
25
+			if ($this->preserveTypes) {
26 26
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
27 27
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
28 28
 			}
29
-			if($callback !== null) {
29
+			if ($callback !== null) {
30 30
 				$result = $callback($row);
31
-				if($result instanceof DBIgnoreRow) {
31
+				if ($result instanceof DBIgnoreRow) {
32 32
 					// Do nothing in this case
33
-				} elseif($result !== null) {
33
+				} elseif ($result !== null) {
34 34
 					yield $result;
35 35
 				} else {
36 36
 					yield $row;
Please login to merge, or discard this patch.
src/Builder/QueryStatement.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 	 * @return $this
47 47
 	 */
48 48
 	public function setFetchMode($mode, $arg0 = null, array $arg1 = null) {
49
-		if($arg1 !== null) {
49
+		if ($arg1 !== null) {
50 50
 			/** @noinspection PhpMethodParametersCountMismatchInspection */
51 51
 			$this->statement->setFetchMode($mode, $arg0, $arg1);
52 52
 			return $this;
53 53
 		}
54
-		if($arg0 !== null) {
54
+		if ($arg0 !== null) {
55 55
 			/** @noinspection PhpMethodParametersCountMismatchInspection */
56 56
 			$this->statement->setFetchMode($mode, $arg0);
57 57
 			return $this;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 			$timer = microtime(true);
71 71
 			$response = $this->statement->execute($params);
72 72
 			$this->queryLoggers->log($this->query, microtime(true)-$timer);
73
-			if(!$response) {
73
+			if (!$response) {
74 74
 				throw new SqlException('Execution returned with "false".');
75 75
 			}
76 76
 		});
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function fetchAll($fetchStyle = null, $fetchArgument = null, array $ctorArgs = []) {
87 87
 		return $this->exceptionHandler(function() use ($fetchStyle, $fetchArgument, $ctorArgs) {
88
-			if($fetchArgument !== null) {
88
+			if ($fetchArgument !== null) {
89 89
 				return $this->statement->fetchAll($fetchStyle, $fetchArgument, $ctorArgs);
90 90
 			}
91 91
 			return $this->statement->fetchAll($fetchStyle);
Please login to merge, or discard this patch.
src/Builder/RunnableSelect.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 	/**
183
-	 * @return bool
183
+	 * @return integer
184 184
 	 */
185 185
 	public function getFoundRows() {
186 186
 		return $this->foundRows;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	/**
229 229
 	 * @param Closure $callback
230 230
 	 * @param int $mode
231
-	 * @param mixed $arg0
231
+	 * @param string $arg0
232 232
 	 * @return mixed
233 233
 	 * @throws \Exception
234 234
 	 */
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	/**
263 263
 	 * @param Closure $callback
264 264
 	 * @param int $mode
265
-	 * @param mixed $arg0
265
+	 * @param string $arg0
266 266
 	 * @return Generator|YieldPolyfillIterator|mixed[]
267 267
 	 */
268 268
 	private function fetchLazy(Closure $callback = null, $mode, $arg0 = null) {
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	/**
283 283
 	 * @param Closure $callback
284 284
 	 * @param int $mode
285
-	 * @param mixed $arg0
285
+	 * @param null|string $arg0
286 286
 	 * @param Closure $resultValidator
287 287
 	 * @return mixed
288 288
 	 * @throws \Exception
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @throws \Exception
94 94
 	 */
95 95
 	public function fetchRow(Closure $callback = null) {
96
-		return $this->fetch($callback, PDO::FETCH_ASSOC, null, function ($row) {
96
+		return $this->fetch($callback, PDO::FETCH_ASSOC, null, function($row) {
97 97
 			return ['valid' => is_array($row), 'default' => []];
98 98
 		});
99 99
 	}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @throws \Exception
125 125
 	 */
126 126
 	public function fetchObject($className = null, Closure $callback = null) {
127
-		return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, function ($row) {
127
+		return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, function($row) {
128 128
 			return ['valid' => is_object($row), 'default' => null];
129 129
 		});
130 130
 	}
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	 * @return mixed[]
135 135
 	 */
136 136
 	public function fetchKeyValue($treatValueAsArray = false) {
137
-		return $this->createTempStatement(function (QueryStatement $statement) use ($treatValueAsArray) {
138
-			if($treatValueAsArray) {
137
+		return $this->createTempStatement(function(QueryStatement $statement) use ($treatValueAsArray) {
138
+			if ($treatValueAsArray) {
139 139
 				$rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
140 140
 				$result = array();
141
-				foreach($rows as $row) {
141
+				foreach ($rows as $row) {
142 142
 					list($key) = array_values($row);
143 143
 					$result[$key] = $row;
144 144
 				}
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 	public function fetchGroups(array $fields) {
156 156
 		$rows = $this->fetchRows();
157 157
 		$result = array();
158
-		foreach($rows as $row) {
158
+		foreach ($rows as $row) {
159 159
 			$tmp = &$result;
160
-			foreach($fields as $field) {
160
+			foreach ($fields as $field) {
161 161
 				$value = $row[$field];
162
-				if(!array_key_exists($value, $tmp)) {
162
+				if (!array_key_exists($value, $tmp)) {
163 163
 					$tmp[$value] = [];
164 164
 				}
165 165
 				$tmp = &$tmp[$value];
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 * @return string[]
174 174
 	 */
175 175
 	public function fetchArray() {
176
-		return $this->createTempStatement(function (QueryStatement $stmt) {
176
+		return $this->createTempStatement(function(QueryStatement $stmt) {
177 177
 			return $stmt->fetchAll(\PDO::FETCH_COLUMN);
178 178
 		});
179 179
 	}
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	 * @return null|bool|string|int|float
184 184
 	 */
185 185
 	public function fetchValue($default = null) {
186
-		return $this->createTempStatement(function (QueryStatement $stmt) use ($default) {
186
+		return $this->createTempStatement(function(QueryStatement $stmt) use ($default) {
187 187
 			$result = $stmt->fetch(\PDO::FETCH_NUM);
188
-			if($result !== false) {
188
+			if ($result !== false) {
189 189
 				return $result[0];
190 190
 			}
191 191
 			return $default;
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		$query = $this->__toString();
226 226
 		$statement = $db->prepare($query);
227 227
 		$statement->execute($this->values);
228
-		if($this->getCalcFoundRows()) {
228
+		if ($this->getCalcFoundRows()) {
229 229
 			$this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn();
230 230
 		}
231 231
 		return $statement;
@@ -246,20 +246,20 @@  discard block
 block discarded – undo
246 246
 	 * @throws \Exception
247 247
 	 */
248 248
 	private function fetchAll(Closure $callback = null, $mode, $arg0 = null) {
249
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) {
249
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) {
250 250
 			$statement->setFetchMode($mode, $arg0);
251 251
 			$data = $statement->fetchAll();
252
-			if($this->preserveTypes) {
252
+			if ($this->preserveTypes) {
253 253
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
254
-				foreach($data as &$row) {
254
+				foreach ($data as &$row) {
255 255
 					$row = FieldValueConverter::convertValues($row, $columnDefinitions);
256 256
 				}
257 257
 			}
258
-			if($callback !== null) {
259
-				return call_user_func(function ($resultData = []) use ($data, $callback) {
260
-					foreach($data as $row) {
258
+			if ($callback !== null) {
259
+				return call_user_func(function($resultData = []) use ($data, $callback) {
260
+					foreach ($data as $row) {
261 261
 						$result = $callback($row);
262
-						if($result !== null && !($result instanceof DBIgnoreRow)) {
262
+						if ($result !== null && !($result instanceof DBIgnoreRow)) {
263 263
 							$resultData[] = $result;
264 264
 						} else {
265 265
 							$resultData[] = $row;
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @return Generator|YieldPolyfillIterator|mixed[]
280 280
 	 */
281 281
 	private function fetchLazy(Closure $callback = null, $mode, $arg0 = null) {
282
-		if(version_compare(PHP_VERSION, '5.5', '<')) {
283
-			return new YieldPolyfillIterator($callback, $this->preserveTypes, function () use ($mode, $arg0) {
282
+		if (version_compare(PHP_VERSION, '5.5', '<')) {
283
+			return new YieldPolyfillIterator($callback, $this->preserveTypes, function() use ($mode, $arg0) {
284 284
 				$statement = $this->createStatement();
285 285
 				$statement->setFetchMode($mode, $arg0);
286 286
 				return $statement;
@@ -301,20 +301,20 @@  discard block
 block discarded – undo
301 301
 	 * @throws \Exception
302 302
 	 */
303 303
 	private function fetch(Closure $callback = null, $mode, $arg0 = null, Closure $resultValidator = null) {
304
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
304
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
305 305
 			$statement->setFetchMode($mode, $arg0);
306 306
 			$row = $statement->fetch();
307 307
 			$result = $resultValidator($row);
308
-			if(!$result['valid']) {
308
+			if (!$result['valid']) {
309 309
 				return $result['default'];
310 310
 			}
311
-			if($this->preserveTypes) {
311
+			if ($this->preserveTypes) {
312 312
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
313 313
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
314 314
 			}
315
-			if($callback !== null) {
315
+			if ($callback !== null) {
316 316
 				$result = $callback($row);
317
-				if($result !== null) {
317
+				if ($result !== null) {
318 318
 					$row = $result;
319 319
 				}
320 320
 			}
Please login to merge, or discard this patch.