@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * Select the first non-empty value from an array. |
| 69 | 69 | * |
| 70 | - * @param array $keys An array of keys to try. |
|
| 70 | + * @param string[] $keys An array of keys to try. |
|
| 71 | 71 | * @param array $array The array to select from. |
| 72 | 72 | * @param mixed $default The default value if non of the keys exist. |
| 73 | 73 | * @return mixed Returns the first non-empty value of {@link $default} if none are found. |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @param array &$data The data to validate. |
| 413 | 413 | * @param Validation &$validation This argument will be filled with the validation result. |
| 414 | - * @return bool Returns true if the data is valid, false otherwise. |
|
| 414 | + * @return Schema Returns true if the data is valid, false otherwise. |
|
| 415 | 415 | * @throws ValidationException Throws an exception when the data does not validate against the schema. |
| 416 | 416 | */ |
| 417 | 417 | public function validate(array &$data, Validation &$validation = null) { |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param string $path The path to current parameters for nested objects. |
| 155 | 155 | * @return Schema Returns the current instance for fluent calls. |
| 156 | 156 | */ |
| 157 | - protected function filterData(array &$data, array $schema, Validation &$validation, $path = '') { |
|
| 157 | + protected function filterData(array &$data, array $schema, Validation & $validation, $path = '') { |
|
| 158 | 158 | foreach ($data as $key => $val) { |
| 159 | 159 | if (array_key_exists($key, $schema)) { |
| 160 | 160 | continue; |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | * @return Schema Returns `$this` for fluent calls. |
| 356 | 356 | */ |
| 357 | 357 | public function requireOneOf(array $fieldnames, $count = 1) { |
| 358 | - $result = $this->addValidator('*', function ($data, Validation $validation) use ($fieldnames, $count) { |
|
| 358 | + $result = $this->addValidator('*', function($data, Validation $validation) use ($fieldnames, $count) { |
|
| 359 | 359 | $hasCount = 0; |
| 360 | 360 | $flattened = []; |
| 361 | 361 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - $messageFields = array_map(function ($v) { |
|
| 387 | + $messageFields = array_map(function($v) { |
|
| 388 | 388 | if (is_array($v)) { |
| 389 | 389 | return '('.implode(', ', $v).')'; |
| 390 | 390 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | * @return bool Returns true if the data is valid, false otherwise. |
| 415 | 415 | * @throws ValidationException Throws an exception when the data does not validate against the schema. |
| 416 | 416 | */ |
| 417 | - public function validate(array &$data, Validation &$validation = null) { |
|
| 417 | + public function validate(array &$data, Validation & $validation = null) { |
|
| 418 | 418 | if (!$this->isValidInternal($data, $this->schema, $validation, '')) { |
| 419 | 419 | if ($validation === null) { |
| 420 | 420 | // Although this should never be null, scrutinizer complains that it might be. |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * @param Validation &$validation This argument will be filled with the validation result. |
| 434 | 434 | * @return bool Returns true if the data is valid. False otherwise. |
| 435 | 435 | */ |
| 436 | - public function isValid(array &$data, Validation &$validation = null) { |
|
| 436 | + public function isValid(array &$data, Validation & $validation = null) { |
|
| 437 | 437 | return $this->isValidInternal($data, $this->schema, $validation, ''); |
| 438 | 438 | } |
| 439 | 439 | |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | * @param string $path The path to the current path for nested objects. |
| 447 | 447 | * @return bool Returns true if the data is valid. False otherwise. |
| 448 | 448 | */ |
| 449 | - protected function isValidInternal(array &$data, array $schema, Validation &$validation = null, $path = '') { |
|
| 449 | + protected function isValidInternal(array &$data, array $schema, Validation & $validation = null, $path = '') { |
|
| 450 | 450 | if ($validation === null) { |
| 451 | 451 | $validation = new Validation(); |
| 452 | 452 | } |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | } else { |
| 684 | 684 | $bools = [ |
| 685 | 685 | '0' => false, 'false' => false, 'no' => false, 'off' => false, |
| 686 | - '1' => true, 'true' => true, 'yes' => true, 'on' => true |
|
| 686 | + '1' => true, 'true' => true, 'yes' => true, 'on' => true |
|
| 687 | 687 | ]; |
| 688 | 688 | if ((is_string($value) || is_numeric($value)) && isset($bools[$value])) { |
| 689 | 689 | $value = $bools[$value]; |
@@ -177,7 +177,7 @@ |
||
| 177 | 177 | /** |
| 178 | 178 | * Get the defaultOrder. |
| 179 | 179 | * |
| 180 | - * @return array Returns the defaultOrder. |
|
| 180 | + * @return string[] Returns the defaultOrder. |
|
| 181 | 181 | */ |
| 182 | 182 | public function getDefaultOrder() { |
| 183 | 183 | return $this->defaultOrder; |
@@ -594,7 +594,7 @@ |
||
| 594 | 594 | /** |
| 595 | 595 | * Build a sql update statement. |
| 596 | 596 | * |
| 597 | - * @param string|Literal $tableName The name of the table to update. |
|
| 597 | + * @param string $tableName The name of the table to update. |
|
| 598 | 598 | * @param array $set An array of columns to set. |
| 599 | 599 | * @param array $where The where filter. |
| 600 | 600 | * @param array $options Additional options for the query. |
@@ -41,6 +41,9 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | private $calculator; |
| 43 | 43 | |
| 44 | + /** |
|
| 45 | + * @param string $table |
|
| 46 | + */ |
|
| 44 | 47 | public function __construct($table, $where, Db $db) { |
| 45 | 48 | $this->table = $table; |
| 46 | 49 | $this->where = $where; |
@@ -141,6 +144,9 @@ discard block |
||
| 141 | 144 | return $this; |
| 142 | 145 | } |
| 143 | 146 | |
| 147 | + /** |
|
| 148 | + * @param string $name |
|
| 149 | + */ |
|
| 144 | 150 | protected function getOption($name, $default = null) { |
| 145 | 151 | return isset($this->options[$name]) ? $this->options[$name] : $default; |
| 146 | 152 | } |
@@ -181,7 +187,7 @@ discard block |
||
| 181 | 187 | /** |
| 182 | 188 | * Set the calculator. |
| 183 | 189 | * |
| 184 | - * @param callable|null $calculator |
|
| 190 | + * @param callable $calculator |
|
| 185 | 191 | * @return $this |
| 186 | 192 | */ |
| 187 | 193 | public function setCalculator(callable $calculator) { |
@@ -152,7 +152,7 @@ |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | if ($type === Db::INDEX_PK || array_diff($index['columns'], $columns) == []) { |
| 155 | - $currentIndex =& $this->indexes[$i]; |
|
| 155 | + $currentIndex = & $this->indexes[$i]; |
|
| 156 | 156 | break; |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $this->px = $px; |
| 139 | 139 | |
| 140 | 140 | $fetchMode = $this->pdo->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); |
| 141 | - $this->setDefaultFetchMode($fetchMode === PDO::FETCH_BOTH ? PDO::FETCH_ASSOC: $fetchMode); |
|
| 141 | + $this->setDefaultFetchMode($fetchMode === PDO::FETCH_BOTH ? PDO::FETCH_ASSOC : $fetchMode); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | |
| 370 | 370 | if (!empty($row['enum'])) { |
| 371 | 371 | $enum = explode(',', $brackets); |
| 372 | - $schema['enum'] = array_map(function ($str) { |
|
| 372 | + $schema['enum'] = array_map(function($str) { |
|
| 373 | 373 | return trim($str, "'\" \t\n\r\0\x0B"); |
| 374 | 374 | }, $enum); |
| 375 | 375 | } |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | } |
| 400 | 400 | $dbtype .= ')'; |
| 401 | 401 | } elseif (!empty($typeDef['enum'])) { |
| 402 | - $parts = array_map(function ($str) { |
|
| 402 | + $parts = array_map(function($str) { |
|
| 403 | 403 | return "'{$str}'"; |
| 404 | 404 | }, $typeDef['enum']); |
| 405 | 405 | $dbtype .= '('.implode(',', $parts).')'; |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | $newColumns = (array)$tableDef['columns']; |
| 450 | 450 | |
| 451 | 451 | $alterDef['add']['columns'] = array_diff_key($newColumns, $curColumns); |
| 452 | - $alterDef['alter']['columns'] = array_uintersect_assoc($newColumns, $curColumns, function ($new, $curr) { |
|
| 452 | + $alterDef['alter']['columns'] = array_uintersect_assoc($newColumns, $curColumns, function($new, $curr) { |
|
| 453 | 453 | $search = ['dbtype', 'allowNull', 'default']; |
| 454 | 454 | foreach ($search as $key) { |
| 455 | 455 | if (self::val($key, $curr) !== self::val($key, $new)) { |
@@ -445,7 +445,7 @@ |
||
| 445 | 445 | )->fetchAll(PDO::FETCH_COLUMN); |
| 446 | 446 | |
| 447 | 447 | // Remove internal tables. |
| 448 | - $tables = array_filter($tables, function ($name) { |
|
| 448 | + $tables = array_filter($tables, function($name) { |
|
| 449 | 449 | return substr($name, 0, 7) !== 'sqlite_'; |
| 450 | 450 | }); |
| 451 | 451 | |