@@ -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 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $parsed = $this->parse_constraint_name($property); |
64 | 64 | |
65 | 65 | // for properties like up.name |
66 | - if ( strpos($property, ".") !== false |
|
66 | + if (strpos($property, ".") !== false |
|
67 | 67 | && !(strpos($property, "metadata") === 0)) { |
68 | 68 | return $parsed['name'] . " as " . str_replace(".", "_", $property); |
69 | 69 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function get($key) |
136 | 136 | { |
137 | - if ( !$this->_has_results() |
|
137 | + if (!$this->_has_results() |
|
138 | 138 | || !isset($this->_results[$key])) { |
139 | 139 | return false; |
140 | 140 | } |
@@ -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; |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | $types = $this->manager->get_types(); |
65 | - uasort($types, function ($a, $b) { |
|
66 | - if ( !empty($a->extends) |
|
65 | + uasort($types, function($a, $b) { |
|
66 | + if (!empty($a->extends) |
|
67 | 67 | && !empty($b->extends)) { |
68 | 68 | return strnatcmp($a->extends, $b->extends); |
69 | 69 | } elseif (!empty($a->extends)) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $prefix = $this->get_class_prefix($namespace); |
105 | 105 | |
106 | 106 | foreach ($this->manager->get_types() as $type) { |
107 | - if ( $prefix !== '' |
|
107 | + if ($prefix !== '' |
|
108 | 108 | && !class_exists($type->name)) { |
109 | 109 | $this->add_line('class_alias( "' . $prefix . $type->name . '", "' . $type->name . '");'); |
110 | 110 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | foreach ($this->manager->get_inherited_mapping() as $child => $parent) { |
114 | 114 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $prefix . $child . '");'); |
115 | - if ( $prefix !== '' |
|
115 | + if ($prefix !== '' |
|
116 | 116 | && !class_exists($child)) { |
117 | 117 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $child . '");'); |
118 | 118 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | $objects[$name] = 'new midgard_datetime("0001-01-01 00:00:00")'; |
174 | 174 | break; |
175 | 175 | } |
176 | - if ( $default !== null |
|
176 | + if ($default !== null |
|
177 | 177 | // we need to skip working links because in this case, Doctrine expects objects as values |
178 | - && ( !$property->link |
|
178 | + && (!$property->link |
|
179 | 179 | || $this->manager->resolve_targetclass($property) === false)) { |
180 | 180 | $line .= ' = ' . $default; |
181 | 181 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $this->write_annotations($type); |
236 | 236 | $this->add_line('class ' . $type->name . ' extends ' . $type->extends); |
237 | 237 | $mixins = $type->get_mixins(); |
238 | - $interfaces = array_filter(array_map(function ($name) { |
|
238 | + $interfaces = array_filter(array_map(function($name) { |
|
239 | 239 | if (interface_exists('\\midgard\\portable\\storage\\interfaces\\' . $name)) { |
240 | 240 | return '\\midgard\\portable\\storage\\interfaces\\' . $name; |
241 | 241 | } |
@@ -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 | } |
@@ -156,7 +156,7 @@ |
||
156 | 156 | |
157 | 157 | foreach ($type->get_properties() as $name => $property) { |
158 | 158 | // doctrine can handle id links only |
159 | - if ( $property->link |
|
159 | + if ($property->link |
|
160 | 160 | && $target_class = $this->manager->resolve_targetclass($property)) { |
161 | 161 | $link_mapping = [ |
162 | 162 | 'fieldName' => $property->name, |
@@ -38,7 +38,7 @@ |
||
38 | 38 | if (!array_key_exists($typeattribute, self::$typemap)) { |
39 | 39 | throw new \Exception('unknown type ' . $typeattribute); |
40 | 40 | } |
41 | - $search = ['unsigned ', 'guid', 'datetime', 'text', 'longtext']; |
|
41 | + $search = ['unsigned ', 'guid', 'datetime', 'text', 'longtext']; |
|
42 | 42 | $replace = ['', 'string', 'midgard_datetime', 'string', 'string']; |
43 | 43 | |
44 | 44 | return str_replace($search, $replace, $typeattribute); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public function read_file_at_path($path) |
34 | 34 | { |
35 | - if ( !file_exists($path) |
|
35 | + if (!file_exists($path) |
|
36 | 36 | || !is_readable($path)) { |
37 | 37 | return false; |
38 | 38 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $subdirs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F']; |
146 | 146 | foreach ($subdirs as $dir) { |
147 | 147 | foreach ($subdirs as $subdir) { |
148 | - if ( !is_dir($this->blobdir . '/' . $dir . '/' . $subdir) |
|
148 | + if (!is_dir($this->blobdir . '/' . $dir . '/' . $subdir) |
|
149 | 149 | && !mkdir($this->blobdir . '/' . $dir . '/' . $subdir, 0777, true)) { |
150 | 150 | return false; |
151 | 151 | } |
@@ -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 | && 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 |