@@ -31,6 +31,9 @@ |
||
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | |
34 | + /** |
|
35 | + * @param string $content |
|
36 | + */ |
|
34 | 37 | public function write_content($content) |
35 | 38 | { |
36 | 39 | return file_put_contents($this->get_path(), $content) !== false; |
@@ -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 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
243 | - * @return boolean Indicating success |
|
243 | + * @return boolean|null Indicating success |
|
244 | 244 | */ |
245 | 245 | public static function import_from_xml($xml, $force = false) |
246 | 246 | { |
@@ -264,6 +264,9 @@ discard block |
||
264 | 264 | $blob->write_content($blob->content); |
265 | 265 | } |
266 | 266 | |
267 | + /** |
|
268 | + * @return string|null |
|
269 | + */ |
|
267 | 270 | private static function resolve_link_id(ClassMetadata $cm, dbobject $object, $name) |
268 | 271 | { |
269 | 272 | if ($object->$name == 0) { |
@@ -339,7 +342,7 @@ discard block |
||
339 | 342 | * |
340 | 343 | * @param SimpleXMLElement $node |
341 | 344 | * @param boolean $force |
342 | - * @return dbobject |
|
345 | + * @return blob |
|
343 | 346 | */ |
344 | 347 | private static function blob_from_xml(SimpleXMLElement $node, $force) |
345 | 348 | { |
@@ -350,6 +353,9 @@ discard block |
||
350 | 353 | return $blob; |
351 | 354 | } |
352 | 355 | |
356 | + /** |
|
357 | + * @param string $guid |
|
358 | + */ |
|
353 | 359 | private static function get_object_action($guid) |
354 | 360 | { |
355 | 361 | $result = connection::get_em() |
@@ -376,6 +382,9 @@ discard block |
||
376 | 382 | } |
377 | 383 | } |
378 | 384 | |
385 | + /** |
|
386 | + * @return string|null |
|
387 | + */ |
|
379 | 388 | private static function convert_value($value) |
380 | 389 | { |
381 | 390 | if ($value instanceof midgard_datetime) { |
@@ -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 |
@@ -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 = array(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 | } |
@@ -30,6 +30,9 @@ discard block |
||
30 | 30 | public $cachedir = '/var/cache/midgard2'; |
31 | 31 | public $gdathreads = false; |
32 | 32 | |
33 | + /** |
|
34 | + * @param string $path |
|
35 | + */ |
|
33 | 36 | public function read_file_at_path($path) |
34 | 37 | { |
35 | 38 | if ( !file_exists($path) |
@@ -122,6 +125,9 @@ discard block |
||
122 | 125 | return true; |
123 | 126 | } |
124 | 127 | |
128 | + /** |
|
129 | + * @param string $key |
|
130 | + */ |
|
125 | 131 | private function convert_to_storage($key, $value) |
126 | 132 | { |
127 | 133 | if (is_bool($value)) { |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | $value = (array) $value; |
97 | 97 | $value = array_merge($value, $this->get_child_ids($mapping['targetEntity'], $parentfield, $value)); |
98 | - } elseif ( $operator === 'IN' |
|
98 | + } elseif ($operator === 'IN' |
|
99 | 99 | || $operator === 'NOT IN') { |
100 | 100 | $value = array_values($value); |
101 | 101 | } elseif (!in_array($operator, array('=', '>', '<', '<>', '<=', '>=', 'LIKE', 'NOT LIKE'))) { |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | $parts = explode('.', $name); |
255 | 255 | $column = array_pop($parts); |
256 | 256 | foreach ($parts as $part) { |
257 | - if ( $part === 'parameter' |
|
257 | + if ($part === 'parameter' |
|
258 | 258 | || $part === 'attachment') { |
259 | 259 | $targetclass = 'midgard_' . $part; |
260 | 260 | $current_table = $this->add_collection_join($current_table, $targetclass); |
261 | 261 | } else { |
262 | 262 | $mrp = new \midgard_reflection_property($targetclass); |
263 | 263 | |
264 | - if ( !$mrp->is_link($part) |
|
264 | + if (!$mrp->is_link($part) |
|
265 | 265 | && !$mrp->is_special_link($part)) { |
266 | 266 | throw exception::ok(); |
267 | 267 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $column = $cm->midgard['field_aliases'][$column]; |
279 | 279 | } |
280 | 280 | |
281 | - if ( !$cm->hasField($column) |
|
281 | + if (!$cm->hasField($column) |
|
282 | 282 | && !$cm->hasAssociation($column)) { |
283 | 283 | throw exception::ok(); |
284 | 284 | } |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | $parsed = $this->parse_constraint_name($name); |
296 | 296 | $expression = $operator . ' ?' . $this->parameters; |
297 | 297 | |
298 | - if ( $operator === 'IN' |
|
298 | + if ($operator === 'IN' |
|
299 | 299 | || $operator === 'NOT IN') { |
300 | 300 | $expression = $operator . '( ?' . $this->parameters . ')'; |
301 | 301 | } |
302 | 302 | |
303 | - if ( $value === 0 |
|
303 | + if ($value === 0 |
|
304 | 304 | || $value === null |
305 | 305 | || is_array($value)) { |
306 | 306 | $cm = connection::get_em()->getClassMetadata($parsed['targetclass']); |
@@ -205,6 +205,9 @@ discard block |
||
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | + /** |
|
209 | + * @param string $targetclass |
|
210 | + */ |
|
208 | 211 | protected function add_collection_join($current_table, $targetclass) |
209 | 212 | { |
210 | 213 | if (!array_key_exists($targetclass, $this->join_tables)) { |
@@ -215,6 +218,9 @@ discard block |
||
215 | 218 | return $this->join_tables[$targetclass]; |
216 | 219 | } |
217 | 220 | |
221 | + /** |
|
222 | + * @param \midgard_reflection_property $mrp |
|
223 | + */ |
|
218 | 224 | protected function add_join($current_table, $mrp, $property) |
219 | 225 | { |
220 | 226 | $targetclass = $mrp->get_link_name($property); |
@@ -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 | } |
@@ -123,6 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Toggle autostart |
126 | + * @param boolean $autostart |
|
126 | 127 | */ |
127 | 128 | public static function set_autostart($autostart) |
128 | 129 | { |
@@ -156,6 +157,9 @@ discard block |
||
156 | 157 | } |
157 | 158 | } |
158 | 159 | |
160 | + /** |
|
161 | + * @param string $name |
|
162 | + */ |
|
159 | 163 | public static function get_parameter($name) |
160 | 164 | { |
161 | 165 | if (!array_key_exists($name, self::$parameters)) { |
@@ -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 = array( |
162 | 162 | 'fieldName' => $property->name, |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if (!($entity instanceof repligard)) { |
100 | 100 | $repligard_entry = $em->getRepository('midgard:midgard_repligard')->findOneBy(array('guid' => $entity->guid)); |
101 | 101 | |
102 | - if ( $entity instanceof metadata |
|
102 | + if ($entity instanceof metadata |
|
103 | 103 | && $entity->{metadata::DELETED_FIELD}) { |
104 | 104 | $repligard_entry->object_action = self::ACTION_DELETE; |
105 | 105 | } else { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | foreach ($columns as $name => &$config) { |
142 | 142 | if ($platform->getName() === 'sqlite') { |
143 | - if ( !empty($config['primary']) |
|
143 | + if (!empty($config['primary']) |
|
144 | 144 | && !empty($config['autoincrement'])) { |
145 | 145 | /* |
146 | 146 | * This is essentially a workaround for http://www.doctrine-project.org/jira/browse/DBAL-642 |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $modified = true; |
150 | 150 | $config['columnDefinition'] = 'INTEGER PRIMARY KEY AUTOINCREMENT'; |
151 | 151 | } |
152 | - if ( !empty($config['comment']) |
|
152 | + if (!empty($config['comment']) |
|
153 | 153 | && $config['comment'] == 'BINARY') { |
154 | 154 | $modified = true; |
155 | 155 | $config['columnDefinition'] = $config['type']->getSQLDeclaration($config, $platform) . ' COLLATE BINARY' . $platform->getDefaultValueDeclarationSQL($config); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $args) |
258 | 258 | { |
259 | 259 | $table = $args->getClassTable(); |
260 | - if ( !$table->hasOption('engine') |
|
260 | + if (!$table->hasOption('engine') |
|
261 | 261 | || $table->getOption('engine') !== 'MyISAM') { |
262 | 262 | return; |
263 | 263 | } |