@@ -259,7 +259,7 @@ |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | $primaryKey = $this->mapper->getPrimaryKey(); |
| 262 | - if ($name === (string)$primaryKey) { |
|
| 262 | + if ($name === (string) $primaryKey) { |
|
| 263 | 263 | return $this->columns[$name] = $value; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -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(); |
@@ -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 |
| 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 $this |
| 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 $this |
| 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 $this |
| 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]; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | /** |
| 164 | 164 | * {@inheritedoc} |
| 165 | 165 | */ |
| 166 | - public function with(string|array $with, bool $immediate = false): self |
|
| 166 | + public function with(string | array $with, bool $immediate = false): self |
|
| 167 | 167 | { |
| 168 | 168 | if (!is_array($with)) { |
| 169 | 169 | $with = [$with]; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * {@inheritedoc} |
| 179 | 179 | */ |
| 180 | 180 | public function orderBy( |
| 181 | - string|Closure|Expression|array $columns, |
|
| 181 | + string | Closure | Expression | array $columns, |
|
| 182 | 182 | string $order = 'ASC' |
| 183 | 183 | ): self { |
| 184 | 184 | $this->orderColumns = $columns; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | /** |
| 202 | 202 | * {@inheritedoc} |
| 203 | 203 | */ |
| 204 | - public function filters(string|array $filters = []): self |
|
| 204 | + public function filters(string | array $filters = []): self |
|
| 205 | 205 | { |
| 206 | 206 | if (is_string($filters)) { |
| 207 | 207 | $filters = [$filters => true]; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * {@inheritedoc} |
| 243 | 243 | * @return TEntity|null |
| 244 | 244 | */ |
| 245 | - public function find(array|string|int|float $id): ?Entity |
|
| 245 | + public function find(array | string | int | float $id): ?Entity |
|
| 246 | 246 | { |
| 247 | 247 | return $this->query()->find($id); |
| 248 | 248 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | /** |
| 283 | 283 | * {@inheritedoc} |
| 284 | 284 | */ |
| 285 | - public function save(Entity $entity): array|string|int|float|bool|null |
|
| 285 | + public function save(Entity $entity): array | string | int | float | bool | null |
|
| 286 | 286 | { |
| 287 | 287 | $data = Proxy::instance()->getEntityDataMapper($entity); |
| 288 | 288 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | /** |
| 297 | 297 | * {@inheritedoc} |
| 298 | 298 | */ |
| 299 | - public function insert(Entity $entity): array|string|int|float|false|null |
|
| 299 | + public function insert(Entity $entity): array | string | int | float | false | null |
|
| 300 | 300 | { |
| 301 | 301 | $data = Proxy::instance()->getEntityDataMapper($entity); |
| 302 | 302 | $mapper = $data->getEntityMapper(); |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | $connection = $this->manager->getConnection(); |
| 314 | - $id = $connection->transaction(function (Connection $connection) use ($data, $mapper) { |
|
| 314 | + $id = $connection->transaction(function(Connection $connection) use ($data, $mapper) { |
|
| 315 | 315 | $columns = $data->getRawColumns(); |
| 316 | 316 | $pkGenerator = $mapper->getPrimaryKeyGenerator(); |
| 317 | 317 | if ($pkGenerator !== null) { |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | $modified = $data->getModifiedColumns(); |
| 382 | 382 | if (!empty($modified)) { |
| 383 | 383 | $connection = $this->manager->getConnection(); |
| 384 | - $result = $connection->transaction(function (Connection $connection) use ($data, $mapper, $modified) { |
|
| 384 | + $result = $connection->transaction(function(Connection $connection) use ($data, $mapper, $modified) { |
|
| 385 | 385 | $columns = array_intersect_key($data->getRawColumns(), array_flip($modified)); |
| 386 | 386 | |
| 387 | 387 | $updatedAt = null; |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | $connection = $this->manager->getConnection(); |
| 421 | - return $connection->transaction(function (Connection $connection) use ($data) { |
|
| 421 | + return $connection->transaction(function(Connection $connection) use ($data) { |
|
| 422 | 422 | $data->executePendingLinkage(); |
| 423 | 423 | |
| 424 | 424 | return true; |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $eventsHandlers = $mapper->getEventHandlers(); |
| 436 | 436 | $connection = $this->manager->getConnection(); |
| 437 | 437 | |
| 438 | - $result = $connection->transaction(function () use ($data, $mapper, $force) { |
|
| 438 | + $result = $connection->transaction(function() use ($data, $mapper, $force) { |
|
| 439 | 439 | if ($data->isDeleted()) { |
| 440 | 440 | throw new EntityStateException('The record was deleted'); |
| 441 | 441 | } |