@@ -77,7 +77,7 @@ |
||
77 | 77 | * |
78 | 78 | * @return int|numeric-string |
79 | 79 | */ |
80 | - public static function exec(string $sql): int|string |
|
80 | + public static function exec(string $sql): int | string |
|
81 | 81 | { |
82 | 82 | return self::getDB()->exec($sql); |
83 | 83 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | * |
54 | 54 | * @return int|numeric-string |
55 | 55 | */ |
56 | - public function exec(string $sql, array $params = []): int|string |
|
56 | + public function exec(string $sql, array $params = []): int | string |
|
57 | 57 | { |
58 | 58 | return $this->connection->executeStatement($sql, $params); |
59 | 59 | } |
@@ -6,10 +6,10 @@ |
||
6 | 6 | |
7 | 7 | return RectorConfig::configure() |
8 | 8 | ->withPaths([ |
9 | - __DIR__ . '/src', |
|
10 | - __DIR__ . '/tests', |
|
9 | + __DIR__.'/src', |
|
10 | + __DIR__.'/tests', |
|
11 | 11 | ]) |
12 | 12 | // uncomment to reach your current PHP version |
13 | 13 | ->withPhpSets(php83:true) |
14 | 14 | ->withAttributesSets() |
15 | - ->withPreparedSets(deadCode:true,typeDeclarations:true,codeQuality:true); |
|
15 | + ->withPreparedSets(deadCode:true, typeDeclarations:true, codeQuality:true); |
@@ -40,7 +40,7 @@ |
||
40 | 40 | // Try to load specific model class first if modelNamespace is not empty |
41 | 41 | $namespace = $this->config->getModelNamespace(); |
42 | 42 | if (!empty($namespace)) { |
43 | - $modelClass = $namespace . ucfirst($name); |
|
43 | + $modelClass = $namespace.ucfirst($name); |
|
44 | 44 | if (class_exists($modelClass)) { |
45 | 45 | return $this->container->make($modelClass); |
46 | 46 | } |
@@ -66,7 +66,7 @@ |
||
66 | 66 | |
67 | 67 | private function createModelManager(): void |
68 | 68 | { |
69 | - $this->container->set(ModelManager::class, fn (): ModelManager => new ModelManager($this->container,$this->container->get(Config::class))); |
|
69 | + $this->container->set(ModelManager::class, fn (): ModelManager => new ModelManager($this->container, $this->container->get(Config::class))); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | private function createConfig(bool $useUUID, string $modelNamespace): void |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function insert(Model $model): mixed |
77 | 77 | { |
78 | - return $this->executeInTransaction(function () use ($model) { |
|
78 | + return $this->executeInTransaction(function() use ($model) { |
|
79 | 79 | if ($this->config->isUsingUUID()) { |
80 | 80 | $model->set(self::ID_COLUMN, Uuid::uuid4()->toString()); |
81 | 81 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function update(Model $model): mixed |
100 | 100 | { |
101 | - return $this->executeInTransaction(function () use ($model) { |
|
101 | + return $this->executeInTransaction(function() use ($model) { |
|
102 | 102 | $this->connection->update( |
103 | 103 | $model->getName(), |
104 | 104 | $model->getSelfProperties(), |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function delete(Model $model): mixed |
115 | 115 | { |
116 | - return $this->executeInTransaction(function () use ($model) { |
|
116 | + return $this->executeInTransaction(function() use ($model) { |
|
117 | 117 | $this->connection->delete( |
118 | 118 | $model->getName(), |
119 | 119 | [self::ID_COLUMN => $model->getId()] |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function getById(string $table, mixed $id): ?Model |
129 | 129 | { |
130 | - return $this->executeInTransaction(function () use ($table, $id) { |
|
130 | + return $this->executeInTransaction(function() use ($table, $id) { |
|
131 | 131 | return $this->createQueryBuilder() |
132 | 132 | ->select(self::ALL_COLUMNS) |
133 | 133 | ->from($table, self::DEFAULT_ALIAS) |
134 | - ->where(self::DEFAULT_ALIAS . '.' . self::ID_COLUMN . ' = ?') |
|
134 | + ->where(self::DEFAULT_ALIAS.'.'.self::ID_COLUMN.' = ?') |
|
135 | 135 | ->setParameter(0, $id) |
136 | 136 | ->first(); |
137 | 137 | }); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function getAll(string $tableName): Collection |
144 | 144 | { |
145 | - return $this->executeInTransaction(function () use ($tableName) { |
|
145 | + return $this->executeInTransaction(function() use ($tableName) { |
|
146 | 146 | return $this->createQueryBuilder() |
147 | 147 | ->select(self::ALL_COLUMNS) |
148 | 148 | ->from($tableName, self::DEFAULT_ALIAS) |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return string|int |
41 | 41 | * @throws InvalidIdException |
42 | 42 | */ |
43 | - public function save(Model $model): string|int |
|
43 | + public function save(Model $model): string | int |
|
44 | 44 | { |
45 | 45 | if ($model->hasForeign(self::RELATION_ONE_TO_ONE)) { |
46 | 46 | $this->saveForeignOneToOne($model); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | foreach ($model->getForeignModels(self::RELATION_ONE_TO_ONE) as $foreign) { |
194 | 194 | $id = $this->createRecords($foreign); |
195 | 195 | $this->finalizeModel($foreign); |
196 | - $name = $foreign->getName() . self::ID_SUFFIX; |
|
196 | + $name = $foreign->getName().self::ID_SUFFIX; |
|
197 | 197 | $model->$name = $id; |
198 | 198 | } |
199 | 199 | }); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | { |
207 | 207 | $id = $model->getId(); |
208 | 208 | foreach ($model->getForeignModels(self::RELATION_ONE_TO_MANY) as $foreign) { |
209 | - $key = $model->getName() . self::ID_SUFFIX; |
|
209 | + $key = $model->getName().self::ID_SUFFIX; |
|
210 | 210 | $foreign->$key = $id; |
211 | 211 | $this->createTable($foreign, $this->createConstraintsOtm($model)); |
212 | 212 | } |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | { |
227 | 227 | $id = $model->getId(); |
228 | 228 | foreach ($model->getForeignModels(self::RELATION_MANY_TO_MANY) as $foreign) { |
229 | - $model_id = $model->getName() . self::ID_SUFFIX; |
|
230 | - $foreign_id = $foreign->getName() . self::ID_SUFFIX; |
|
229 | + $model_id = $model->getName().self::ID_SUFFIX; |
|
230 | + $foreign_id = $foreign->getName().self::ID_SUFFIX; |
|
231 | 231 | $relational_table = $this->modelManager->create( |
232 | - $model->getName() . '_' . $foreign->getName() |
|
232 | + $model->getName().'_'.$foreign->getName() |
|
233 | 233 | ); |
234 | 234 | |
235 | 235 | $default_id = $this->config->isUsingUUID() ? '' : 0; |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | $rel_id = $this->createRecords($foreign); |
249 | 249 | $this->finalizeModel($foreign); |
250 | 250 | |
251 | - $model_id = $model->getName() . self::ID_SUFFIX; |
|
252 | - $foreign_id = $foreign->getName() . self::ID_SUFFIX; |
|
251 | + $model_id = $model->getName().self::ID_SUFFIX; |
|
252 | + $foreign_id = $foreign->getName().self::ID_SUFFIX; |
|
253 | 253 | |
254 | 254 | $relational_table = $this->modelManager->create( |
255 | - $model->getName() . '_' . $foreign->getName() |
|
255 | + $model->getName().'_'.$foreign->getName() |
|
256 | 256 | ); |
257 | 257 | $relational_table->$model_id = $id; |
258 | 258 | $relational_table->$foreign_id = $rel_id; |
@@ -15,6 +15,6 @@ |
||
15 | 15 | { |
16 | 16 | public function __construct(?string $type) |
17 | 17 | { |
18 | - parent::__construct('Invalid relation type: ' . $type); |
|
18 | + parent::__construct('Invalid relation type: '.$type); |
|
19 | 19 | } |
20 | 20 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | $db = $this->recordManager->find(strtolower((string) $parts[1])); |
250 | - $db->where($this->getName() . '_id = :id') |
|
250 | + $db->where($this->getName().'_id = :id') |
|
251 | 251 | ->setParameter( |
252 | 252 | 'id', |
253 | 253 | $this->__meta['id'], |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $relTable = $this->getRelationTable($targetTable); |
276 | 276 | |
277 | 277 | $db = $this->recordManager->find($relTable); |
278 | - $db->where($this->getName() . '_id = :id') |
|
278 | + $db->where($this->getName().'_id = :id') |
|
279 | 279 | ->setParameter( |
280 | 280 | 'id', |
281 | 281 | $this->__meta['id'], |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | |
307 | 307 | private function getRelationTable(string $targetTable): string |
308 | 308 | { |
309 | - $cacheKey = $this->table . '_' . $targetTable; |
|
309 | + $cacheKey = $this->table.'_'.$targetTable; |
|
310 | 310 | |
311 | 311 | if (!isset($this->relationTableCache[$cacheKey])) { |
312 | 312 | $this->relationTableCache[$cacheKey] = $this->tableManager->tableExists($cacheKey) |
313 | 313 | ? $cacheKey |
314 | - : $targetTable . '_' . $this->table; |
|
314 | + : $targetTable.'_'.$this->table; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | return $this->relationTableCache[$cacheKey]; |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | */ |
328 | 328 | private function extractRelationIds(Collection $relations, string $targetTable): array |
329 | 329 | { |
330 | - return $relations->map(function ($relation) use ($targetTable) { |
|
331 | - $key = $targetTable . '_id'; |
|
330 | + return $relations->map(function($relation) use ($targetTable) { |
|
331 | + $key = $targetTable.'_id'; |
|
332 | 332 | |
333 | 333 | return $relation->$key; |
334 | 334 | })->toArray(); |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | } |
356 | 356 | |
357 | 357 | // Handle foreign key relations |
358 | - if (array_key_exists($key . '_id', $this->__properties['self'])) { |
|
359 | - $result = $this->recordManager->getById($key, $this->__properties['self'][$key . '_id']); |
|
358 | + if (array_key_exists($key.'_id', $this->__properties['self'])) { |
|
359 | + $result = $this->recordManager->getById($key, $this->__properties['self'][$key.'_id']); |
|
360 | 360 | $this->set($key, $result); |
361 | 361 | |
362 | 362 | return $result; |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * |
515 | 515 | * @throws Exception\InvalidModelException |
516 | 516 | */ |
517 | - private function createCollection(?Collection $collection, array|Collection $models): Collection |
|
517 | + private function createCollection(?Collection $collection, array | Collection $models): Collection |
|
518 | 518 | { |
519 | 519 | if (is_null($collection)) { |
520 | 520 | $collection = Collection::fromIterable([]); |
@@ -545,8 +545,8 @@ discard block |
||
545 | 545 | |
546 | 546 | private function handleModelRelation(string $key, Model $val): void |
547 | 547 | { |
548 | - if (isset($this->__properties['all'][$key . '_id'])) { |
|
549 | - unset($this->__properties['all'][$key . '_id']); |
|
548 | + if (isset($this->__properties['all'][$key.'_id'])) { |
|
549 | + unset($this->__properties['all'][$key.'_id']); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | $this->__meta['foreign_models']['oto'] = $this->createCollection( |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | /** |
596 | 596 | * Determines the ParameterType for an ID value. |
597 | 597 | */ |
598 | - private function determineIdType(int|string $id): ParameterType |
|
598 | + private function determineIdType(int | string $id): ParameterType |
|
599 | 599 | { |
600 | 600 | return is_int($id) ? ParameterType::INTEGER : ParameterType::STRING; |
601 | 601 | } |