@@ -124,7 +124,7 @@ |
||
124 | 124 | * @param DataMapper<TEntity> $mapper |
125 | 125 | * @return null|TEntity|TEntity[] |
126 | 126 | */ |
127 | - public function getResult(DataMapper $mapper): Entity|array|null |
|
127 | + public function getResult(DataMapper $mapper): Entity | array | null |
|
128 | 128 | { |
129 | 129 | $results = $this->loadResults(); |
130 | 130 |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | } |
270 | 270 | }; |
271 | 271 | |
272 | - $linkKey = new ForeignKey(array_map(function ($value) use ($junctionTable) { |
|
272 | + $linkKey = new ForeignKey(array_map(function($value) use ($junctionTable) { |
|
273 | 273 | return 'hidden_' . $junctionTable . $value; |
274 | 274 | }, $this->foreignKey->columns())); |
275 | 275 | |
276 | - $select->join($joinTable, function (Join $join) use ($junctionTable, $joinTable) { |
|
276 | + $select->join($joinTable, function(Join $join) use ($junctionTable, $joinTable) { |
|
277 | 277 | if ($this->junction !== null) { |
278 | 278 | foreach ($this->junction->columns() as $pkColumn => $fkColumn) { |
279 | 279 | $join->on($junctionTable . '.' . $fkColumn, $joinTable . '.' . $pkColumn); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @return TEntity|array<TEntity>|null |
322 | 322 | */ |
323 | - public function getResult(DataMapper $mapper, ?callable $callback = null): Entity|array|null |
|
323 | + public function getResult(DataMapper $mapper, ?callable $callback = null): Entity | array | null |
|
324 | 324 | { |
325 | 325 | $manager = $mapper->getEntityManager(); |
326 | 326 | $owner = $mapper->getEntityMapper(); |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | }; |
387 | 387 | |
388 | - $select->join($joinTable, function (Join $join) use ($junctionTable, $joinTable) { |
|
388 | + $select->join($joinTable, function(Join $join) use ($junctionTable, $joinTable) { |
|
389 | 389 | if ($this->junction !== null) { |
390 | 390 | foreach ($this->junction->columns() as $pkColumn => $fkColumn) { |
391 | 391 | $join->on($junctionTable . '.' . $fkColumn, $joinTable . '.' . $pkColumn); |
@@ -109,5 +109,5 @@ |
||
109 | 109 | abstract public function getResult( |
110 | 110 | DataMapper $mapper, |
111 | 111 | ?callable $callback = null |
112 | - ): Entity|array|null; |
|
112 | + ): Entity | array | null; |
|
113 | 113 | } |
@@ -168,7 +168,7 @@ |
||
168 | 168 | * |
169 | 169 | * @return TEntity|array<TEntity>|null |
170 | 170 | */ |
171 | - public function getResult(DataMapper $mapper, ?callable $callback = null): Entity|array|null |
|
171 | + public function getResult(DataMapper $mapper, ?callable $callback = null): Entity | array | null |
|
172 | 172 | { |
173 | 173 | $manager = $mapper->getEntityManager(); |
174 | 174 | $owner = $mapper->getEntityMapper(); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param bool $immediate |
140 | 140 | * @return $this |
141 | 141 | */ |
142 | - public function with(string|array $value, bool $immediate = false): self |
|
142 | + public function with(string | array $value, bool $immediate = false): self |
|
143 | 143 | { |
144 | 144 | if (!is_array($value)) { |
145 | 145 | $value = [$value]; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param string|Expression|Closure|string[]|Expression[]|Closure[] $columns |
169 | 169 | * @return $this |
170 | 170 | */ |
171 | - public function groupBy(string|Expression|Closure|array $columns): self |
|
171 | + public function groupBy(string | Expression | Closure | array $columns): self |
|
172 | 172 | { |
173 | 173 | if (!is_array($columns)) { |
174 | 174 | $columns = [$columns]; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @param Closure|null $value |
186 | 186 | * @return $this |
187 | 187 | */ |
188 | - public function having(string|Expression|Closure $column, Closure $value = null): self |
|
188 | + public function having(string | Expression | Closure $column, Closure $value = null): self |
|
189 | 189 | { |
190 | 190 | $this->getHavingStatement()->having($column, $value); |
191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param Closure|null $value |
199 | 199 | * @return $this |
200 | 200 | */ |
201 | - public function orHaving(string|Expression|Closure $column, Closure $value = null): self |
|
201 | + public function orHaving(string | Expression | Closure $column, Closure $value = null): self |
|
202 | 202 | { |
203 | 203 | $this->getHavingStatement()->orHaving($column, $value); |
204 | 204 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @return $this |
213 | 213 | */ |
214 | 214 | public function orderBy( |
215 | - string|Closure|Expression|array $columns, |
|
215 | + string | Closure | Expression | array $columns, |
|
216 | 216 | string $order = 'ASC' |
217 | 217 | ): self { |
218 | 218 | if (!is_array($columns)) { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param string|string[]|Expression|Expression[]|Closure|Closure[] $columns |
263 | 263 | * @return void |
264 | 264 | */ |
265 | - protected function select(string|Expression|Closure|array $columns = []): void |
|
265 | + protected function select(string | Expression | Closure | array $columns = []): void |
|
266 | 266 | { |
267 | 267 | $exp = new ColumnExpression($this->getQueryStatement()); |
268 | 268 | if ($columns instanceof Closure) { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param string|array<int, string>|array<string, mixed> $names |
116 | 116 | * @return $this |
117 | 117 | */ |
118 | - public function filter(string|array $names): self |
|
118 | + public function filter(string | array $names): self |
|
119 | 119 | { |
120 | 120 | if (!is_array($names)) { |
121 | 121 | $names = [$names]; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function delete(bool $force = false, array $tables = []): int |
211 | 211 | { |
212 | - return (int) $this->transaction(function (Connection $connection) use ($tables, $force) { |
|
212 | + return (int) $this->transaction(function(Connection $connection) use ($tables, $force) { |
|
213 | 213 | if (!$force && $this->mapper->hasSoftDelete()) { |
214 | 214 | return (new Update($connection, $this->mapper->getTable(), $this->queryStatement)) |
215 | 215 | ->set([ |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function update(array $columns = []): int |
229 | 229 | { |
230 | - return (int) $this->transaction(function (Connection $connection) use ($columns) { |
|
230 | + return (int) $this->transaction(function(Connection $connection) use ($columns) { |
|
231 | 231 | if ($this->mapper->hasTimestamp()) { |
232 | 232 | list(, $updatedAtColumn) = $this->mapper->getTimestampColumns(); |
233 | 233 | $columns[$updatedAtColumn] = date($this->manager->getDateFormat()); |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | * @param mixed $value |
244 | 244 | * @return int |
245 | 245 | */ |
246 | - public function increment(string|array $column, mixed $value = 1): int |
|
246 | + public function increment(string | array $column, mixed $value = 1): int |
|
247 | 247 | { |
248 | - return (int) $this->transaction(function (Connection $connection) use ($column, $value) { |
|
248 | + return (int) $this->transaction(function(Connection $connection) use ($column, $value) { |
|
249 | 249 | if ($this->mapper->hasTimestamp()) { |
250 | 250 | list(, $updatedAtColumn) = $this->mapper->getTimestampColumns(); |
251 | 251 | $this->queryStatement->addUpdateColumns([ |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | * @param mixed $value |
264 | 264 | * @return int |
265 | 265 | */ |
266 | - public function decrement(string|array $column, mixed $value = 1): int |
|
266 | + public function decrement(string | array $column, mixed $value = 1): int |
|
267 | 267 | { |
268 | - return (int) $this->transaction(function (Connection $connection) use ($column, $value) { |
|
268 | + return (int) $this->transaction(function(Connection $connection) use ($column, $value) { |
|
269 | 269 | if ($this->mapper->hasTimestamp()) { |
270 | 270 | list(, $updatedAtColumn) = $this->mapper->getTimestampColumns(); |
271 | 271 | $this->queryStatement->addUpdateColumns([ |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * |
284 | 284 | * @return TEntity|null |
285 | 285 | */ |
286 | - public function find(string|int|float|array $id): ?Entity |
|
286 | + public function find(string | int | float | array $id): ?Entity |
|
287 | 287 | { |
288 | 288 | if (is_array($id)) { |
289 | 289 | foreach ($id as $pkColumn => $pkValue) { |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @param string|Expression|Closure $column |
332 | 332 | * @return mixed |
333 | 333 | */ |
334 | - public function column(string|Expression|Closure $column): mixed |
|
334 | + public function column(string | Expression | Closure $column): mixed |
|
335 | 335 | { |
336 | 336 | (new ColumnExpression($this->queryStatement))->column($column); |
337 | 337 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | * @return mixed |
346 | 346 | */ |
347 | 347 | public function count( |
348 | - string|Expression|Closure $column = '*', |
|
348 | + string | Expression | Closure $column = '*', |
|
349 | 349 | bool $distinct = false |
350 | 350 | ): mixed { |
351 | 351 | (new ColumnExpression($this->queryStatement))->count($column, null, $distinct); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return mixed |
361 | 361 | */ |
362 | 362 | public function avg( |
363 | - string|Expression|Closure $column, |
|
363 | + string | Expression | Closure $column, |
|
364 | 364 | bool $distinct = false |
365 | 365 | ): mixed { |
366 | 366 | (new ColumnExpression($this->queryStatement))->avg($column, null, $distinct); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @return mixed |
376 | 376 | */ |
377 | 377 | public function sum( |
378 | - string|Expression|Closure $column, |
|
378 | + string | Expression | Closure $column, |
|
379 | 379 | bool $distinct = false |
380 | 380 | ): mixed { |
381 | 381 | (new ColumnExpression($this->queryStatement))->sum($column, null, $distinct); |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @param bool $distinct |
390 | 390 | * @return mixed |
391 | 391 | */ |
392 | - public function min(string|Expression|Closure $column, bool $distinct = false): mixed |
|
392 | + public function min(string | Expression | Closure $column, bool $distinct = false): mixed |
|
393 | 393 | { |
394 | 394 | (new ColumnExpression($this->queryStatement))->min($column, null, $distinct); |
395 | 395 | |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @return mixed |
404 | 404 | */ |
405 | 405 | public function max( |
406 | - string|Expression|Closure $column, |
|
406 | + string | Expression | Closure $column, |
|
407 | 407 | bool $distinct = false |
408 | 408 | ): mixed { |
409 | 409 | (new ColumnExpression($this->queryStatement))->max($column, null, $distinct); |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | * @param array<int, mixed>|false $results |
470 | 470 | * @return array<string, \Platine\Orm\Relation\RelationLoader<TEntity>> |
471 | 471 | */ |
472 | - protected function getRelationLoaders(array|false $results): array |
|
472 | + protected function getRelationLoaders(array | false $results): array |
|
473 | 473 | { |
474 | 474 | if (empty($this->with) || empty($results)) { |
475 | 475 | return []; |
@@ -320,7 +320,7 @@ |
||
320 | 320 | public function relation(string $name): RelationFactory |
321 | 321 | { |
322 | 322 | /** @var RelationFactory<TEntity> $factory */ |
323 | - $factory = new RelationFactory($name, function ($name, Relation $relation) { |
|
323 | + $factory = new RelationFactory($name, function($name, Relation $relation) { |
|
324 | 324 | return $this->relations[$name] = $relation; |
325 | 325 | }); |
326 | 326 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param bool $immediate |
64 | 64 | * @return EntityQuery<TEntity> |
65 | 65 | */ |
66 | - public function query(string|array $with = [], bool $immediate = false): EntityQuery; |
|
66 | + public function query(string | array $with = [], bool $immediate = false): EntityQuery; |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Load with relation |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param bool $immediate |
72 | 72 | * @return self<TEntity> |
73 | 73 | */ |
74 | - public function with(string|array $with, bool $immediate = false): self; |
|
74 | + public function with(string | array $with, bool $immediate = false): self; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Set order |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return self<TEntity> |
81 | 81 | */ |
82 | 82 | public function orderBy( |
83 | - string|Closure|Expression|array $columns, |
|
83 | + string | Closure | Expression | array $columns, |
|
84 | 84 | string $order = 'ASC' |
85 | 85 | ): self; |
86 | 86 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param string|array<string, mixed> $filters |
98 | 98 | * @return self<TEntity> |
99 | 99 | */ |
100 | - public function filters(string|array $filters = []): self; |
|
100 | + public function filters(string | array $filters = []): self; |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Create the instance of Entity |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | * @param TEntity $entity |
112 | 112 | * @return array<mixed>|string|int|float|bool|null |
113 | 113 | */ |
114 | - public function save(Entity $entity): array|string|int|float|bool|null; |
|
114 | + public function save(Entity $entity): array | string | int | float | bool | null; |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * Save the new entity in data store |
118 | 118 | * @param TEntity $entity |
119 | 119 | * @return array<mixed>|string|int|float|false|null the primary key(s) value(s) |
120 | 120 | */ |
121 | - public function insert(Entity $entity): array|string|int|float|false|null; |
|
121 | + public function insert(Entity $entity): array | string | int | float | false | null; |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Update the existing entity in data store |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return TEntity|null |
150 | 150 | */ |
151 | - public function find(array|string|int|float $id): ?Entity; |
|
151 | + public function find(array | string | int | float $id): ?Entity; |
|
152 | 152 | |
153 | 153 | /** |
154 | 154 | * Find one entity instance using some conditions |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * The order by column(s) |
84 | 84 | * @var string|Closure|Expression|string[]|Expression[]|Closure[] |
85 | 85 | */ |
86 | - protected string|Closure|Expression|array $orderColumns = ''; |
|
86 | + protected string | Closure | Expression | array $orderColumns = ''; |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * The order direction |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * {@inheritedoc} |
125 | 125 | */ |
126 | - public function query(string|array $with = [], bool $immediate = false): EntityQuery |
|
126 | + public function query(string | array $with = [], bool $immediate = false): EntityQuery |
|
127 | 127 | { |
128 | 128 | if (is_string($with)) { |
129 | 129 | $with = [$with]; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * {@inheritedoc} |
165 | 165 | * @return self<TEntity> |
166 | 166 | */ |
167 | - public function with(string|array $with, bool $immediate = false): self |
|
167 | + public function with(string | array $with, bool $immediate = false): self |
|
168 | 168 | { |
169 | 169 | if (!is_array($with)) { |
170 | 170 | $with = [$with]; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @return self<TEntity> |
181 | 181 | */ |
182 | 182 | public function orderBy( |
183 | - string|Closure|Expression|array $columns, |
|
183 | + string | Closure | Expression | array $columns, |
|
184 | 184 | string $order = 'ASC' |
185 | 185 | ): self { |
186 | 186 | $this->orderColumns = $columns; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * {@inheritedoc} |
206 | 206 | * @return self<TEntity> |
207 | 207 | */ |
208 | - public function filters(string|array $filters = []): self |
|
208 | + public function filters(string | array $filters = []): self |
|
209 | 209 | { |
210 | 210 | if (is_string($filters)) { |
211 | 211 | $filters = [$filters => true]; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | /** |
245 | 245 | * {@inheritedoc} |
246 | 246 | */ |
247 | - public function find(array|string|int|float $id): ?Entity |
|
247 | + public function find(array | string | int | float $id): ?Entity |
|
248 | 248 | { |
249 | 249 | return $this->query()->find($id); |
250 | 250 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | /** |
285 | 285 | * {@inheritedoc} |
286 | 286 | */ |
287 | - public function save(Entity $entity): array|string|int|float|bool|null |
|
287 | + public function save(Entity $entity): array | string | int | float | bool | null |
|
288 | 288 | { |
289 | 289 | $data = Proxy::instance()->getEntityDataMapper($entity); |
290 | 290 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | /** |
299 | 299 | * {@inheritedoc} |
300 | 300 | */ |
301 | - public function insert(Entity $entity): array|string|int|float|false|null |
|
301 | + public function insert(Entity $entity): array | string | int | float | false | null |
|
302 | 302 | { |
303 | 303 | $data = Proxy::instance()->getEntityDataMapper($entity); |
304 | 304 | $mapper = $data->getEntityMapper(); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | $connection = $this->manager->getConnection(); |
316 | - $id = $connection->transaction(function (Connection $connection) use ($data, $mapper) { |
|
316 | + $id = $connection->transaction(function(Connection $connection) use ($data, $mapper) { |
|
317 | 317 | $columns = $data->getRawColumns(); |
318 | 318 | $pkGenerator = $mapper->getPrimaryKeyGenerator(); |
319 | 319 | if ($pkGenerator !== null) { |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | $modified = $data->getModifiedColumns(); |
384 | 384 | if (!empty($modified)) { |
385 | 385 | $connection = $this->manager->getConnection(); |
386 | - $result = $connection->transaction(function (Connection $connection) use ($data, $mapper, $modified) { |
|
386 | + $result = $connection->transaction(function(Connection $connection) use ($data, $mapper, $modified) { |
|
387 | 387 | $columns = array_intersect_key($data->getRawColumns(), array_flip($modified)); |
388 | 388 | |
389 | 389 | $updatedAt = null; |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | $connection = $this->manager->getConnection(); |
423 | - return $connection->transaction(function (Connection $connection) use ($data) { |
|
423 | + return $connection->transaction(function(Connection $connection) use ($data) { |
|
424 | 424 | $data->executePendingLinkage(); |
425 | 425 | |
426 | 426 | return true; |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | $eventsHandlers = $mapper->getEventHandlers(); |
438 | 438 | $connection = $this->manager->getConnection(); |
439 | 439 | |
440 | - $result = $connection->transaction(function () use ($data, $mapper, $force) { |
|
440 | + $result = $connection->transaction(function() use ($data, $mapper, $force) { |
|
441 | 441 | if ($data->isDeleted()) { |
442 | 442 | throw new EntityStateException('The record was deleted'); |
443 | 443 | } |