@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | } else { |
253 | 253 | $mrp = new \midgard_reflection_property($targetclass); |
254 | 254 | |
255 | - if ( !$mrp->is_link($part) |
|
255 | + if (!$mrp->is_link($part) |
|
256 | 256 | && !$mrp->is_special_link($part)) { |
257 | 257 | throw exception::invalid_property($part); |
258 | 258 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $column = $cm->midgard['field_aliases'][$column]; |
270 | 270 | } |
271 | 271 | |
272 | - if ( !$cm->hasField($column) |
|
272 | + if (!$cm->hasField($column) |
|
273 | 273 | && !$cm->hasAssociation($column)) { |
274 | 274 | throw exception::invalid_property($column); |
275 | 275 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $expression = $operator . '( ?' . $this->parameters . ')'; |
291 | 291 | } |
292 | 292 | |
293 | - if ( $value === 0 |
|
293 | + if ($value === 0 |
|
294 | 294 | || $value === null |
295 | 295 | || is_array($value)) { |
296 | 296 | $cm = connection::get_em()->getClassMetadata($parsed['targetclass']); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | { |
57 | 57 | $this->initialize(); |
58 | 58 | $properties = array_merge($this->cm->getFieldNames(), $this->cm->getAssociationNames(), array_keys($this->cm->midgard['field_aliases'])); |
59 | - $properties = array_filter($properties, function ($input) { |
|
59 | + $properties = array_filter($properties, function($input) { |
|
60 | 60 | return !str_contains($input, 'metadata_'); |
61 | 61 | }); |
62 | 62 | $ret = []; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | { |
72 | 72 | $this->initialize(); |
73 | 73 | |
74 | - if ( !$this->cm->hasField($field) |
|
74 | + if (!$this->cm->hasField($field) |
|
75 | 75 | && isset($this->cm->midgard['field_aliases'][$field])) { |
76 | 76 | $field = $this->cm->midgard['field_aliases'][$field]; |
77 | 77 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if (empty($value)) { |
82 | 82 | $value = null; |
83 | 83 | } else { |
84 | - if ( !\is_object($this->$field) |
|
84 | + if (!\is_object($this->$field) |
|
85 | 85 | || $this->$field->id != $value) { |
86 | 86 | $this->changed_associations[$field] = true; |
87 | 87 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } elseif ($this->cm->hasField($field)) { |
92 | 92 | $mapping = $this->cm->getFieldMapping($field); |
93 | 93 | |
94 | - if ( $mapping['type'] === 'string' |
|
94 | + if ($mapping['type'] === 'string' |
|
95 | 95 | || $mapping['type'] == 'text') { |
96 | 96 | $value = (string) $value; |
97 | 97 | } elseif ($mapping['type'] === 'integer') { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } elseif ($mapping['type'] === 'float') { |
102 | 102 | $value = (float) $value; |
103 | 103 | } elseif (in_array($mapping['type'], ['datetime', 'date'])) { |
104 | - if ( \is_string($value) |
|
104 | + if (\is_string($value) |
|
105 | 105 | && $value !== '0000-00-00 00:00:00') { |
106 | 106 | $value = new midgard_datetime($value); |
107 | 107 | } elseif (!($value instanceof midgard_datetime)) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $this->initialize(); |
119 | 119 | |
120 | - if ( !$this->cm->hasField($field) |
|
120 | + if (!$this->cm->hasField($field) |
|
121 | 121 | && isset($this->cm->midgard['field_aliases'][$field])) { |
122 | 122 | $field = $this->cm->midgard['field_aliases'][$field]; |
123 | 123 | } |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | } |
131 | 131 | return 0; |
132 | 132 | } |
133 | - if ( $this->$field === null |
|
133 | + if ($this->$field === null |
|
134 | 134 | && $this->cm->isIdentifier($field)) { |
135 | 135 | return 0; |
136 | 136 | } |
137 | - if ( $this->$field instanceof midgard_datetime |
|
137 | + if ($this->$field instanceof midgard_datetime |
|
138 | 138 | && $this->$field->format('U') == -62169984000) { |
139 | 139 | //This is mainly needed for working with converted Legacy databases. Midgard2 somehow handles this internally |
140 | 140 | //@todo Find a nicer solution and research how QB handles this |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $parsed = $this->parse_constraint_name($property); |
60 | 60 | |
61 | 61 | // for properties like up.name |
62 | - if ( str_contains($property, ".") |
|
62 | + if (str_contains($property, ".") |
|
63 | 63 | && !(str_starts_with($property, "metadata"))) { |
64 | 64 | return $parsed['name'] . " as " . str_replace(".", "_", $property); |
65 | 65 | } |
@@ -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); |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | protected function load_parent(array $candidates) : ?dbobject |
99 | 99 | { |
100 | 100 | foreach ($candidates as $candidate) { |
101 | - if ( is_string($this->$candidate) |
|
101 | + if (is_string($this->$candidate) |
|
102 | 102 | && mgd_is_guid($this->$candidate)) { |
103 | 103 | return \midgard_object_class::get_object_by_guid($this->$candidate); |
104 | 104 | } |
105 | 105 | if ($this->$candidate !== null) { |
106 | 106 | //Proxies become stale if the object itself is detached, so we have to re-fetch |
107 | - if ( $this->$candidate instanceof Proxy |
|
107 | + if ($this->$candidate instanceof Proxy |
|
108 | 108 | && $this->$candidate->__isInitialized()) { |
109 | 109 | try { |
110 | 110 | $this->$candidate->get_by_id($this->$candidate->id); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | exception::duplicate(); |
174 | 174 | return false; |
175 | 175 | } |
176 | - if ( !$this->is_unique() |
|
176 | + if (!$this->is_unique() |
|
177 | 177 | || !$this->check_parent()) { |
178 | 178 | return false; |
179 | 179 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | exception::invalid_property_value(); |
225 | 225 | return false; |
226 | 226 | } |
227 | - if ( $check_dependencies |
|
227 | + if ($check_dependencies |
|
228 | 228 | && $this->has_dependents()) { |
229 | 229 | exception::has_dependants(); |
230 | 230 | return false; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | |
307 | 307 | private function check_parent() : bool |
308 | 308 | { |
309 | - if ( empty($this->cm->midgard['parentfield']) |
|
309 | + if (empty($this->cm->midgard['parentfield']) |
|
310 | 310 | || empty($this->cm->midgard['parent'])) { |
311 | 311 | return true; |
312 | 312 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | private function check_fields() : bool |
322 | 322 | { |
323 | 323 | foreach ($this->cm->fieldMappings as $name => $field) { |
324 | - if ( $field['midgard:midgard_type'] == translator::TYPE_GUID |
|
324 | + if ($field['midgard:midgard_type'] == translator::TYPE_GUID |
|
325 | 325 | && !empty($this->$name) |
326 | 326 | && !mgd_is_guid($this->$name)) { |
327 | 327 | exception::invalid_property_value("'" . $name . "' property's value is not a guid."); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | private function check_upfield() : bool |
335 | 335 | { |
336 | 336 | $identifier = $this->cm->getIdentifierValues($this); |
337 | - if ( $identifier |
|
337 | + if ($identifier |
|
338 | 338 | && !empty($this->cm->midgard['upfield']) |
339 | 339 | && $this->__get($this->cm->midgard['upfield']) === reset($identifier) |
340 | 340 | && $this->cm->getAssociationMapping($this->cm->midgard['upfield'])['targetEntity'] === $this->cm->getName()) { |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $stat = $results > 0; |
373 | 373 | } |
374 | 374 | |
375 | - if ( !$stat |
|
375 | + if (!$stat |
|
376 | 376 | && !empty($this->cm->midgard['childtypes'])) { |
377 | 377 | foreach ($this->cm->midgard['childtypes'] as $typename => $parentfield) { |
378 | 378 | $identifier = $this->cm->getIdentifierValues($this); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | exception::not_exists(); |
688 | 688 | return false; |
689 | 689 | } |
690 | - if ( $check_dependencies |
|
690 | + if ($check_dependencies |
|
691 | 691 | && $this->has_dependents()) { |
692 | 692 | exception::has_dependants(); |
693 | 693 | return false; |