@@ -213,7 +213,7 @@ |
||
213 | 213 | $midgard = midgard_connection::get_instance(); |
214 | 214 | if ($midgard->config->logfilename) { |
215 | 215 | $logdir = dirname($midgard->config->logfilename); |
216 | - if ( !is_dir($logdir) |
|
216 | + if (!is_dir($logdir) |
|
217 | 217 | && !mkdir($logdir, 0777, true)) { |
218 | 218 | throw exception::user_data('Log directory could not be created'); |
219 | 219 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $mgd_config = midgard_connection::get_instance()->config; |
57 | 57 | $mgdschema_file = $mgd_config->vardir . '/mgdschema_classes.php'; |
58 | - if ( file_exists($mgdschema_file) |
|
58 | + if (file_exists($mgdschema_file) |
|
59 | 59 | && !unlink($mgdschema_file)) { |
60 | 60 | throw new \RuntimeException('Could not unlink ' . $mgdschema_file); |
61 | 61 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $cms = $em->getMetadataFactory()->getAllMetadata(); |
73 | 73 | |
74 | 74 | // create storage |
75 | - if ( !midgard_storage::create_base_storage() |
|
75 | + if (!midgard_storage::create_base_storage() |
|
76 | 76 | && midgard_connection::get_instance()->get_error_string() != 'MGD_ERR_OK') { |
77 | 77 | throw new \Exception("Failed to create base database structures" . midgard_connection::get_instance()->get_error_string()); |
78 | 78 | } |
@@ -174,7 +174,7 @@ |
||
174 | 174 | break; |
175 | 175 | } |
176 | 176 | if ( $default !== null |
177 | - // we need to skip working links because in this case, Doctrine expects objects as values |
|
177 | + // we need to skip working links because in this case, Doctrine expects objects as values |
|
178 | 178 | && ( !$property->link |
179 | 179 | || $this->manager->resolve_targetclass($property) === false)) { |
180 | 180 | $line .= ' = ' . $default; |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | $types = $this->manager->get_types(); |
71 | - uasort($types, function ($a, $b) { |
|
72 | - if ( !empty($a->extends) |
|
71 | + uasort($types, function($a, $b) { |
|
72 | + if (!empty($a->extends) |
|
73 | 73 | && !empty($b->extends)) { |
74 | 74 | return strnatcmp($a->extends, $b->extends); |
75 | 75 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $prefix = $this->get_class_prefix($namespace); |
113 | 113 | |
114 | 114 | foreach ($this->manager->get_types() as $type) { |
115 | - if ( $prefix !== '' |
|
115 | + if ($prefix !== '' |
|
116 | 116 | && !class_exists($type->name)) { |
117 | 117 | $this->add_line('class_alias( "' . $prefix . $type->name . '", "' . $type->name . '");'); |
118 | 118 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | foreach ($this->manager->get_inherited_mapping() as $child => $parent) { |
122 | 122 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $prefix . $child . '");'); |
123 | - if ( $prefix !== '' |
|
123 | + if ($prefix !== '' |
|
124 | 124 | && !class_exists($child)) { |
125 | 125 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $child . '");'); |
126 | 126 | } |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | $objects[$name] = 'new midgard_datetime("0001-01-01 00:00:00")'; |
182 | 182 | break; |
183 | 183 | } |
184 | - if ( $default !== null |
|
184 | + if ($default !== null |
|
185 | 185 | // we need to skip working links because in this case, Doctrine expects objects as values |
186 | - && ( !$property->link |
|
186 | + && (!$property->link |
|
187 | 187 | || $this->manager->resolve_targetclass($property) === false)) { |
188 | 188 | $line .= ' = ' . $default; |
189 | 189 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->write_annotations($type); |
244 | 244 | $this->add_line('class ' . $type->name . ' extends ' . $type->extends); |
245 | 245 | $mixins = $type->get_mixins(); |
246 | - $interfaces = array_filter(array_map(function ($name) { |
|
246 | + $interfaces = array_filter(array_map(function($name) { |
|
247 | 247 | if (interface_exists('\\midgard\\portable\\storage\\interfaces\\' . $name)) { |
248 | 248 | return '\\midgard\\portable\\storage\\interfaces\\' . $name; |
249 | 249 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | } else { |
66 | 66 | if ($property->parentfield) { |
67 | 67 | $this->parentfield = $property->name; |
68 | - if ( empty($this->parent) |
|
68 | + if (empty($this->parent) |
|
69 | 69 | && $property->link) { |
70 | 70 | $this->parent = $property->link['target']; |
71 | 71 | } |
@@ -201,19 +201,19 @@ |
||
201 | 201 | break; |
202 | 202 | } |
203 | 203 | |
204 | - if ( $dbobject->id > 0 |
|
204 | + if ($dbobject->id > 0 |
|
205 | 205 | && $dbobject->metadata->revised->format('U') >= $object->metadata->revised->format('U')) { |
206 | 206 | midgard_connection::get_instance()->set_error(exception::OBJECT_IMPORTED); |
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - if ( $dbobject->metadata->deleted |
|
210 | + if ($dbobject->metadata->deleted |
|
211 | 211 | && !$object->metadata->deleted) { |
212 | 212 | if (!midgard_object_class::undelete($dbobject->guid)) { |
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | $dbobject->metadata_deleted = false; |
216 | - } elseif ( !$dbobject->metadata->deleted |
|
216 | + } elseif (!$dbobject->metadata->deleted |
|
217 | 217 | && $object->metadata->deleted) { |
218 | 218 | return $dbobject->delete(); |
219 | 219 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | } else { |
261 | 261 | $mrp = new \midgard_reflection_property($targetclass); |
262 | 262 | |
263 | - if ( !$mrp->is_link($part) |
|
263 | + if (!$mrp->is_link($part) |
|
264 | 264 | && !$mrp->is_special_link($part)) { |
265 | 265 | throw exception::ok(); |
266 | 266 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $column = $cm->midgard['field_aliases'][$column]; |
278 | 278 | } |
279 | 279 | |
280 | - if ( !$cm->hasField($column) |
|
280 | + if (!$cm->hasField($column) |
|
281 | 281 | && !$cm->hasAssociation($column)) { |
282 | 282 | throw exception::ok(); |
283 | 283 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $expression = $operator . '( ?' . $this->parameters . ')'; |
299 | 299 | } |
300 | 300 | |
301 | - if ( $value === 0 |
|
301 | + if ($value === 0 |
|
302 | 302 | || $value === null |
303 | 303 | || is_array($value)) { |
304 | 304 | $cm = connection::get_em()->getClassMetadata($parsed['targetclass']); |
@@ -75,7 +75,7 @@ |
||
75 | 75 | |
76 | 76 | $fqcn = $this->get_fcqn($property->link['target']); |
77 | 77 | |
78 | - if ( isset($this->types[$fqcn]) |
|
78 | + if (isset($this->types[$fqcn]) |
|
79 | 79 | || $property->link['target'] === $property->get_parent()->name) { |
80 | 80 | return $property->link['target']; |
81 | 81 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | $parsed = $this->parse_constraint_name($property); |
74 | 74 | |
75 | 75 | // for properties like up.name |
76 | - if ( strpos($property, ".") !== false |
|
76 | + if (strpos($property, ".") !== false |
|
77 | 77 | && !(strpos($property, "metadata") === 0)) { |
78 | 78 | return $parsed['name'] . " as " . str_replace(".", "_", $property); |
79 | 79 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | public function __get($field) |
80 | 80 | { |
81 | - if ( $field === 'metadata' |
|
81 | + if ($field === 'metadata' |
|
82 | 82 | && $this->metadata === null |
83 | 83 | && $this instanceof metadata_interface) { |
84 | 84 | $this->metadata = new metadata($this); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | foreach ($candidates as $candidate) { |
101 | 101 | if ($this->$candidate !== null) { |
102 | 102 | //Proxies become stale if the object itself is detached, so we have to re-fetch |
103 | - if ( $this->$candidate instanceof Proxy |
|
103 | + if ($this->$candidate instanceof Proxy |
|
104 | 104 | && $this->$candidate->__isInitialized()) { |
105 | 105 | try { |
106 | 106 | $this->$candidate->get_by_id($this->$candidate->id); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | // According to Doctrine documentation, proxies should be transparent, but in practice, |
130 | 130 | // there will be problems if we don't force-load |
131 | - if ( $entity instanceof Proxy |
|
131 | + if ($entity instanceof Proxy |
|
132 | 132 | && !$entity->__isInitialized()) { |
133 | 133 | try { |
134 | 134 | $entity->__load(); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | exception::duplicate(); |
182 | 182 | return false; |
183 | 183 | } |
184 | - if ( !$this->is_unique() |
|
184 | + if (!$this->is_unique() |
|
185 | 185 | || !$this->check_parent()) { |
186 | 186 | return false; |
187 | 187 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | midgard_connection::get_instance()->set_error(MGD_ERR_INVALID_PROPERTY_VALUE); |
238 | 238 | return false; |
239 | 239 | } |
240 | - if ( $check_dependencies |
|
240 | + if ($check_dependencies |
|
241 | 241 | && $this->has_dependents()) { |
242 | 242 | exception::has_dependants(); |
243 | 243 | return false; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | { |
329 | 329 | $this->initialize(); |
330 | 330 | |
331 | - if ( empty($this->cm->midgard['parentfield']) |
|
331 | + if (empty($this->cm->midgard['parentfield']) |
|
332 | 332 | || empty($this->cm->midgard['parent'])) { |
333 | 333 | return true; |
334 | 334 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $this->initialize(); |
346 | 346 | |
347 | 347 | foreach ($this->cm->fieldMappings as $name => $field) { |
348 | - if ( $field['midgard:midgard_type'] == translator::TYPE_GUID |
|
348 | + if ($field['midgard:midgard_type'] == translator::TYPE_GUID |
|
349 | 349 | && !empty($this->$name) |
350 | 350 | && !mgd_is_guid($this->$name)) { |
351 | 351 | exception::invalid_property_value("'" . $name . "' property's value is not a guid."); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | |
358 | 358 | private function check_upfield() : bool |
359 | 359 | { |
360 | - if ( !empty($this->id) |
|
360 | + if (!empty($this->id) |
|
361 | 361 | && !empty($this->cm->midgard['upfield']) |
362 | 362 | && $this->__get($this->cm->midgard['upfield']) === $this->id |
363 | 363 | && $this->cm->getAssociationMapping($this->cm->midgard['upfield'])['targetEntity'] === $this->cm->getName()) { |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $stat = $results > 0; |
395 | 395 | } |
396 | 396 | |
397 | - if ( !$stat |
|
397 | + if (!$stat |
|
398 | 398 | && !empty($this->cm->midgard['childtypes'])) { |
399 | 399 | foreach ($this->cm->midgard['childtypes'] as $typename => $parentfield) { |
400 | 400 | $qb = connection::get_em()->createQueryBuilder(); |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | exception::not_exists(); |
744 | 744 | return false; |
745 | 745 | } |
746 | - if ( $check_dependencies |
|
746 | + if ($check_dependencies |
|
747 | 747 | && $this->has_dependents()) { |
748 | 748 | exception::has_dependants(); |
749 | 749 | return false; |