@@ -39,27 +39,27 @@ |
||
39 | 39 | { |
40 | 40 | $errors = []; |
41 | 41 | |
42 | - if (! $this->entityNamespace) { |
|
42 | + if (!$this->entityNamespace) { |
|
43 | 43 | $errors[] = 'Missing entity namespace property'; |
44 | 44 | } |
45 | 45 | |
46 | - if (! $this->entityDestination) { |
|
46 | + if (!$this->entityDestination) { |
|
47 | 47 | $errors[] = 'Missing entity destination property'; |
48 | - } elseif (! is_dir($this->entityDestination)) { |
|
48 | + } elseif (!is_dir($this->entityDestination)) { |
|
49 | 49 | $errors[] = sprintf('%s is not a valid directory', $this->entityDestination); |
50 | - } elseif (! is_writable($this->entityDestination)) { |
|
50 | + } elseif (!is_writable($this->entityDestination)) { |
|
51 | 51 | $errors[] = sprintf('%s is not writable', $this->entityDestination); |
52 | 52 | } |
53 | 53 | |
54 | - if (! $this->mapperNamespace) { |
|
54 | + if (!$this->mapperNamespace) { |
|
55 | 55 | $errors[] = 'Missing mapper namespace property'; |
56 | 56 | } |
57 | 57 | |
58 | - if (! $this->mapperDestination) { |
|
58 | + if (!$this->mapperDestination) { |
|
59 | 59 | $errors[] = 'Missing entity destination property'; |
60 | - } elseif (! is_dir($this->mapperDestination)) { |
|
60 | + } elseif (!is_dir($this->mapperDestination)) { |
|
61 | 61 | $errors[] = sprintf('%s is not a valid directory', $this->mapperDestination); |
62 | - } elseif (! is_writable($this->mapperDestination)) { |
|
62 | + } elseif (!is_writable($this->mapperDestination)) { |
|
63 | 63 | $errors[] = sprintf('%s is not writable', $this->mapperDestination); |
64 | 64 | } |
65 | 65 |
@@ -49,28 +49,28 @@ discard block |
||
49 | 49 | { |
50 | 50 | $errors = []; |
51 | 51 | |
52 | - if (! $this->name) { |
|
52 | + if (!$this->name) { |
|
53 | 53 | $errors[] = "Unknown relation name"; |
54 | 54 | } |
55 | 55 | |
56 | - if (! $this->type) { |
|
56 | + if (!$this->type) { |
|
57 | 57 | $errors[] = "Unknown relation type"; |
58 | 58 | } |
59 | 59 | |
60 | - if (! $this->nativeKey) { |
|
60 | + if (!$this->nativeKey) { |
|
61 | 61 | $errors[] = "Missing native key column"; |
62 | 62 | } |
63 | 63 | |
64 | - if (! $this->foreignMapper) { |
|
64 | + if (!$this->foreignMapper) { |
|
65 | 65 | $errors[] = "Missing foreign mapper name"; |
66 | 66 | } |
67 | 67 | |
68 | - if (! $this->foreignKey) { |
|
68 | + if (!$this->foreignKey) { |
|
69 | 69 | $errors[] = "Missing foreign key"; |
70 | 70 | } |
71 | 71 | |
72 | 72 | $strategies = [RelationConfig::LOAD_LAZY, RelationConfig::LOAD_EAGER, RelationConfig::LOAD_NONE]; |
73 | - if (! in_array($this->loadStrategy, $strategies)) { |
|
73 | + if (!in_array($this->loadStrategy, $strategies)) { |
|
74 | 74 | $errors[] = sprintf("Relation loading strategy is not valid (allowed values: %s)", implode(', ', $strategies)); |
75 | 75 | } |
76 | 76 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $value !== 0 && |
206 | 206 | $value !== '' && |
207 | 207 | $value !== [] && |
208 | - ! is_object($value)) { |
|
208 | + !is_object($value)) { |
|
209 | 209 | $result[Str::underscore($prop)] = $value; |
210 | 210 | } |
211 | 211 | if (is_object($value) && is_callable($value)) { |
@@ -32,11 +32,11 @@ |
||
32 | 32 | { |
33 | 33 | $errors = []; |
34 | 34 | |
35 | - if (! $this->name) { |
|
35 | + if (!$this->name) { |
|
36 | 36 | $errors[] = 'Method requires a name'; |
37 | 37 | } |
38 | 38 | |
39 | - if (! in_array($this->visibility, [ClassType::VISIBILITY_PUBLIC, ClassType::VISIBILITY_PROTECTED])) { |
|
39 | + if (!in_array($this->visibility, [ClassType::VISIBILITY_PUBLIC, ClassType::VISIBILITY_PROTECTED])) { |
|
40 | 40 | $errors[] = 'Wrong method visilibity type. Only `public` and `protected` are allowed.'; |
41 | 41 | } |
42 | 42 |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | return $this; |
139 | 139 | } |
140 | 140 | |
141 | - if (! $this->mapper->hasRelation($name)) { |
|
141 | + if (!$this->mapper->hasRelation($name)) { |
|
142 | 142 | throw new \InvalidArgumentException( |
143 | 143 | sprintf("Relation %s, not defined for %s", $name, $this->mapper->getConfig()->getTable()) |
144 | 144 | ); |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | return null; |
201 | 201 | } |
202 | 202 | |
203 | - $receivedTracker = ! ! $tracker; |
|
204 | - if (! $tracker) { |
|
203 | + $receivedTracker = !!$tracker; |
|
204 | + if (!$tracker) { |
|
205 | 205 | $receivedTracker = false; |
206 | 206 | $tracker = new Tracker([$data]); |
207 | 207 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $this->injectAggregates($entity, $tracker, $load); |
212 | 212 | $entity->setState(StateEnum::SYNCHRONIZED); |
213 | 213 | |
214 | - if (! $receivedTracker) { |
|
214 | + if (!$receivedTracker) { |
|
215 | 215 | $tracker->replaceRows([$entity]); |
216 | 216 | } |
217 | 217 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $queryCallback = $eagerLoad[$name] ?? null; |
263 | 263 | $nextLoad = Arr::getChildren($eagerLoad, $name); |
264 | 264 | |
265 | - if (! $tracker->hasRelation($name)) { |
|
265 | + if (!$tracker->hasRelation($name)) { |
|
266 | 266 | $tracker->setRelation($name, $relation, $queryCallback, $nextLoad); |
267 | 267 | } |
268 | 268 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | { |
279 | 279 | foreach ($this->mapper->getRelations() as $name) { |
280 | 280 | $relation = $this->mapper->getRelation($name); |
281 | - if (! method_exists($relation, 'getAggregates')) { |
|
281 | + if (!method_exists($relation, 'getAggregates')) { |
|
282 | 282 | continue; |
283 | 283 | } |
284 | 284 | $aggregates = $relation->getAggregates(); |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function chunk(int $size, callable $callback, int $limit = 100000) |
309 | 309 | { |
310 | - if (! $this->orderBy->build()) { |
|
310 | + if (!$this->orderBy->build()) { |
|
311 | 311 | $this->orderBy(...(array)$this->mapper->getConfig()->getPrimaryKey()); |
312 | 312 | } |
313 | 313 |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | { |
146 | 146 | $this->namespace->addUse($this->mapper->getEntityNamespace() . '\\' . $this->mapper->getEntityClass()); |
147 | 147 | $method = $this->class->addMethod('find') |
148 | - ->setReturnNullable(true) |
|
149 | - ->setReturnType($this->mapper->getEntityClass()); |
|
148 | + ->setReturnNullable(true) |
|
149 | + ->setReturnType($this->mapper->getEntityClass()); |
|
150 | 150 | $method->addParameter('pk'); |
151 | 151 | $method->addParameter('load', [])->setType('array'); |
152 | 152 | $method->setBody('return $this->newQuery()->find($pk, $load);'); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | protected function addNewQueryMethod() |
156 | 156 | { |
157 | 157 | $method = $this->class->addMethod('newQuery') |
158 | - ->setReturnType($this->mapper->getQueryClass()); |
|
158 | + ->setReturnType($this->mapper->getQueryClass()); |
|
159 | 159 | $method->addBody(sprintf('$query = new %s($this->getReadConnection(), $this);', $this->mapper->getQueryClass())); |
160 | 160 | $method->addBody('return $this->behaviours->apply($this, __FUNCTION__, $query);'); |
161 | 161 | } |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | protected function addNewSubselectQueryMethod() |
164 | 164 | { |
165 | 165 | $method = $this->class->addMethod('newSubselectQuery') |
166 | - ->setReturnType($this->mapper->getQueryClass()); |
|
166 | + ->setReturnType($this->mapper->getQueryClass()); |
|
167 | 167 | $this->class->getNamespace()->addUse(Connection::class, null, $connectionAlias); |
168 | 168 | $method->addParameter('connection') |
169 | - ->setType($connectionAlias); |
|
169 | + ->setType($connectionAlias); |
|
170 | 170 | $this->class->getNamespace()->addUse(Bindings::class, null, $bindingsAlias); |
171 | 171 | $method->addParameter('bindings') |
172 | - ->setType($bindingsAlias); |
|
172 | + ->setType($bindingsAlias); |
|
173 | 173 | $method->addParameter('indent') |
174 | - ->setType('string'); |
|
174 | + ->setType('string'); |
|
175 | 175 | $method->addBody(sprintf('$query = new %s($this->getReadConnection(), $this, $bindings, $indent);', $this->mapper->getQueryClass())); |
176 | 176 | $method->addBody('return $this->behaviours->apply($this, __FUNCTION__, $query);'); |
177 | 177 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $this->namespace->addUse(StateEnum::class); |
184 | 184 | |
185 | 185 | $method = $this->class->addMethod('save') |
186 | - ->setReturnType('bool'); |
|
186 | + ->setReturnType('bool'); |
|
187 | 187 | $method->addParameter('entity')->setType($this->mapper->getEntityClass()); |
188 | 188 | $method->addParameter('withRelations', false); |
189 | 189 | $method->setBody(' |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | protected function addDeleteMethod() |
222 | 222 | { |
223 | 223 | $method = $this->class->addMethod('delete') |
224 | - ->setReturnType('bool'); |
|
224 | + ->setReturnType('bool'); |
|
225 | 225 | $method->addParameter('entity')->setType($this->mapper->getEntityClass()); |
226 | 226 | $method->addParameter('withRelations', false); |
227 | 227 | $method->setBody(' |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | unset($this->lazyMappers[$name]); |
100 | 100 | } |
101 | 101 | |
102 | - if (! isset($this->mappers[$name]) || ! $this->mappers[$name]) { |
|
102 | + if (!isset($this->mappers[$name]) || !$this->mappers[$name]) { |
|
103 | 103 | throw new InvalidArgumentException(sprintf('Mapper named %s is not registered', $name)); |
104 | 104 | } |
105 | 105 | |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | $mapper = $this->mapperLocator->get($mapperConfigOrFactory); |
131 | 131 | } |
132 | 132 | |
133 | - if (! $mapper) { |
|
133 | + if (!$mapper) { |
|
134 | 134 | throw new InvalidArgumentException( |
135 | 135 | 'The mapper could not be generated/retrieved.' |
136 | 136 | ); |
137 | 137 | } |
138 | 138 | |
139 | - if (! $mapper instanceof Mapper) { |
|
139 | + if (!$mapper instanceof Mapper) { |
|
140 | 140 | throw new InvalidArgumentException( |
141 | 141 | 'The mapper generated from the factory is not a valid `Mapper` instance.' |
142 | 142 | ); |
@@ -115,8 +115,8 @@ |
||
115 | 115 | |
116 | 116 | $insert = new \Sirius\Sql\Insert($conn); |
117 | 117 | $insert->into($pivotTable) |
118 | - ->columns($insertColumns) |
|
119 | - ->perform(); |
|
118 | + ->columns($insertColumns) |
|
119 | + ->perform(); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | protected function getNativeEntityHydrator() |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | protected function maybeUpdatePivotRow() |
70 | 70 | { |
71 | - if (! $this->relation instanceof ManyToMany) { |
|
71 | + if (!$this->relation instanceof ManyToMany) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $delete->where($pivotForeignColumns[$k], $foreignKey[$k]); |
89 | 89 | } |
90 | 90 | foreach ((array)$this->relation->getOption(RelationConfig::PIVOT_GUARDS) as $col => $value) { |
91 | - if (! is_int($col)) { |
|
91 | + if (!is_int($col)) { |
|
92 | 92 | $delete->where($col, $value); |
93 | 93 | } else { |
94 | 94 | $delete->where($value); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | foreach ((array)$this->relation->getOption(RelationConfig::PIVOT_GUARDS) as $col => $value) { |
111 | - if (! is_int($col)) { |
|
111 | + if (!is_int($col)) { |
|
112 | 112 | $insertColumns[$col] = $value; |
113 | 113 | } |
114 | 114 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | $conditions = []; |
76 | 76 | |
77 | - $nativeEntityPk = (array)$this->nativeMapper->getConfig()->getPrimaryKey(); |
|
77 | + $nativeEntityPk = (array)$this->nativeMapper->getConfig()->getPrimaryKey(); |
|
78 | 78 | $pivotThroughCols = (array)$this->relation->getOption(RelationConfig::PIVOT_NATIVE_COLUMN); |
79 | 79 | foreach ($nativeEntityPk as $idx => $col) { |
80 | 80 | $val = $this->nativeEntityHydrator->get($this->nativeEntity, $col); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - $entityPk = (array)$this->mapper->getConfig()->getPrimaryKey(); |
|
86 | + $entityPk = (array)$this->mapper->getConfig()->getPrimaryKey(); |
|
87 | 87 | $pivotColumns = (array)$this->relation->getOption(RelationConfig::PIVOT_FOREIGN_COLUMN); |
88 | 88 | foreach ($entityPk as $idx => $col) { |
89 | 89 | $val = $this->entityHydrator->get($this->entity, $col); |
@@ -13,14 +13,14 @@ |
||
13 | 13 | { |
14 | 14 | $foreignMapper = $options[RelationConfig::FOREIGN_MAPPER]; |
15 | 15 | if ($orm->has($foreignMapper)) { |
16 | - if (! $foreignMapper instanceof Mapper) { |
|
16 | + if (!$foreignMapper instanceof Mapper) { |
|
17 | 17 | $foreignMapper = $orm->get($foreignMapper); |
18 | 18 | } |
19 | 19 | } |
20 | 20 | $type = $options[RelationConfig::TYPE]; |
21 | 21 | $relationClass = 'Sirius\\Orm\\Relation\\' . Str::className($type); |
22 | 22 | |
23 | - if (! class_exists($relationClass)) { |
|
23 | + if (!class_exists($relationClass)) { |
|
24 | 24 | throw new InvalidArgumentException("{$relationClass} does not exist"); |
25 | 25 | } |
26 | 26 |