@@ -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);'); |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | return [ |
| 68 | 68 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
| 69 | 69 | 'contents' => $this->classPrinter->printFile($file) |
| 70 | - . PHP_EOL |
|
| 71 | - . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 72 | - . $this->classPrinter->printClass($class) |
|
| 70 | + . PHP_EOL |
|
| 71 | + . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 72 | + . $this->classPrinter->printClass($class) |
|
| 73 | 73 | ]; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | return [ |
| 89 | 89 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
| 90 | 90 | 'contents' => $this->classPrinter->printFile($file) |
| 91 | - . PHP_EOL |
|
| 92 | - . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 93 | - . $this->classPrinter->printClass($class) |
|
| 91 | + . PHP_EOL |
|
| 92 | + . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 93 | + . $this->classPrinter->printClass($class) |
|
| 94 | 94 | ]; |
| 95 | 95 | |
| 96 | 96 | } |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | return [ |
| 106 | 106 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
| 107 | 107 | 'contents' => $this->classPrinter->printFile($file) |
| 108 | - . PHP_EOL |
|
| 109 | - . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 110 | - . $this->classPrinter->printClass($class) |
|
| 108 | + . PHP_EOL |
|
| 109 | + . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 110 | + . $this->classPrinter->printClass($class) |
|
| 111 | 111 | ]; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | return [ |
| 128 | 128 | 'path' => $mapper->getDestination() . $class->getName() . '.php', |
| 129 | 129 | 'contents' => $this->classPrinter->printFile($file) |
| 130 | - . PHP_EOL |
|
| 131 | - . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 132 | - . $this->classPrinter->printClass($class) |
|
| 130 | + . PHP_EOL |
|
| 131 | + . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 132 | + . $this->classPrinter->printClass($class) |
|
| 133 | 133 | ]; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | return [ |
| 148 | 148 | 'path' => $mapper->getEntityDestination() . $class->getName() . '.php', |
| 149 | 149 | 'contents' => $this->classPrinter->printFile($file) |
| 150 | - . PHP_EOL |
|
| 151 | - . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 152 | - . $this->classPrinter->printClass($class) |
|
| 150 | + . PHP_EOL |
|
| 151 | + . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 152 | + . $this->classPrinter->printClass($class) |
|
| 153 | 153 | ]; |
| 154 | 154 | |
| 155 | 155 | $class = new ClassType( |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | return [ |
| 175 | 175 | 'path' => $mapper->getEntityDestination() . $class->getName() . '.php', |
| 176 | 176 | 'contents' => $this->classPrinter->printFile($file) |
| 177 | - . PHP_EOL |
|
| 178 | - . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 179 | - . $this->classPrinter->printClass($class) |
|
| 177 | + . PHP_EOL |
|
| 178 | + . $this->classPrinter->printNamespace($class->getNamespace()) |
|
| 179 | + . $this->classPrinter->printClass($class) |
|
| 180 | 180 | ]; |
| 181 | 181 | |
| 182 | 182 | } |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | $this->namespace->addUse($this->mapper->getEntityNamespace() . '\\' . $this->mapper->getEntityClass()); |
| 149 | 149 | $method = $this->class->addMethod('find') |
| 150 | - ->setReturnNullable(true) |
|
| 151 | - ->setReturnType($this->mapper->getEntityClass()); |
|
| 150 | + ->setReturnNullable(true) |
|
| 151 | + ->setReturnType($this->mapper->getEntityClass()); |
|
| 152 | 152 | $method->addParameter('pk'); |
| 153 | 153 | $method->addParameter('load', [])->setType('array'); |
| 154 | 154 | $method->setBody('return parent::find($pk, $load);'); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | protected function addNewQueryMethod() |
| 158 | 158 | { |
| 159 | 159 | $method = $this->class->addMethod('newQuery') |
| 160 | - ->setReturnType($this->mapper->getQueryClass()); |
|
| 160 | + ->setReturnType($this->mapper->getQueryClass()); |
|
| 161 | 161 | $method->addBody(sprintf('$query = new %s($this->getReadConnection(), $this);', $this->mapper->getQueryClass())); |
| 162 | 162 | $method->addBody('return $this->behaviours->apply($this, __FUNCTION__, $query);'); |
| 163 | 163 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $this->namespace->addUse(Update::class, 'UpdateAction'); |
| 171 | 171 | |
| 172 | 172 | $method = $this->class->addMethod('save') |
| 173 | - ->setReturnType('bool'); |
|
| 173 | + ->setReturnType('bool'); |
|
| 174 | 174 | $method->addParameter('entity')->setType($this->mapper->getEntityClass()); |
| 175 | 175 | $method->addParameter('withRelations', false); |
| 176 | 176 | $method->setBody(' |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | protected function addDeleteMethod() |
| 209 | 209 | { |
| 210 | 210 | $method = $this->class->addMethod('delete') |
| 211 | - ->setReturnType('bool'); |
|
| 211 | + ->setReturnType('bool'); |
|
| 212 | 212 | $method->addParameter('entity')->setType($this->mapper->getEntityClass()); |
| 213 | 213 | $method->addParameter('withRelations', false); |
| 214 | 214 | $method->setBody(' |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | protected function ensureHydratedElement($element) |
| 31 | 31 | { |
| 32 | - if ( ! $element instanceof EntityInterface) { |
|
| 32 | + if (!$element instanceof EntityInterface) { |
|
| 33 | 33 | return $this->hydrator->hydrate((array)$element); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | public function add($element) |
| 60 | 60 | { |
| 61 | 61 | $element = $this->ensureHydratedElement($element); |
| 62 | - if ( ! $this->contains($element)) { |
|
| 62 | + if (!$this->contains($element)) { |
|
| 63 | 63 | $this->change('added', $element); |
| 64 | 64 | |
| 65 | 65 | return parent::add($element); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function removeElement($element) |
| 80 | 80 | { |
| 81 | 81 | $element = $this->ensureHydratedElement($element); |
| 82 | - if ( ! $this->contains($element)) { |
|
| 82 | + if (!$this->contains($element)) { |
|
| 83 | 83 | return true; |
| 84 | 84 | } |
| 85 | 85 | $removed = parent::removeElement($element); |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | public function pluck($names) |
| 94 | 94 | { |
| 95 | - return $this->map(function ($item) use ($names) { |
|
| 96 | - if ( ! is_array($names)) { |
|
| 95 | + return $this->map(function($item) use ($names) { |
|
| 96 | + if (!is_array($names)) { |
|
| 97 | 97 | return $this->hydrator->get($item, $names); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | /** @var ArrayCollection $changeCollection */ |
| 144 | 144 | $changeCollection = $this->changes[$t]; |
| 145 | 145 | if ($t == $type) { |
| 146 | - if ( ! $changeCollection->contains($element)) { |
|
| 146 | + if (!$changeCollection->contains($element)) { |
|
| 147 | 147 | $changeCollection->add($element); |
| 148 | 148 | } |
| 149 | 149 | } else { |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public static function getInstance() |
| 16 | 16 | { |
| 17 | - if ( ! static::$instance) { |
|
| 17 | + if (!static::$instance) { |
|
| 18 | 18 | static::$instance = new static; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - return ! ! $value; |
|
| 87 | + return !!$value; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // phpcs:ignore |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | public function json($value) |
| 112 | 112 | { |
| 113 | - if ( ! $value) { |
|
| 113 | + if (!$value) { |
|
| 114 | 114 | return new \ArrayObject(); |
| 115 | 115 | } |
| 116 | 116 | if (is_array($value)) { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | // phpcs:ignore |
| 129 | 129 | public function json_for_db($value) |
| 130 | 130 | { |
| 131 | - if ( ! $value) { |
|
| 131 | + if (!$value) { |
|
| 132 | 132 | return null; |
| 133 | 133 | } |
| 134 | 134 | if (is_array($value)) { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | protected function setOptionIfMissing($name, $value) |
| 80 | 80 | { |
| 81 | - if ( ! isset($this->options[$name])) { |
|
| 81 | + if (!isset($this->options[$name])) { |
|
| 82 | 82 | $this->options[$name] = $value; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | protected function getKeyColumn($name, $column) |
| 119 | 119 | { |
| 120 | - if ( ! is_array($column)) { |
|
| 120 | + if (!is_array($column)) { |
|
| 121 | 121 | return $name . '_' . $column; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | foreach ($entities as $entity) { |
| 180 | 180 | $entityId = $this->getEntityId($this->foreignMapper, $entity, array_values($this->keyPairs)); |
| 181 | - if ( ! isset($result[$entityId])) { |
|
| 181 | + if (!isset($result[$entityId])) { |
|
| 182 | 182 | $result[$entityId] = []; |
| 183 | 183 | } |
| 184 | 184 | $result[$entityId][] = $entity; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | protected function getRemainingRelations($relations) |
| 227 | 227 | { |
| 228 | - if ( ! is_array($relations)) { |
|
| 228 | + if (!is_array($relations)) { |
|
| 229 | 229 | return $relations; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | if (is_array($guards)) { |
| 247 | 247 | foreach ($guards as $col => $val) { |
| 248 | 248 | // guards that are strings (eg: 'deleted_at is null') can't be used as extra columns |
| 249 | - if ( ! is_int($col)) { |
|
| 249 | + if (!is_int($col)) { |
|
| 250 | 250 | $cols[$col] = $val; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | protected function addActionOnDelete(BaseAction $action) |
| 26 | 26 | { |
| 27 | 27 | // no cascade delete? treat it as a save |
| 28 | - if ( ! $this->isCascade()) { |
|
| 28 | + if (!$this->isCascade()) { |
|
| 29 | 29 | $this->addActionOnSave($action); |
| 30 | 30 | } else { |
| 31 | 31 | $foreignEntity = $this->nativeEntityHydrator->get($action->getEntity(), $this->name); |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | protected function addActionOnSave(BaseAction $action) |
| 44 | 44 | { |
| 45 | - if ( ! $this->relationWasChanged($action->getEntity())) { |
|
| 45 | + if (!$this->relationWasChanged($action->getEntity())) { |
|
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if ( ! $action->includesRelation($this->name)) { |
|
| 49 | + if (!$action->includesRelation($this->name)) { |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |