@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $parsed = $this->parse_constraint_name($property); |
| 71 | 71 | |
| 72 | 72 | // for properties like up.name |
| 73 | - if ( strpos($property, ".") !== false |
|
| 73 | + if (strpos($property, ".") !== false |
|
| 74 | 74 | && !(strpos($property, "metadata") === 0)) |
| 75 | 75 | { |
| 76 | 76 | return $parsed['name'] . " as " . str_replace(".", "_", $property); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function get($key) |
| 156 | 156 | { |
| 157 | - if ( !$this->_has_results() |
|
| 157 | + if (!$this->_has_results() |
|
| 158 | 158 | || !isset($this->_results[$key])) |
| 159 | 159 | { |
| 160 | 160 | return false; |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | use midgard\portable\mgdschema\translator; |
| 10 | 10 | use midgard\portable\api\error\exception; |
| 11 | 11 | |
| 12 | -if ( extension_loaded('midgard') |
|
| 12 | +if (extension_loaded('midgard') |
|
| 13 | 13 | || extension_loaded('midgard2')) |
| 14 | 14 | { |
| 15 | 15 | //TODO: Print some error? |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | $fqcn = $this->namespace . '\\' . $fqcn; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( array_key_exists($fqcn, $this->types) |
|
| 83 | + if (array_key_exists($fqcn, $this->types) |
|
| 84 | 84 | || $property->link['target'] === $property->get_parent()->name) |
| 85 | 85 | { |
| 86 | 86 | $target_class = $property->link['target']; |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | if ($property->parentfield) |
| 77 | 77 | { |
| 78 | 78 | $this->parentfield = $property->name; |
| 79 | - if ( empty($this->parent) |
|
| 79 | + if (empty($this->parent) |
|
| 80 | 80 | && $property->link) |
| 81 | 81 | { |
| 82 | 82 | $this->parent = $property->link['target']; |
@@ -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 >= $object->metadata->revised) { |
| 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 | } |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $types = $this->manager->get_types(); |
| 66 | - uasort($types, function ($a, $b) { |
|
| 67 | - if ( !empty($a->extends) |
|
| 66 | + uasort($types, function($a, $b) { |
|
| 67 | + if (!empty($a->extends) |
|
| 68 | 68 | && !empty($b->extends)) { |
| 69 | 69 | return strnatcmp($a->extends, $b->extends); |
| 70 | 70 | } elseif (!empty($a->extends)) { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $prefix = $this->get_class_prefix($namespace); |
| 106 | 106 | |
| 107 | 107 | foreach ($this->manager->get_types() as $type) { |
| 108 | - if ( $prefix !== '' |
|
| 108 | + if ($prefix !== '' |
|
| 109 | 109 | && !class_exists($type->name)) { |
| 110 | 110 | $this->add_line('class_alias( "' . $prefix . $type->name . '", "' . $type->name . '");'); |
| 111 | 111 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | foreach ($this->manager->get_inherited_mapping() as $child => $parent) { |
| 115 | 115 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $prefix . $child . '");'); |
| 116 | - if ( $prefix !== '' |
|
| 116 | + if ($prefix !== '' |
|
| 117 | 117 | && !class_exists($child)) { |
| 118 | 118 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $child . '");'); |
| 119 | 119 | } |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | $objects[$name] = 'new midgard_datetime("0001-01-01 00:00:00")'; |
| 178 | 178 | break; |
| 179 | 179 | } |
| 180 | - if ( $default !== null |
|
| 180 | + if ($default !== null |
|
| 181 | 181 | // we need to skip working links because in this case, Doctrine expects objects as values |
| 182 | - && ( !$property->link |
|
| 182 | + && (!$property->link |
|
| 183 | 183 | || $this->manager->resolve_targetclass($property) === false)) { |
| 184 | 184 | $line .= ' = ' . $default; |
| 185 | 185 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $this->add_line('class ' . $type->name . ' extends ' . $type->extends); |
| 225 | 225 | $mixins = $type->get_mixins(); |
| 226 | - $interfaces = array_filter(array_map(function ($name) { |
|
| 226 | + $interfaces = array_filter(array_map(function($name) { |
|
| 227 | 227 | if (interface_exists('\\midgard\\portable\\storage\\' . $name . '\\entity')) { |
| 228 | 228 | return '\\midgard\\portable\\storage\\' . $name . '\\entity'; |
| 229 | 229 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | private function load_by_properties(array $properties) |
| 63 | 63 | { |
| 64 | - if ( !array_key_exists('authtype', $properties) |
|
| 64 | + if (!array_key_exists('authtype', $properties) |
|
| 65 | 65 | || !array_key_exists('login', $properties)) { |
| 66 | 66 | throw exception::invalid_property_value(); |
| 67 | 67 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | public function &get_person() |
| 111 | 111 | { |
| 112 | - if ( $this->person_object === null |
|
| 112 | + if ($this->person_object === null |
|
| 113 | 113 | && $this->person !== null) { |
| 114 | 114 | $this->person_object = connection::get_em()->getRepository('midgard:midgard_person')->findOneBy(array('guid' => $this->person)); |
| 115 | 115 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | public function create() |
| 120 | 120 | { |
| 121 | - if ( empty($this->authtype) |
|
| 121 | + if (empty($this->authtype) |
|
| 122 | 122 | || !empty($this->id)) { |
| 123 | 123 | exception::invalid_property_value(); |
| 124 | 124 | return false; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | protected function is_unique() |
| 184 | 184 | { |
| 185 | - if ( empty($this->login) |
|
| 185 | + if (empty($this->login) |
|
| 186 | 186 | || empty($this->authtype)) { |
| 187 | 187 | return true; |
| 188 | 188 | } |
@@ -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 = array(); |
@@ -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 | && array_key_exists($field, $this->cm->midgard['field_aliases'])) { |
| 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 |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | public function __get($field) |
| 79 | 79 | { |
| 80 | - if ( $field === 'metadata' |
|
| 80 | + if ($field === 'metadata' |
|
| 81 | 81 | && property_exists($this, 'metadata') |
| 82 | 82 | && $this->metadata === null) { |
| 83 | 83 | $this->metadata = new metadata($this); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | foreach ($candidates as $candidate) { |
| 100 | 100 | if ($this->$candidate !== null) { |
| 101 | 101 | //Proxies become stale if the object itself is detached, so we have to re-fetch |
| 102 | - if ( $this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 102 | + if ($this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 103 | 103 | && $this->$candidate->__isInitialized()) { |
| 104 | 104 | try { |
| 105 | 105 | $this->$candidate->get_by_id($this->$candidate->id); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | // According to Doctrine documentation, proxies should be transparent, but in practice, |
| 125 | 125 | // there will be problems if we don't force-load |
| 126 | - if ( $entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 126 | + if ($entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 127 | 127 | && !$entity->__isInitialized()) { |
| 128 | 128 | try { |
| 129 | 129 | $entity->__load(); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | exception::duplicate(); |
| 170 | 170 | return false; |
| 171 | 171 | } |
| 172 | - if ( !$this->is_unique() |
|
| 172 | + if (!$this->is_unique() |
|
| 173 | 173 | || !$this->check_parent()) { |
| 174 | 174 | return false; |
| 175 | 175 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | midgard_connection::get_instance()->set_error(MGD_ERR_INVALID_PROPERTY_VALUE); |
| 221 | 221 | return false; |
| 222 | 222 | } |
| 223 | - if ( $check_dependencies |
|
| 223 | + if ($check_dependencies |
|
| 224 | 224 | && $this->has_dependents()) { |
| 225 | 225 | exception::has_dependants(); |
| 226 | 226 | return false; |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | { |
| 303 | 303 | $this->initialize(); |
| 304 | 304 | |
| 305 | - if ( empty($this->cm->midgard['parentfield']) |
|
| 305 | + if (empty($this->cm->midgard['parentfield']) |
|
| 306 | 306 | || empty($this->cm->midgard['parent'])) { |
| 307 | 307 | return true; |
| 308 | 308 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $this->initialize(); |
| 320 | 320 | |
| 321 | 321 | foreach ($this->cm->fieldMappings as $name => $field) { |
| 322 | - if ( $field['midgard:midgard_type'] == translator::TYPE_GUID |
|
| 322 | + if ($field['midgard:midgard_type'] == translator::TYPE_GUID |
|
| 323 | 323 | && !empty($this->$name) |
| 324 | 324 | && !mgd_is_guid($this->$name)) { |
| 325 | 325 | exception::invalid_property_value("'" . $name . "' property's value is not a guid."); |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $stat = ($results > 0); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - if ( !$stat |
|
| 358 | + if (!$stat |
|
| 359 | 359 | && !empty($this->cm->midgard['childtypes'])) { |
| 360 | 360 | foreach ($this->cm->midgard['childtypes'] as $typename => $parentfield) { |
| 361 | 361 | $qb = connection::get_em()->createQueryBuilder(); |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | exception::not_exists(); |
| 685 | 685 | return false; |
| 686 | 686 | } |
| 687 | - if ( $check_dependencies |
|
| 687 | + if ($check_dependencies |
|
| 688 | 688 | && $this->has_dependents()) { |
| 689 | 689 | exception::has_dependants(); |
| 690 | 690 | return false; |