@@ -10,7 +10,7 @@ |
||
| 10 | 10 | public static function new(...$args) |
| 11 | 11 | { |
| 12 | 12 | if ($args[0] instanceof Connection) { |
| 13 | - return new ConnectionLocator(function () use ($args) { |
|
| 13 | + return new ConnectionLocator(function() use ($args) { |
|
| 14 | 14 | return $args[0]; |
| 15 | 15 | }); |
| 16 | 16 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | if (strpos($key, $separator)) { |
| 27 | 27 | $parents = static::getParents($key, $separator); |
| 28 | 28 | foreach ($parents as $parent) { |
| 29 | - if (! isset($arr[$parent])) { |
|
| 29 | + if (!isset($arr[$parent])) { |
|
| 30 | 30 | $arr[$parent] = null; |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | { |
| 8 | 8 | public static function reference($table, $tableAlias) |
| 9 | 9 | { |
| 10 | - if (! $tableAlias || $table == $tableAlias) { |
|
| 10 | + if (!$tableAlias || $table == $tableAlias) { |
|
| 11 | 11 | return $table; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | $insertSql = new \Sirius\Sql\Insert($connection); |
| 31 | 31 | $insertSql->into($this->mapper->getConfig()->getTable()) |
| 32 | - ->columns($columns); |
|
| 32 | + ->columns($columns); |
|
| 33 | 33 | $insertSql->perform(); |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -38,13 +38,13 @@ |
||
| 38 | 38 | * For example, on one-to-many relations when persisting the "parent", |
| 39 | 39 | * the actions that persist the "children" have to know about the parent's ID |
| 40 | 40 | */ |
| 41 | - $this->entityHydrator->setPk($this->entity, (int) $connection->lastInsertId()); |
|
| 41 | + $this->entityHydrator->setPk($this->entity, (int)$connection->lastInsertId()); |
|
| 42 | 42 | $this->entity->setState(StateEnum::SYNCHRONIZED); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function revert() |
| 46 | 46 | { |
| 47 | - if (! $this->hasRun) { |
|
| 47 | + if (!$this->hasRun) { |
|
| 48 | 48 | return; |
| 49 | 49 | } |
| 50 | 50 | $this->entityHydrator->setPk($this->entity, $this->entityId); |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | |
| 24 | 24 | $update = new \Sirius\Sql\Update($this->mapper->getWriteConnection()); |
| 25 | 25 | $update->table($this->mapper->getConfig()->getTable()) |
| 26 | - ->columns([ |
|
| 27 | - $this->getOption('deleted_at_column') => $this->now |
|
| 28 | - ]) |
|
| 29 | - ->where('id', $entityId); |
|
| 26 | + ->columns([ |
|
| 27 | + $this->getOption('deleted_at_column') => $this->now |
|
| 28 | + ]) |
|
| 29 | + ->where('id', $entityId); |
|
| 30 | 30 | $update->perform(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | protected function execute() |
| 16 | 16 | { |
| 17 | 17 | $entityId = $this->entityHydrator->getPk($this->entity); |
| 18 | - if (! $entityId) { |
|
| 18 | + if (!$entityId) { |
|
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -122,8 +122,8 @@ |
||
| 122 | 122 | |
| 123 | 123 | $insert = new \Sirius\Sql\Insert($conn); |
| 124 | 124 | $insert->into($throughTable) |
| 125 | - ->columns($insertColumns) |
|
| 126 | - ->perform(); |
|
| 125 | + ->columns($insertColumns) |
|
| 126 | + ->perform(); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | protected function getNativeEntityHydrator() |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | protected function maybeUpdatePivotRow() |
| 77 | 77 | { |
| 78 | - if (! $this->relation instanceof ManyToMany) { |
|
| 78 | + if (!$this->relation instanceof ManyToMany) { |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $delete->where($throughForeignColumns[$k], $foreignKey[$k]); |
| 96 | 96 | } |
| 97 | 97 | foreach ((array)$this->relation->getOption(RelationConfig::THROUGH_GUARDS) as $col => $value) { |
| 98 | - if (! is_int($col)) { |
|
| 98 | + if (!is_int($col)) { |
|
| 99 | 99 | $delete->where($col, $value); |
| 100 | 100 | } else { |
| 101 | 101 | $delete->where($value); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | foreach ((array)$this->relation->getOption(RelationConfig::THROUGH_GUARDS) as $col => $value) { |
| 118 | - if (! is_int($col)) { |
|
| 118 | + if (!is_int($col)) { |
|
| 119 | 119 | $insertColumns[$col] = $value; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -54,8 +54,8 @@ |
||
| 54 | 54 | if (count($columns) > 0) { |
| 55 | 55 | $updateSql = new \Sirius\Sql\Update($connection); |
| 56 | 56 | $updateSql->table($this->mapper->getConfig()->getTable()) |
| 57 | - ->columns($columns) |
|
| 58 | - ->whereAll($conditions, false); |
|
| 57 | + ->columns($columns) |
|
| 58 | + ->whereAll($conditions, false); |
|
| 59 | 59 | $updateSql->perform(); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | |
| 63 | 63 | public function revert() |
| 64 | 64 | { |
| 65 | - if (! $this->hasRun) { |
|
| 65 | + if (!$this->hasRun) { |
|
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | $this->entity->setState($this->entityState); |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | private function addFirstMethod() |
| 65 | 65 | { |
| 66 | 66 | $method = $this->class->addMethod('first') |
| 67 | - ->setReturnNullable(true) |
|
| 68 | - ->setReturnType($this->mapper->getEntityClass()); |
|
| 67 | + ->setReturnNullable(true) |
|
| 68 | + ->setReturnType($this->mapper->getEntityClass()); |
|
| 69 | 69 | $method->setBody('return parent::first();'); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $this->namespace->addUse(Collection::class); |
| 75 | 75 | $method = $this->class->addMethod('get') |
| 76 | - ->setReturnType('Collection'); |
|
| 76 | + ->setReturnType('Collection'); |
|
| 77 | 77 | $method->setBody('return parent::get();'); |
| 78 | 78 | $method->addComment(sprintf('@return Collection|%s[]', $this->mapper->getEntityClass())); |
| 79 | 79 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $this->namespace->addUse(PaginatedCollection::class); |
| 84 | 84 | $method = $this->class->addMethod('paginate') |
| 85 | - ->setReturnType('PaginatedCollection'); |
|
| 85 | + ->setReturnType('PaginatedCollection'); |
|
| 86 | 86 | $method->addParameter('perPage')->setType('int'); |
| 87 | 87 | $method->addParameter('page', 1)->setType('int'); |
| 88 | 88 | $method->setBody('return parent::paginate($perPage, $page);'); |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | public function joinSubselect(Query $query, string $reference) |
| 49 | 49 | { |
| 50 | 50 | $subselect = $query->subSelectForJoinWith($this->foreignMapper) |
| 51 | - ->as($reference); |
|
| 51 | + ->as($reference); |
|
| 52 | 52 | |
| 53 | 53 | $subselect = $this->applyQueryCallback($subselect); |
| 54 | 54 | |
@@ -18,11 +18,11 @@ discard block |
||
| 18 | 18 | protected function applyDefaults(): void |
| 19 | 19 | { |
| 20 | 20 | $nativeKey = $this->nativeMapper->getConfig()->getPrimaryKey(); |
| 21 | - if (! isset($this->options[RelationConfig::NATIVE_KEY])) { |
|
| 21 | + if (!isset($this->options[RelationConfig::NATIVE_KEY])) { |
|
| 22 | 22 | $this->options[RelationConfig::NATIVE_KEY] = $nativeKey; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - if (! isset($this->options[RelationConfig::FOREIGN_KEY])) { |
|
| 25 | + if (!isset($this->options[RelationConfig::FOREIGN_KEY])) { |
|
| 26 | 26 | $prefix = Inflector::singularize($this->nativeMapper->getConfig()->getTable()); |
| 27 | 27 | $this->options[RelationConfig::FOREIGN_KEY] = $this->getKeyColumn($prefix, $nativeKey); |
| 28 | 28 | } |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | protected function addActionOnDelete(BaseAction $action) |
| 95 | 95 | { |
| 96 | - $relations = $action->getOption('relations'); |
|
| 96 | + $relations = $action->getOption('relations'); |
|
| 97 | 97 | |
| 98 | 98 | // no cascade delete? treat as save so we can process the changes |
| 99 | - if (! $this->isCascade()) { |
|
| 99 | + if (!$this->isCascade()) { |
|
| 100 | 100 | $this->addActionOnSave($action); |
| 101 | 101 | } elseif ($relations === true || in_array($this->name, (array)$relations)) { |
| 102 | 102 | $nativeEntity = $action->getEntity(); |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | protected function addActionOnSave(BaseAction $action) |
| 120 | 120 | { |
| 121 | - if (! $this->relationWasChanged($action->getEntity())) { |
|
| 121 | + if (!$this->relationWasChanged($action->getEntity())) { |
|
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if (! $action->includesRelation($this->name)) { |
|
| 125 | + if (!$action->includesRelation($this->name)) { |
|
| 126 | 126 | return; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | // save the entities still in the collection |
| 137 | 137 | foreach ($foreignEntities as $foreignEntity) { |
| 138 | - if (! empty($foreignEntity->getChanges())) { |
|
| 138 | + if (!empty($foreignEntity->getChanges())) { |
|
| 139 | 139 | $saveAction = $this->foreignMapper |
| 140 | 140 | ->newSaveAction($foreignEntity, ['relations' => $remainingRelations]); |
| 141 | 141 | $saveAction->addColumns($this->getExtraColumnsForAction()); |