@@ -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 |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | - /** |
|
321 | - * {@inheritedoc} |
|
322 | - */ |
|
320 | + /** |
|
321 | + * {@inheritedoc} |
|
322 | + */ |
|
323 | 323 | public function hasColumn(string $column): bool |
324 | 324 | { |
325 | 325 | return array_key_exists($column, $this->columns) |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | $this->rawColumns[$name] = $value; |
353 | 353 | } |
354 | 354 | |
355 | - /** |
|
356 | - * {@inheritedoc} |
|
357 | - */ |
|
355 | + /** |
|
356 | + * {@inheritedoc} |
|
357 | + */ |
|
358 | 358 | public function getRelated(string $name, callable $callback = null): mixed |
359 | 359 | { |
360 | 360 | if (array_key_exists($name, $this->relations)) { |
@@ -66,8 +66,7 @@ |
||
66 | 66 | * @template TEntity as Entity |
67 | 67 | * @implements DataMapperInterface<TEntity> |
68 | 68 | */ |
69 | -class DataMapper implements DataMapperInterface |
|
70 | -{ |
|
69 | +class DataMapper implements DataMapperInterface { |
|
71 | 70 | /** |
72 | 71 | * The raw columns data |
73 | 72 | * @var array<string, mixed> |
@@ -155,7 +155,7 @@ |
||
155 | 155 | |
156 | 156 | if ($this->offset >= 0 && $this->limit >= 0) { |
157 | 157 | $query->offset($this->offset) |
158 | - ->limit($this->limit); |
|
158 | + ->limit($this->limit); |
|
159 | 159 | |
160 | 160 | $this->offset = -1; |
161 | 161 | $this->limit = 0; |
@@ -65,8 +65,7 @@ |
||
65 | 65 | * @template TEntity as Entity |
66 | 66 | * @implements RepositoryInterface<TEntity> |
67 | 67 | */ |
68 | -class Repository implements RepositoryInterface |
|
69 | -{ |
|
68 | +class Repository implements RepositoryInterface { |
|
70 | 69 | /** |
71 | 70 | * The list of relation to load with the query |
72 | 71 | * @var array<int, string>|array<string, Closure> |
@@ -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 | } |
@@ -55,8 +55,7 @@ |
||
55 | 55 | * @package Platine\Orm |
56 | 56 | * @template TEntity as Entity |
57 | 57 | */ |
58 | -interface RepositoryInterface |
|
59 | -{ |
|
58 | +interface RepositoryInterface { |
|
60 | 59 | /** |
61 | 60 | * Return the instance of EntityQuery |
62 | 61 | * @param string|array<int, string>|array<string, Closure> $with |
@@ -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 |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * @template TEntity as \Platine\Orm\Entity |
53 | 53 | * @extends ShareRelation<TEntity> |
54 | 54 | */ |
55 | -class ShareOne extends ShareRelation |
|
56 | -{ |
|
55 | +class ShareOne extends ShareRelation { |
|
57 | 56 | /** |
58 | 57 | * {@inheritedoc} |
59 | 58 | */ |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * @template TEntity as \Platine\Orm\Entity |
53 | 53 | * @extends HasRelation<TEntity> |
54 | 54 | */ |
55 | -class HasOne extends HasRelation |
|
56 | -{ |
|
55 | +class HasOne extends HasRelation { |
|
57 | 56 | /** |
58 | 57 | * {@inheritedoc} |
59 | 58 | */ |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * @template TEntity as \Platine\Orm\Entity |
53 | 53 | * @extends HasRelation<TEntity> |
54 | 54 | */ |
55 | -class HasMany extends HasRelation |
|
56 | -{ |
|
55 | +class HasMany extends HasRelation { |
|
57 | 56 | /** |
58 | 57 | * {@inheritedoc} |
59 | 58 | */ |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * @template TEntity as \Platine\Orm\Entity |
53 | 53 | * @extends ShareRelation<TEntity> |
54 | 54 | */ |
55 | -class ShareMany extends ShareRelation |
|
56 | -{ |
|
55 | +class ShareMany extends ShareRelation { |
|
57 | 56 | /** |
58 | 57 | * {@inheritedoc} |
59 | 58 | */ |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | - * |
|
102 | - * @param DataMapper<TEntity> $mapper |
|
103 | - * @param TEntity $entity |
|
104 | - * |
|
105 | - * @return bool |
|
106 | - */ |
|
101 | + * |
|
102 | + * @param DataMapper<TEntity> $mapper |
|
103 | + * @param TEntity $entity |
|
104 | + * |
|
105 | + * @return bool |
|
106 | + */ |
|
107 | 107 | public function link(DataMapper $mapper, Entity $entity): bool |
108 | 108 | { |
109 | 109 | $manager = $mapper->getEntityManager(); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | } |
385 | 385 | }); |
386 | 386 | |
387 | - $foreignKeys = $this->foreignKey->getValue($mapper->getRawColumns(), true); |
|
387 | + $foreignKeys = $this->foreignKey->getValue($mapper->getRawColumns(), true); |
|
388 | 388 | if (is_array($foreignKeys)) { |
389 | 389 | foreach ($foreignKeys as $fkColumn => $value) { |
390 | 390 | $select->where($junctionTable . '.' . $fkColumn)->is($value); |
@@ -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); |
@@ -68,8 +68,7 @@ discard block |
||
68 | 68 | * @template TEntity as Entity |
69 | 69 | * @extends Relation<TEntity> |
70 | 70 | */ |
71 | -abstract class ShareRelation extends Relation |
|
72 | -{ |
|
71 | +abstract class ShareRelation extends Relation { |
|
73 | 72 | /** |
74 | 73 | * Whether is many or not |
75 | 74 | * @var bool |
@@ -222,8 +221,7 @@ discard block |
||
222 | 221 | |
223 | 222 | $queryStatement = new QueryStatement(); |
224 | 223 | |
225 | - $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery |
|
226 | - { |
|
224 | + $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery { |
|
227 | 225 | /** |
228 | 226 | * |
229 | 227 | * @var string |
@@ -338,8 +336,7 @@ discard block |
||
338 | 336 | $joinTable = $related->getTable(); |
339 | 337 | |
340 | 338 | $queryStatement = new QueryStatement(); |
341 | - $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery |
|
342 | - { |
|
339 | + $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery { |
|
343 | 340 | /** |
344 | 341 | * |
345 | 342 | * @var string |
@@ -435,15 +432,13 @@ discard block |
||
435 | 432 | */ |
436 | 433 | protected function buildJunction(EntityMapper $owner, EntityMapper $related): Junction |
437 | 434 | { |
438 | - return new class ($owner, $related) extends Junction |
|
439 | - { |
|
435 | + return new class ($owner, $related) extends Junction { |
|
440 | 436 | /** |
441 | 437 | * |
442 | 438 | * @param EntityMapper<TEntity> $owner |
443 | 439 | * @param EntityMapper<TEntity> $related |
444 | 440 | */ |
445 | - public function __construct(EntityMapper $owner, EntityMapper $related) |
|
446 | - { |
|
441 | + public function __construct(EntityMapper $owner, EntityMapper $related) { |
|
447 | 442 | $table = [$owner->getTable(), $related->getTable()]; |
448 | 443 | sort($table); |
449 | 444 | parent::__construct(implode('_', $table), $related->getForeignKey()->columns()); |
@@ -199,9 +199,9 @@ |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
202 | - * Map the entity information |
|
203 | - * @param EntityMapperInterface<TEntity> $mapper |
|
204 | - */ |
|
202 | + * Map the entity information |
|
203 | + * @param EntityMapperInterface<TEntity> $mapper |
|
204 | + */ |
|
205 | 205 | abstract public static function mapEntity(EntityMapperInterface $mapper): void; |
206 | 206 | |
207 | 207 | /** |