@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | $new = ''; |
| 13 | 13 | $par = array_values($par); |
| 14 | 14 | if (substr_count($sql, '?') === 2 && !is_array($par[0])) { |
| 15 | - $par = [ $par ]; |
|
| 15 | + $par = [$par]; |
|
| 16 | 16 | } |
| 17 | 17 | $parts = explode('??', $sql); |
| 18 | 18 | $index = 0; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $index += count($tmp) - 1; |
| 23 | 23 | if (isset($par[$index])) { |
| 24 | 24 | if (!is_array($par[$index])) { |
| 25 | - $par[$index] = [ $par[$index] ]; |
|
| 25 | + $par[$index] = [$par[$index]]; |
|
| 26 | 26 | } |
| 27 | 27 | $params = $par[$index]; |
| 28 | 28 | array_splice($par, $index, 1, $params); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $new .= implode(',', array_fill(0, count($params), '?')); |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | - return [ $new, $par ]; |
|
| 33 | + return [$new, $par]; |
|
| 34 | 34 | } |
| 35 | 35 | /** |
| 36 | 36 | * Run a query (prepare & execute). |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | $this->connect(); |
| 53 | 53 | $statement = \ibase_prepare($this->transaction !== null ? $this->transaction : $this->lnk, $sql); |
| 54 | 54 | if ($statement === false) { |
| 55 | - throw new DBException('Prepare error: ' . \ibase_errmsg()); |
|
| 55 | + throw new DBException('Prepare error: '.\ibase_errmsg()); |
|
| 56 | 56 | } |
| 57 | 57 | return new Statement( |
| 58 | 58 | $statement, |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | } |
| 56 | 56 | public function next() |
| 57 | 57 | { |
| 58 | - $this->fetched ++; |
|
| 58 | + $this->fetched++; |
|
| 59 | 59 | $this->last = $this->statement->fetch(\PDO::FETCH_ASSOC); |
| 60 | 60 | } |
| 61 | 61 | public function valid() |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | isset($this->connection['opts']) ? $this->connection['opts'] : [] |
| 45 | 45 | ); |
| 46 | 46 | } catch (\PDOException $e) { |
| 47 | - throw new DBException('Connect error: ' . $e->getMessage()); |
|
| 47 | + throw new DBException('Connect error: '.$e->getMessage()); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | $instance->setLength($data['length']); |
| 52 | 52 | } |
| 53 | 53 | if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) { |
| 54 | - $temp = array_map(function ($v) { |
|
| 54 | + $temp = array_map(function($v) { |
|
| 55 | 55 | return str_replace("''", "'", $v); |
| 56 | 56 | }, explode("','", substr($instance->getType(), 6, -2))); |
| 57 | 57 | $instance->setValues($temp); |
@@ -24,28 +24,28 @@ |
||
| 24 | 24 | foreach ($data as $i => $v) { |
| 25 | 25 | switch (gettype($v)) { |
| 26 | 26 | case 'boolean': |
| 27 | - $this->statement->bindValue($i+1, $v, \PDO::PARAM_BOOL); |
|
| 27 | + $this->statement->bindValue($i + 1, $v, \PDO::PARAM_BOOL); |
|
| 28 | 28 | break; |
| 29 | 29 | case 'integer': |
| 30 | - $this->statement->bindValue($i+1, $v, \PDO::PARAM_INT); |
|
| 30 | + $this->statement->bindValue($i + 1, $v, \PDO::PARAM_INT); |
|
| 31 | 31 | break; |
| 32 | 32 | case 'NULL': |
| 33 | - $this->statement->bindValue($i+1, $v, \PDO::PARAM_NULL); |
|
| 33 | + $this->statement->bindValue($i + 1, $v, \PDO::PARAM_NULL); |
|
| 34 | 34 | break; |
| 35 | 35 | case 'double': |
| 36 | - $this->statement->bindValue($i+1, $v); |
|
| 36 | + $this->statement->bindValue($i + 1, $v); |
|
| 37 | 37 | break; |
| 38 | 38 | default: |
| 39 | 39 | // keep in mind oracle needs a transaction when inserting LOBs, aside from the specific syntax: |
| 40 | 40 | // INSERT INTO table (column, lobcolumn) VALUES (?, ?, EMPTY_BLOB()) RETURNING lobcolumn INTO ? |
| 41 | 41 | if (is_resource($v) && get_resource_type($v) === 'stream') { |
| 42 | - $this->statement->bindParam($i+1, $v, \PDO::PARAM_LOB); |
|
| 42 | + $this->statement->bindParam($i + 1, $v, \PDO::PARAM_LOB); |
|
| 43 | 43 | break; |
| 44 | 44 | } |
| 45 | 45 | if (!is_string($data[$i])) { |
| 46 | 46 | $data[$i] = serialize($data[$i]); |
| 47 | 47 | } |
| 48 | - $this->statement->bindValue($i+1, $v); |
|
| 48 | + $this->statement->bindValue($i + 1, $v); |
|
| 49 | 49 | break; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -47,8 +47,7 @@ |
||
| 47 | 47 | if (isset($this->definition->getRelations()[$method])) { |
| 48 | 48 | if (array_key_exists($method, $this->fetched)) { |
| 49 | 49 | return is_callable($this->fetched[$method]) ? |
| 50 | - $this->fetched[$method] = call_user_func($this->fetched[$method], $args[0] ?? null) : |
|
| 51 | - $this->fetched[$method]; |
|
| 50 | + $this->fetched[$method] = call_user_func($this->fetched[$method], $args[0] ?? null) : $this->fetched[$method]; |
|
| 52 | 51 | } |
| 53 | 52 | } |
| 54 | 53 | return null; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $connection['pass'] = isset($temp['pass']) && strlen($temp['pass']) ? $temp['pass'] : null; |
| 75 | 75 | $connection['host'] = isset($temp['host']) && strlen($temp['host']) ? $temp['host'] : null; |
| 76 | 76 | $connection['name'] = isset($temp['path']) && strlen($temp['path']) ? trim($temp['path'], '/') : null; |
| 77 | - $connection['port'] = isset($temp['port']) && (int)$temp['port'] ? (int)$temp['port'] : null; |
|
| 77 | + $connection['port'] = isset($temp['port']) && (int) $temp['port'] ? (int) $temp['port'] : null; |
|
| 78 | 78 | if (isset($temp['query']) && strlen($temp['query'])) { |
| 79 | 79 | parse_str($temp['query'], $connection['opts']); |
| 80 | 80 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $new = ''; |
| 118 | 118 | $par = array_values($par); |
| 119 | 119 | if (substr_count($sql, '?') === 2 && !is_array($par[0])) { |
| 120 | - $par = [ $par ]; |
|
| 120 | + $par = [$par]; |
|
| 121 | 121 | } |
| 122 | 122 | $parts = explode('??', $sql); |
| 123 | 123 | $index = 0; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $index += count($tmp) - 1; |
| 128 | 128 | if (isset($par[$index])) { |
| 129 | 129 | if (!is_array($par[$index])) { |
| 130 | - $par[$index] = [ $par[$index] ]; |
|
| 130 | + $par[$index] = [$par[$index]]; |
|
| 131 | 131 | } |
| 132 | 132 | $params = $par[$index]; |
| 133 | 133 | array_splice($par, $index, 1, $params); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $new .= implode(',', array_fill(0, count($params), '?')); |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | - return [ $new, $par ]; |
|
| 138 | + return [$new, $par]; |
|
| 139 | 139 | } |
| 140 | 140 | /** |
| 141 | 141 | * Run a query (prepare & execute). |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | ): Collection { |
| 185 | 185 | $coll = Collection::from($this->query($sql, $par, $buff)); |
| 186 | 186 | if (($keys = $this->driver->option('mode')) && in_array($keys, ['strtoupper', 'strtolower'])) { |
| 187 | - $coll->map(function ($v) use ($keys) { |
|
| 187 | + $coll->map(function($v) use ($keys) { |
|
| 188 | 188 | $new = []; |
| 189 | 189 | foreach ($v as $k => $vv) { |
| 190 | 190 | $new[call_user_func($keys, $k)] = $vv; |
@@ -193,18 +193,18 @@ discard block |
||
| 193 | 193 | }); |
| 194 | 194 | } |
| 195 | 195 | if ($key !== null) { |
| 196 | - $coll->mapKey(function ($v) use ($key) { |
|
| 196 | + $coll->mapKey(function($v) use ($key) { |
|
| 197 | 197 | return $v[$key]; |
| 198 | 198 | }); |
| 199 | 199 | } |
| 200 | 200 | if ($skip) { |
| 201 | - $coll->map(function ($v) use ($key) { |
|
| 201 | + $coll->map(function($v) use ($key) { |
|
| 202 | 202 | unset($v[$key]); |
| 203 | 203 | return $v; |
| 204 | 204 | }); |
| 205 | 205 | } |
| 206 | 206 | if ($opti) { |
| 207 | - $coll->map(function ($v) { |
|
| 207 | + $coll->map(function($v) { |
|
| 208 | 208 | return count($v) === 1 ? current($v) : $v; |
| 209 | 209 | }); |
| 210 | 210 | } |
@@ -299,8 +299,7 @@ discard block |
||
| 299 | 299 | public function definition(string $table, bool $detectRelations = true) : Table |
| 300 | 300 | { |
| 301 | 301 | return isset($this->tables[$table]) ? |
| 302 | - $this->tables[$table] : |
|
| 303 | - $this->driver->table($table, $detectRelations); |
|
| 302 | + $this->tables[$table] : $this->driver->table($table, $detectRelations); |
|
| 304 | 303 | } |
| 305 | 304 | /** |
| 306 | 305 | * Parse all tables from the database. |
@@ -317,13 +316,13 @@ discard block |
||
| 317 | 316 | */ |
| 318 | 317 | public function getSchema($asPlainArray = true) |
| 319 | 318 | { |
| 320 | - return !$asPlainArray ? $this->tables : array_map(function ($table) { |
|
| 319 | + return !$asPlainArray ? $this->tables : array_map(function($table) { |
|
| 321 | 320 | return [ |
| 322 | 321 | 'name' => $table->getName(), |
| 323 | 322 | 'schema' => $table->getSchema(), |
| 324 | 323 | 'pkey' => $table->getPrimaryKey(), |
| 325 | 324 | 'comment' => $table->getComment(), |
| 326 | - 'columns' => array_map(function ($column) { |
|
| 325 | + 'columns' => array_map(function($column) { |
|
| 327 | 326 | return [ |
| 328 | 327 | 'name' => $column->getName(), |
| 329 | 328 | 'type' => $column->getType(), |
@@ -334,9 +333,9 @@ discard block |
||
| 334 | 333 | 'nullable' => $column->isNullable() |
| 335 | 334 | ]; |
| 336 | 335 | }, $table->getFullColumns()), |
| 337 | - 'relations' => array_map(function ($rel) { |
|
| 336 | + 'relations' => array_map(function($rel) { |
|
| 338 | 337 | $relation = clone $rel; |
| 339 | - $relation = (array)$relation; |
|
| 338 | + $relation = (array) $relation; |
|
| 340 | 339 | $relation['table'] = $rel->table->getName(); |
| 341 | 340 | if ($rel->pivot) { |
| 342 | 341 | $relation['pivot'] = $rel->pivot->getName(); |
@@ -389,8 +388,7 @@ discard block |
||
| 389 | 388 | public function table(string $table, bool $mapped = false) |
| 390 | 389 | { |
| 391 | 390 | return $mapped ? |
| 392 | - new TableQueryMapped($this, $this->definition($table)) : |
|
| 393 | - new TableQuery($this, $this->definition($table)); |
|
| 391 | + new TableQueryMapped($this, $this->definition($table)) : new TableQuery($this, $this->definition($table)); |
|
| 394 | 392 | } |
| 395 | 393 | public function __call($method, $args) |
| 396 | 394 | { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function collection(TableQueryIterator $iterator, Table $definition) : Collection |
| 53 | 53 | { |
| 54 | 54 | return Collection::from($iterator) |
| 55 | - ->map(function ($v) use ($definition) { |
|
| 55 | + ->map(function($v) use ($definition) { |
|
| 56 | 56 | return $this->entity($definition, $v); |
| 57 | 57 | }); |
| 58 | 58 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $definition = $entity->definition(); |
| 128 | 128 | foreach ($definition->getColumns() as $column) { |
| 129 | 129 | if (!array_key_exists($column, $data)) { |
| 130 | - $entity->__lazyProperty($column, function () use ($definition, $primary, $column) { |
|
| 130 | + $entity->__lazyProperty($column, function() use ($definition, $primary, $column) { |
|
| 131 | 131 | $query = $this->db->table($definition->getFullName()); |
| 132 | 132 | foreach ($primary as $k => $v) { |
| 133 | 133 | $query->filter($k, $v); |
@@ -141,12 +141,12 @@ discard block |
||
| 141 | 141 | $name, |
| 142 | 142 | array_key_exists($name, $data) && isset($data[$name]) ? |
| 143 | 143 | ($relation->many ? |
| 144 | - array_map(function ($v) use ($relation) { |
|
| 144 | + array_map(function($v) use ($relation) { |
|
| 145 | 145 | return $this->entity($relation->table, $v); |
| 146 | 146 | }, $data[$name]) : |
| 147 | 147 | $this->entity($relation->table, $data[$name]) |
| 148 | 148 | ) : |
| 149 | - function (array $columns = null) use ($entity, $definition, $relation, $data) { |
|
| 149 | + function(array $columns = null) use ($entity, $definition, $relation, $data) { |
|
| 150 | 150 | $query = $this->db->table($relation->table->getFullName(), true); |
| 151 | 151 | if ($columns !== null) { |
| 152 | 152 | $query->columns($columns); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | ); |
| 173 | 173 | } |
| 174 | 174 | foreach ($definition->getPrimaryKey() as $v) { |
| 175 | - $query->filter($nm . '.' . $v, $data[$v] ?? null); |
|
| 175 | + $query->filter($nm.'.'.$v, $data[$v] ?? null); |
|
| 176 | 176 | } |
| 177 | 177 | } else { |
| 178 | 178 | foreach ($relation->keymap as $k => $v) { |
@@ -180,8 +180,7 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | return $relation->many ? |
| 183 | - $query->iterator() : |
|
| 184 | - $query[0]; |
|
| 183 | + $query->iterator() : $query[0]; |
|
| 185 | 184 | } |
| 186 | 185 | ); |
| 187 | 186 | } |