@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | $this->initialize(); |
65 | 65 | $properties = array_merge($this->cm->getFieldNames(), $this->cm->getAssociationNames(), array_keys($this->cm->midgard['field_aliases'])); |
66 | - $properties = array_filter($properties, function ($input) { |
|
66 | + $properties = array_filter($properties, function($input) { |
|
67 | 67 | return strpos($input, 'metadata_') === false; |
68 | 68 | }); |
69 | 69 | $ret = []; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | $this->initialize(); |
80 | 80 | |
81 | - if ( !$this->cm->hasField($field) |
|
81 | + if (!$this->cm->hasField($field) |
|
82 | 82 | && isset($field, $this->cm->midgard['field_aliases'][$field])) { |
83 | 83 | $field = $this->cm->midgard['field_aliases'][$field]; |
84 | 84 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if (empty($value)) { |
89 | 89 | $value = null; |
90 | 90 | } else { |
91 | - if ( !\is_object($this->$field) |
|
91 | + if (!\is_object($this->$field) |
|
92 | 92 | || $this->$field->id != $value) { |
93 | 93 | $this->changed_associations[$field] = true; |
94 | 94 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | } elseif ($this->cm->hasField($field)) { |
99 | 99 | $mapping = $this->cm->getFieldMapping($field); |
100 | 100 | |
101 | - if ( $mapping['type'] === 'string' |
|
101 | + if ($mapping['type'] === 'string' |
|
102 | 102 | || $mapping['type'] == 'text') { |
103 | 103 | $value = (string) $value; |
104 | 104 | } elseif ($mapping['type'] === 'integer') { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } elseif ($mapping['type'] === 'float') { |
109 | 109 | $value = (float) $value; |
110 | 110 | } elseif ($mapping['type'] === 'midgard_datetime') { |
111 | - if ( \is_string($value) |
|
111 | + if (\is_string($value) |
|
112 | 112 | && $value !== '0000-00-00 00:00:00') { |
113 | 113 | $value = new midgard_datetime($value); |
114 | 114 | } elseif (!($value instanceof midgard_datetime)) { |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | { |
125 | 125 | $this->initialize(); |
126 | 126 | |
127 | - if ( !$this->cm->hasField($field) |
|
127 | + if (!$this->cm->hasField($field) |
|
128 | 128 | && array_key_exists($field, $this->cm->midgard['field_aliases'])) { |
129 | 129 | $field = $this->cm->midgard['field_aliases'][$field]; |
130 | 130 | } |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } |
138 | 138 | return 0; |
139 | 139 | } |
140 | - if ( $this->$field === null |
|
140 | + if ($this->$field === null |
|
141 | 141 | && $this->cm->isIdentifier($field)) { |
142 | 142 | return 0; |
143 | 143 | } |
144 | - if ( $this->$field instanceof midgard_datetime |
|
144 | + if ($this->$field instanceof midgard_datetime |
|
145 | 145 | && $this->$field->format('U') == -62169984000) { |
146 | 146 | //This is mainly needed for working with converted Legacy databases. Midgard2 somehow handles this internally |
147 | 147 | //@todo Find a nicer solution and research how QB handles this |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | public function __get($field) |
82 | 82 | { |
83 | - if ( $field === 'metadata' |
|
83 | + if ($field === 'metadata' |
|
84 | 84 | && $this->metadata === null |
85 | 85 | && $this instanceof metadata_interface) { |
86 | 86 | $this->metadata = new metadata($this); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | foreach ($candidates as $candidate) { |
103 | 103 | if ($this->$candidate !== null) { |
104 | 104 | //Proxies become stale if the object itself is detached, so we have to re-fetch |
105 | - if ( $this->$candidate instanceof Proxy |
|
105 | + if ($this->$candidate instanceof Proxy |
|
106 | 106 | && $this->$candidate->__isInitialized()) { |
107 | 107 | try { |
108 | 108 | $this->$candidate->get_by_id($this->$candidate->id); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | // According to Doctrine documentation, proxies should be transparent, but in practice, |
132 | 132 | // there will be problems if we don't force-load |
133 | - if ( $entity instanceof Proxy |
|
133 | + if ($entity instanceof Proxy |
|
134 | 134 | && !$entity->__isInitialized()) { |
135 | 135 | try { |
136 | 136 | $entity->__load(); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | exception::duplicate(); |
184 | 184 | return false; |
185 | 185 | } |
186 | - if ( !$this->is_unique() |
|
186 | + if (!$this->is_unique() |
|
187 | 187 | || !$this->check_parent()) { |
188 | 188 | return false; |
189 | 189 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | midgard_connection::get_instance()->set_error(MGD_ERR_INVALID_PROPERTY_VALUE); |
240 | 240 | return false; |
241 | 241 | } |
242 | - if ( $check_dependencies |
|
242 | + if ($check_dependencies |
|
243 | 243 | && $this->has_dependents()) { |
244 | 244 | exception::has_dependants(); |
245 | 245 | return false; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | { |
331 | 331 | $this->initialize(); |
332 | 332 | |
333 | - if ( empty($this->cm->midgard['parentfield']) |
|
333 | + if (empty($this->cm->midgard['parentfield']) |
|
334 | 334 | || empty($this->cm->midgard['parent'])) { |
335 | 335 | return true; |
336 | 336 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $this->initialize(); |
348 | 348 | |
349 | 349 | foreach ($this->cm->fieldMappings as $name => $field) { |
350 | - if ( $field['midgard:midgard_type'] == translator::TYPE_GUID |
|
350 | + if ($field['midgard:midgard_type'] == translator::TYPE_GUID |
|
351 | 351 | && !empty($this->$name) |
352 | 352 | && !mgd_is_guid($this->$name)) { |
353 | 353 | exception::invalid_property_value("'" . $name . "' property's value is not a guid."); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | private function check_upfield() |
361 | 361 | { |
362 | - if ( !empty($this->id) |
|
362 | + if (!empty($this->id) |
|
363 | 363 | && !empty($this->cm->midgard['upfield']) |
364 | 364 | && $this->__get($this->cm->midgard['upfield']) === $this->id |
365 | 365 | && $this->cm->getAssociationMapping($this->cm->midgard['upfield'])['targetEntity'] === $this->cm->getName()) { |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $stat = $results > 0; |
397 | 397 | } |
398 | 398 | |
399 | - if ( !$stat |
|
399 | + if (!$stat |
|
400 | 400 | && !empty($this->cm->midgard['childtypes'])) { |
401 | 401 | foreach ($this->cm->midgard['childtypes'] as $typename => $parentfield) { |
402 | 402 | $qb = connection::get_em()->createQueryBuilder(); |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | exception::not_exists(); |
756 | 756 | return false; |
757 | 757 | } |
758 | - if ( $check_dependencies |
|
758 | + if ($check_dependencies |
|
759 | 759 | && $this->has_dependents()) { |
760 | 760 | exception::has_dependants(); |
761 | 761 | return false; |
@@ -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 | } |
@@ -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']); |