@@ -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 |
@@ -56,8 +56,7 @@ |
||
56 | 56 | * @package Platine\Orm\Relation |
57 | 57 | * @template TEntity as Entity |
58 | 58 | */ |
59 | -class RelationLoader |
|
60 | -{ |
|
59 | +class RelationLoader { |
|
61 | 60 | /** |
62 | 61 | * |
63 | 62 | * @var EntityQuery<TEntity> |
@@ -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()); |
@@ -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 | } |
@@ -56,8 +56,7 @@ |
||
56 | 56 | * @package Platine\Orm\Relation |
57 | 57 | * @template TEntity as Entity |
58 | 58 | */ |
59 | -abstract class Relation |
|
60 | -{ |
|
59 | +abstract class Relation { |
|
61 | 60 | /** |
62 | 61 | * Query callback |
63 | 62 | * @var callable|null |
@@ -53,15 +53,13 @@ |
||
53 | 53 | * @package Platine\Orm\Relation |
54 | 54 | * @template TEntity as \Platine\Orm\Entity |
55 | 55 | */ |
56 | -class RelationFactory |
|
57 | -{ |
|
56 | +class RelationFactory { |
|
58 | 57 | /** |
59 | 58 | * Create new instance |
60 | 59 | * @param string $name |
61 | 60 | * @param Closure $callback |
62 | 61 | */ |
63 | - public function __construct(protected string $name, protected Closure $callback) |
|
64 | - { |
|
62 | + public function __construct(protected string $name, protected Closure $callback) { |
|
65 | 63 | } |
66 | 64 | |
67 | 65 | /** |
@@ -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(); |
@@ -61,8 +61,7 @@ |
||
61 | 61 | * @template TEntity as Entity |
62 | 62 | * @extends Relation<TEntity> |
63 | 63 | */ |
64 | -abstract class HasRelation extends Relation |
|
65 | -{ |
|
64 | +abstract class HasRelation extends Relation { |
|
66 | 65 | /** |
67 | 66 | * Whether is many or not |
68 | 67 | * @var bool |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | * @package Platine\Orm\Relation |
57 | 57 | * @template TEntity as Entity |
58 | 58 | */ |
59 | -class PrimaryKey implements Stringable |
|
60 | -{ |
|
59 | +class PrimaryKey implements Stringable { |
|
61 | 60 | /** |
62 | 61 | * |
63 | 62 | * @var array<int, string> |
@@ -74,8 +73,7 @@ discard block |
||
74 | 73 | * Create new instance |
75 | 74 | * @param string ...$columns |
76 | 75 | */ |
77 | - public function __construct(string ...$columns) |
|
78 | - { |
|
76 | + public function __construct(string ...$columns) { |
|
79 | 77 | $this->columns = array_values($columns); |
80 | 78 | $this->composite = count($columns) > 1; |
81 | 79 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * @class ForeignKey |
53 | 53 | * @package Platine\Orm\Relation |
54 | 54 | */ |
55 | -class ForeignKey implements Stringable |
|
56 | -{ |
|
55 | +class ForeignKey implements Stringable { |
|
57 | 56 | /** |
58 | 57 | * |
59 | 58 | * @var array<string, string> |
@@ -70,8 +69,7 @@ discard block |
||
70 | 69 | * Create new instance |
71 | 70 | * @param array<string, string> $columns |
72 | 71 | */ |
73 | - public function __construct(array $columns) |
|
74 | - { |
|
72 | + public function __construct(array $columns) { |
|
75 | 73 | $this->columns = $columns; |
76 | 74 | $this->composite = count($columns) > 1; |
77 | 75 | } |
@@ -50,15 +50,13 @@ |
||
50 | 50 | * @class Junction |
51 | 51 | * @package Platine\Orm\Relation |
52 | 52 | */ |
53 | -class Junction |
|
54 | -{ |
|
53 | +class Junction { |
|
55 | 54 | /** |
56 | 55 | * Create new instance |
57 | 56 | * @param string $table |
58 | 57 | * @param array<string, string> $columns |
59 | 58 | */ |
60 | - public function __construct(protected string $table, protected array $columns) |
|
61 | - { |
|
59 | + public function __construct(protected string $table, protected array $columns) { |
|
62 | 60 | } |
63 | 61 | |
64 | 62 | /** |
@@ -64,8 +64,7 @@ |
||
64 | 64 | * @template TEntity as Entity |
65 | 65 | * @extends Relation<TEntity> |
66 | 66 | */ |
67 | -class BelongsTo extends Relation |
|
68 | -{ |
|
67 | +class BelongsTo extends Relation { |
|
69 | 68 | /** |
70 | 69 | * |
71 | 70 | * @param DataMapper<TEntity> $owner |