@@ -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); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | exception::duplicate(); |
172 | 172 | return false; |
173 | 173 | } |
174 | - if ( !$this->is_unique() |
|
174 | + if (!$this->is_unique() |
|
175 | 175 | || !$this->check_parent()) { |
176 | 176 | return false; |
177 | 177 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | exception::invalid_property_value(); |
220 | 220 | return false; |
221 | 221 | } |
222 | - if ( $check_dependencies |
|
222 | + if ($check_dependencies |
|
223 | 223 | && $this->has_dependents()) { |
224 | 224 | exception::has_dependants(); |
225 | 225 | return false; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | { |
305 | 305 | $this->initialize(); |
306 | 306 | |
307 | - if ( empty($this->cm->midgard['parentfield']) |
|
307 | + if (empty($this->cm->midgard['parentfield']) |
|
308 | 308 | || empty($this->cm->midgard['parent'])) { |
309 | 309 | return true; |
310 | 310 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $this->initialize(); |
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."); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | |
334 | 334 | private function check_upfield() : bool |
335 | 335 | { |
336 | - if ( !empty($this->id) |
|
336 | + if (!empty($this->id) |
|
337 | 337 | && !empty($this->cm->midgard['upfield']) |
338 | 338 | && $this->__get($this->cm->midgard['upfield']) === $this->id |
339 | 339 | && $this->cm->getAssociationMapping($this->cm->midgard['upfield'])['targetEntity'] === $this->cm->getName()) { |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $stat = $results > 0; |
371 | 371 | } |
372 | 372 | |
373 | - if ( !$stat |
|
373 | + if (!$stat |
|
374 | 374 | && !empty($this->cm->midgard['childtypes'])) { |
375 | 375 | foreach ($this->cm->midgard['childtypes'] as $typename => $parentfield) { |
376 | 376 | $qb = connection::get_em()->createQueryBuilder(); |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | exception::not_exists(); |
680 | 680 | return false; |
681 | 681 | } |
682 | - if ( $check_dependencies |
|
682 | + if ($check_dependencies |
|
683 | 683 | && $this->has_dependents()) { |
684 | 684 | exception::has_dependants(); |
685 | 685 | return false; |
@@ -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 | } |