@@ -187,6 +187,4 @@ |
||
187 | 187 | private function getEntityProperties(object $entity, RelationMap $relMap): array |
188 | 188 | { |
189 | 189 | return $this->classProperties[$entity::class] ??= $this->propertiesExtractor |
190 | - ->extract($entity, array_keys($relMap->getRelations())); |
|
191 | - } |
|
192 | -} |
|
190 | + ->extract($entity, array_keys($relMap->getRelations |
|
193 | 191 | \ No newline at end of file |
@@ -187,6 +187,4 @@ |
||
187 | 187 | private function getEntityProperties(object $entity, RelationMap $relMap): array |
188 | 188 | { |
189 | 189 | return $this->classProperties[$entity::class] ??= $this->propertiesExtractor |
190 | - ->extract($entity, array_keys($relMap->getRelations())); |
|
191 | - } |
|
192 | -} |
|
190 | + ->extract($entity, array_keys($relMap->getRelations |
|
193 | 191 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | private ClassPropertiesExtractor $propertiesExtractor |
34 | 34 | ) { |
35 | 35 | $this->instantiator = new Instantiator(); |
36 | - $this->initializer = static function (object $entity, array $properties): void { |
|
36 | + $this->initializer = static function(object $entity, array $properties): void { |
|
37 | 37 | foreach ($properties as $name) { |
38 | 38 | unset($entity->$name); |
39 | 39 | } |
@@ -187,6 +187,4 @@ discard block |
||
187 | 187 | private function getEntityProperties(object $entity, RelationMap $relMap): array |
188 | 188 | { |
189 | 189 | return $this->classProperties[$entity::class] ??= $this->propertiesExtractor |
190 | - ->extract($entity, array_keys($relMap->getRelations())); |
|
191 | - } |
|
192 | -} |
|
190 | + ->extract($entity, array_keys($relMap->getRelations |
|
193 | 191 | \ No newline at end of file |
@@ -187,6 +187,4 @@ |
||
187 | 187 | private function getEntityProperties(object $entity, RelationMap $relMap): array |
188 | 188 | { |
189 | 189 | return $this->classProperties[$entity::class] ??= $this->propertiesExtractor |
190 | - ->extract($entity, array_keys($relMap->getRelations())); |
|
191 | - } |
|
192 | -} |
|
190 | + ->extract($entity, array_keys($relMap->getRelations |
|
193 | 191 | \ No newline at end of file |
@@ -187,6 +187,4 @@ |
||
187 | 187 | private function getEntityProperties(object $entity, RelationMap $relMap): array |
188 | 188 | { |
189 | 189 | return $this->classProperties[$entity::class] ??= $this->propertiesExtractor |
190 | - ->extract($entity, array_keys($relMap->getRelations())); |
|
191 | - } |
|
192 | -} |
|
190 | + ->extract($entity, array_keys($relMap->getRelations |
|
193 | 191 | \ No newline at end of file |
@@ -98,7 +98,7 @@ |
||
98 | 98 | |
99 | 99 | public function uncast(array $data): array |
100 | 100 | { |
101 | - if (! $this->typecast instanceof UncastableInterface) { |
|
101 | + if (!$this->typecast instanceof UncastableInterface) { |
|
102 | 102 | return $data; |
103 | 103 | } |
104 | 104 |
@@ -225,7 +225,7 @@ |
||
225 | 225 | $original ?? [], |
226 | 226 | $related, |
227 | 227 | // static fn(object $a, object $b): int => strcmp(spl_object_hash($a), spl_object_hash($b)) |
228 | - static fn (object $a, object $b): int => (int)($a === $b) - 1 |
|
228 | + static fn(object $a, object $b): int => (int)($a === $b) - 1 |
|
229 | 229 | ); |
230 | 230 | } |
231 | 231 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | { |
30 | 30 | return $data === null |
31 | 31 | ? null |
32 | - : ($this->mapperProvider->getMapper($this->target)?->cast($data) ?? $data); |
|
32 | + : ($this->mapperProvider->getMapper($this->target) ? ->cast($data) ?? $data); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function initReference(Node $node): ReferenceInterface |
@@ -201,7 +201,7 @@ |
||
201 | 201 | |
202 | 202 | public function extract(?iterable $data): PivotedStorage |
203 | 203 | { |
204 | - return match (true) { |
|
204 | + return match(true) { |
|
205 | 205 | $data instanceof PivotedStorage => $data, |
206 | 206 | $data instanceof PivotedCollectionInterface => new PivotedStorage( |
207 | 207 | $data->toArray(), |
@@ -54,7 +54,7 @@ |
||
54 | 54 | |
55 | 55 | $role = $related instanceof ReferenceInterface |
56 | 56 | ? $related->getRole() |
57 | - : $pool->offsetGet($related)?->node->getRole(); |
|
57 | + : $pool->offsetGet($related) ? ->node->getRole(); |
|
58 | 58 | $tuple->state->register($this->morphKey, $role); |
59 | 59 | } |
60 | 60 |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | public function run(): StateInterface |
86 | 86 | { |
87 | - $this->stage = match ($this->stage) { |
|
87 | + $this->stage = match($this->stage) { |
|
88 | 88 | self::STAGE_FINISHED => throw new SuccessTransactionRetryException( |
89 | 89 | 'A successful transaction cannot be re-run.' |
90 | 90 | ), |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @var Tuple $tuple |
210 | 210 | */ |
211 | 211 | foreach ($this->pool->openIterator() as $tuple) { |
212 | - if ($tuple->task === Tuple::TASK_FORCE_DELETE && ! $tuple->cascade) { |
|
212 | + if ($tuple->task === Tuple::TASK_FORCE_DELETE && !$tuple->cascade) { |
|
213 | 213 | // currently we rely on db to delete all nested records (or soft deletes) |
214 | 214 | $command = $this->commandGenerator->generateDeleteCommand($this->orm, $tuple); |
215 | 215 | $this->runCommand($command); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | private function resolveMasterRelations(Tuple $tuple, RelationMap $map): int |
226 | 226 | { |
227 | - if (! $map->hasDependencies()) { |
|
227 | + if (!$map->hasDependencies()) { |
|
228 | 228 | return self::RELATIONS_RESOLVED; |
229 | 229 | } |
230 | 230 | |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | // $tuple->waitKeys = array_unique(array_merge(...$waitKeys)); |
262 | - return ($deferred ? self::RELATIONS_DEFERRED : 0) | ($resolved ? self::RELATIONS_RESOLVED : 0); |
|
262 | + return ($deferred ? self::RELATIONS_DEFERRED : 0)|($resolved ? self::RELATIONS_RESOLVED : 0); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | private function resolveSlaveRelations(Tuple $tuple, RelationMap $map): int |
266 | 266 | { |
267 | - if (! $map->hasSlaves()) { |
|
267 | + if (!$map->hasSlaves()) { |
|
268 | 268 | return self::RELATIONS_RESOLVED; |
269 | 269 | } |
270 | 270 | $changedFields = array_keys($tuple->state->getChanges()); |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | |
299 | 299 | if ($relationStatus !== RelationInterface::STATUS_PREPARE |
300 | 300 | && $relationStatus !== RelationInterface::STATUS_RESOLVED |
301 | - && ! $isWaitingKeys |
|
302 | - && ! $hasChangedKeys |
|
301 | + && !$isWaitingKeys |
|
302 | + && !$hasChangedKeys |
|
303 | 303 | && \count(array_intersect($innerKeys, array_keys($transactData))) === \count($innerKeys) |
304 | 304 | ) { |
305 | 305 | $child ??= $tuple->state->getRelation($name); |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | $deferred = $deferred || $relationStatus === RelationInterface::STATUS_DEFERRED; |
311 | 311 | } |
312 | 312 | |
313 | - return ($deferred ? self::RELATIONS_DEFERRED : 0) | ($resolved ? self::RELATIONS_RESOLVED : 0); |
|
313 | + return ($deferred ? self::RELATIONS_DEFERRED : 0)|($resolved ? self::RELATIONS_RESOLVED : 0); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | private function resolveSelfWithEmbedded(Tuple $tuple, RelationMap $map, bool $hasDeferredRelations): void |
317 | 317 | { |
318 | - if (! $map->hasEmbedded() && ! $tuple->state->hasChanges()) { |
|
319 | - $tuple->status = ! $hasDeferredRelations |
|
318 | + if (!$map->hasEmbedded() && !$tuple->state->hasChanges()) { |
|
319 | + $tuple->status = !$hasDeferredRelations |
|
320 | 320 | ? Tuple::STATUS_PROCESSED |
321 | 321 | : max(Tuple::STATUS_DEFERRED, $tuple->status); |
322 | 322 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | $command = $this->commandGenerator->generateStoreCommand($this->orm, $tuple); |
326 | 326 | |
327 | - if (! $map->hasEmbedded()) { |
|
327 | + if (!$map->hasEmbedded()) { |
|
328 | 328 | // Not embedded but has changes |
329 | 329 | $this->runCommand($command); |
330 | 330 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | $this->runCommand($command); |
353 | 353 | |
354 | - $tuple->status = $tuple->status === Tuple::STATUS_PREPROCESSED || ! $hasDeferredRelations |
|
354 | + $tuple->status = $tuple->status === Tuple::STATUS_PREPROCESSED || !$hasDeferredRelations |
|
355 | 355 | ? Tuple::STATUS_PROCESSED |
356 | 356 | : max(Tuple::STATUS_DEFERRED, $tuple->status); |
357 | 357 | } |
@@ -364,8 +364,8 @@ discard block |
||
364 | 364 | $result = $tuple->task === Tuple::TASK_STORE |
365 | 365 | ? $this->resolveMasterRelations($tuple, $map) |
366 | 366 | : $this->resolveSlaveRelations($tuple, $map); |
367 | - $isDependenciesResolved = (bool)($result & self::RELATIONS_RESOLVED); |
|
368 | - $deferred = (bool)($result & self::RELATIONS_DEFERRED); |
|
367 | + $isDependenciesResolved = (bool)($result&self::RELATIONS_RESOLVED); |
|
368 | + $deferred = (bool)($result&self::RELATIONS_DEFERRED); |
|
369 | 369 | |
370 | 370 | // Self |
371 | 371 | if ($deferred && $tuple->status < Tuple::STATUS_PROPOSED) { |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | : $this->resolveMasterRelations($tuple, $map); |
392 | 392 | } |
393 | 393 | |
394 | - if (! $isDependenciesResolved && $tuple->status === Tuple::STATUS_PREPROCESSED) { |
|
394 | + if (!$isDependenciesResolved && $tuple->status === Tuple::STATUS_PREPROCESSED) { |
|
395 | 395 | $tuple->status = Tuple::STATUS_UNPROCESSED; |
396 | 396 | } |
397 | 397 | } |
@@ -320,7 +320,7 @@ |
||
320 | 320 | if (($node === null && $tuple->task !== Tuple::TASK_STORE) || $entity instanceof ReferenceInterface) { |
321 | 321 | return; |
322 | 322 | } |
323 | - $tuple->mapper ??= $this->orm->getMapper($node?->getRole() ?? $entity); |
|
323 | + $tuple->mapper ??= $this->orm->getMapper($node ? ->getRole() ?? $entity); |
|
324 | 324 | if ($node === null) { |
325 | 325 | // Create new Node |
326 | 326 | $node = new Node(Node::NEW, [], $tuple->mapper->getRole()); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $commands[$tuple->node->getRole()] = $entityCommand; |
30 | 30 | } |
31 | 31 | |
32 | - return match (\count($commands)) { |
|
32 | + return match(\count($commands)) { |
|
33 | 33 | 0 => null, |
34 | 34 | 1 => \current($commands), |
35 | 35 | default => $this->buildStoreSequence($schema, $commands, $tuple) |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ?? $schema->define($parent, SchemaInterface::PRIMARY_KEY)); |
114 | 114 | $primaryKey = (array)$schema->define($role, SchemaInterface::PRIMARY_KEY); |
115 | 115 | $result[] = $command->withBeforeExecution( |
116 | - static function (StoreCommandInterface $command) use ($tuple, $parentKey, $primaryKey): void { |
|
116 | + static function(StoreCommandInterface $command) use ($tuple, $parentKey, $primaryKey): void { |
|
117 | 117 | foreach ($primaryKey as $i => $pk) { |
118 | 118 | $command->registerAppendix($pk, $tuple->state->getValue($parentKey[$i])); |
119 | 119 | } |