Completed
Push — master ( dd997c...791084 )
by Andreas
07:48 queued 03:59
created
api/midgard/collector.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -25,6 +25,9 @@
 block discarded – undo
25 25
 
26 26
     private $value_properties = array();
27 27
 
28
+    /**
29
+     * @param string $class
30
+     */
28 31
     function __construct($class, $field, $value)
29 32
     {
30 33
         parent::__construct($class);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,8 +53,7 @@  discard block
 block discarded – undo
53 53
         try
54 54
         {
55 55
             $property_select = $this->build_property_select($property);
56
-        }
57
-        catch (exception $e)
56
+        } catch (exception $e)
58 57
         {
59 58
             return false;
60 59
         }
@@ -103,8 +102,7 @@  discard block
 block discarded – undo
103 102
             try
104 103
             {
105 104
                 $properties[] = $this->build_property_select($this->key_property);
106
-            }
107
-            catch (exception $e)
105
+            } catch (exception $e)
108 106
             {
109 107
                 throw new exception('Property "' . $this->key_property . '" not found in "' . $this->classname . '"', exception::INVALID_PROPERTY);
110 108
             }
Please login to merge, or discard this patch.
api/midgard/connection.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -37,6 +37,9 @@
 block discarded – undo
37 37
         //??
38 38
     }
39 39
 
40
+    /**
41
+     * @return integer
42
+     */
40 43
     public static function get_instance()
41 44
     {
42 45
         if (self::$instance === null)
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         return is_object($this->config);
85 85
     }
86 86
 
87
-    public function connect($signal, $callback, $userdata = '???' )
87
+    public function connect($signal, $callback, $userdata = '???')
88 88
     {
89 89
 
90 90
     }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         return connection::get_user();
124 124
     }
125 125
 
126
-    public function set_loglevel($level, $callback = '???' )
126
+    public function set_loglevel($level, $callback = '???')
127 127
     {
128 128
         if (!in_array($level, $this->available_loglevels))
129 129
         {
Please login to merge, or discard this patch.
api/midgard/object/class.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -106,6 +106,9 @@
 block discarded – undo
106 106
         return true;
107 107
     }
108 108
 
109
+    /**
110
+     * @param string $guid
111
+     */
109 112
     public static function get_object_by_guid($guid)
110 113
     {
111 114
         if (!mgd_is_guid($guid))
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
         {
38 38
             throw exception::object_purged();
39 39
         }
40
-        if (    !$include_deleted
40
+        if (!$include_deleted
41 41
              && $result["object_action"] == subscriber::ACTION_DELETE)
42 42
         {
43 43
             throw exception::object_deleted();
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
         try
25 25
         {
26 26
             $result = $qb->getQuery()->getSingleResult();
27
-        }
28
-        catch (\Doctrine\ORM\NoResultException $e)
27
+        } catch (\Doctrine\ORM\NoResultException $e)
29 28
         {
30 29
             $result = null;
31 30
         }
@@ -67,8 +66,7 @@  discard block
 block discarded – undo
67 66
         try
68 67
         {
69 68
             $classname = self::resolve_classname($guid, true);
70
-        }
71
-        catch (exception $e)
69
+        } catch (exception $e)
72 70
         {
73 71
             return false;
74 72
         }
@@ -95,8 +93,7 @@  discard block
 block discarded – undo
95 93
         {
96 94
             $om = new objectmanager(connection::get_em());
97 95
             $om->undelete($entity);
98
-        }
99
-        catch (\Exception $e)
96
+        } catch (\Exception $e)
100 97
         {
101 98
             exception::internal($e);
102 99
             return false;
Please login to merge, or discard this patch.
api/midgard/query/builder.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -22,6 +22,9 @@
 block discarded – undo
22 22
         }
23 23
     }
24 24
 
25
+    /**
26
+     * @param string $operator
27
+     */
25 28
     public function add_constraint($name, $operator, $value)
26 29
     {
27 30
         try
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,7 @@  discard block
 block discarded – undo
15 15
         try
16 16
         {
17 17
             return parent::add_constraint_with_property($name, $operator, $value);
18
-        }
19
-        catch (exception $e)
18
+        } catch (exception $e)
20 19
         {
21 20
             return false;
22 21
         }
@@ -27,8 +26,7 @@  discard block
 block discarded – undo
27 26
         try
28 27
         {
29 28
             return parent::add_constraint($name, $operator, $value);
30
-        }
31
-        catch (exception $e)
29
+        } catch (exception $e)
32 30
         {
33 31
             return false;
34 32
         }
Please login to merge, or discard this patch.
api/midgard/replicator.php 3 patches
Doc Comments   +11 added lines, -2 removed lines patch added patch discarded remove patch
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     }
275 275
 
276 276
     /**
277
-     * @return boolean Indicating success
277
+     * @return boolean|null Indicating success
278 278
      */
279 279
     public static function import_from_xml($xml, $force = false)
280 280
     {
@@ -302,6 +302,9 @@  discard block
 block discarded – undo
302 302
         $blob->write_content($blob->content);
303 303
     }
304 304
 
305
+    /**
306
+     * @return string|null
307
+     */
305 308
     private static function resolve_link_id(ClassMetadata $cm, dbobject $object, $name)
306 309
     {
307 310
         if ($object->$name == 0)
@@ -387,7 +390,7 @@  discard block
 block discarded – undo
387 390
      *
388 391
      * @param SimpleXMLElement $node
389 392
      * @param boolean $force
390
-     * @return dbobject
393
+     * @return blob
391 394
      */
392 395
     private static function blob_from_xml(SimpleXMLElement $node, $force)
393 396
     {
@@ -398,6 +401,9 @@  discard block
 block discarded – undo
398 401
         return $blob;
399 402
     }
400 403
 
404
+    /**
405
+     * @param string $guid
406
+     */
401 407
     private static function get_object_action($guid)
402 408
     {
403 409
         $result = connection::get_em()
@@ -425,6 +431,9 @@  discard block
 block discarded – undo
425 431
         }
426 432
     }
427 433
 
434
+    /**
435
+     * @return string|null
436
+     */
428 437
     private static function convert_value($value)
429 438
     {
430 439
         if ($value instanceof midgard_datetime)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -225,14 +225,14 @@  discard block
 block discarded – undo
225 225
                 break;
226 226
         }
227 227
 
228
-        if (   $dbobject->id > 0
228
+        if ($dbobject->id > 0
229 229
             && $dbobject->metadata->revised >= $object->metadata->revised)
230 230
         {
231 231
             midgard_connection::get_instance()->set_error(exception::OBJECT_IMPORTED);
232 232
             return false;
233 233
         }
234 234
 
235
-        if (   $dbobject->metadata->deleted
235
+        if ($dbobject->metadata->deleted
236 236
             && !$object->metadata->deleted)
237 237
         {
238 238
             if (!midgard_object_class::undelete($dbobject->guid))
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
             }
242 242
             $dbobject->metadata_deleted = false;
243 243
         }
244
-        else if (   !$dbobject->metadata->deleted
244
+        else if (!$dbobject->metadata->deleted
245 245
                  && $object->metadata->deleted)
246 246
         {
247 247
             return $dbobject->delete();
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -112,8 +112,7 @@  discard block
 block discarded – undo
112 112
             if (strpos($name, 'metadata_') === 0)
113 113
             {
114 114
                 $metadata[substr($name, 9)] = $object->$name;
115
-            }
116
-            else
115
+            } else
117 116
             {
118 117
                 $node->addChild($name, self::convert_value($object->$name));
119 118
             }
@@ -159,13 +158,11 @@  discard block
 block discarded – undo
159 158
                 if ($node->getName() == 'midgard_blob')
160 159
                 {
161 160
                     $ret[] = self::blob_from_xml($node, $force);
162
-                }
163
-                else
161
+                } else
164 162
                 {
165 163
                     $ret[] = self::object_from_xml($node, $force);
166 164
                 }
167
-            }
168
-            catch (\Exception $e)
165
+            } catch (\Exception $e)
169 166
             {
170 167
                 connection::log()->warning($e->getMessage());
171 168
             }
@@ -240,8 +237,7 @@  discard block
 block discarded – undo
240 237
                 return false;
241 238
             }
242 239
             $dbobject->metadata_deleted = false;
243
-        }
244
-        else if (   !$dbobject->metadata->deleted
240
+        } else if (   !$dbobject->metadata->deleted
245 241
                  && $object->metadata->deleted)
246 242
         {
247 243
             return $dbobject->delete();
@@ -284,8 +280,7 @@  discard block
 block discarded – undo
284 280
             if ($object instanceof blob)
285 281
             {
286 282
                 self::import_blob($object, $force);
287
-            }
288
-            else
283
+            } else
289 284
             {
290 285
                 self::import_object($object, $force);
291 286
             }
@@ -367,8 +362,7 @@  discard block
 block discarded – undo
367 362
                 try
368 363
                 {
369 364
                     $value = self::resolve_link_guid($cm, $field, $value);
370
-                }
371
-                catch (NoResultException $e)
365
+                } catch (NoResultException $e)
372 366
                 {
373 367
                     if (!$force)
374 368
                     {
Please login to merge, or discard this patch.
api/midgard/storage.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -61,6 +61,9 @@  discard block
 block discarded – undo
61 61
         return true;
62 62
     }
63 63
 
64
+    /**
65
+     * @param string $classname
66
+     */
64 67
     public static function create_class_storage($classname)
65 68
     {
66 69
         $em = connection::get_em();
@@ -95,6 +98,11 @@  discard block
 block discarded – undo
95 98
         $generator->generateProxyClass($cm, $filename);
96 99
     }
97 100
 
101
+    /**
102
+     * @param Doctrine\ORM\EntityManagerInterface $em
103
+     *
104
+     * @return ClassMetadata
105
+     */
98 106
     private static function get_cm($em, $classname)
99 107
     {
100 108
         if (!class_exists($classname))
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -107,16 +107,14 @@
 block discarded – undo
107 107
         try
108 108
         {
109 109
             return $factory->getMetadataFor($classname);
110
-        }
111
-        catch (MappingException $e)
110
+        } catch (MappingException $e)
112 111
         {
113 112
             // add namespace
114 113
             $classname = $em->getConfiguration()->getEntityNamespace("midgard") . '\\' . $classname;
115 114
             try
116 115
             {
117 116
                 return $factory->getMetadataFor($classname);
118
-            }
119
-            catch (MappingException $e)
117
+            } catch (MappingException $e)
120 118
             {
121 119
                 // check for merged classes (duplicate tablenames)
122 120
                 $classname = get_class(new $classname);
Please login to merge, or discard this patch.
src/api/blob.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -31,6 +31,9 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/api/config.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -30,6 +30,9 @@  discard block
 block discarded – undo
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)
@@ -136,6 +139,9 @@  discard block
 block discarded – undo
136 139
         return true;
137 140
     }
138 141
 
142
+    /**
143
+     * @param string $key
144
+     */
139 145
     private function convert_to_storage($key, $value)
140 146
     {
141 147
         if (is_bool($value))
Please login to merge, or discard this patch.
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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
         {
38 38
             return false;
@@ -47,8 +47,7 @@  discard block
 block discarded – undo
47 47
     // TODO: find out if this could be moved to read_data()
48 48
     private function apply_config(array $config)
49 49
     {
50
-        $mapping = array
51
-        (
50
+        $mapping = array(
52 51
             'type' => 'dbtype',
53 52
             'name' => 'database',
54 53
             'username' => 'dbuser',
@@ -166,7 +165,7 @@  discard block
 block discarded – undo
166 165
         {
167 166
             foreach ($subdirs as $subdir)
168 167
             {
169
-                if (   !is_dir($this->blobdir . '/' . $dir . '/' . $subdir)
168
+                if (!is_dir($this->blobdir . '/' . $dir . '/' . $subdir)
170 169
                     && !mkdir($this->blobdir . '/' . $dir . '/' . $subdir, 0777, true))
171 170
                 {
172 171
                     return false;
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
         if (!$user)
81 81
         {
82 82
             $prefix = '/etc/midgard2/conf.d';
83
-        }
84
-        else
83
+        } else
85 84
         {
86 85
             $prefix = getenv('HOME') . '/.midgard2/conf.d';
87 86
         }
@@ -93,8 +92,7 @@  discard block
 block discarded – undo
93 92
         if (!$user)
94 93
         {
95 94
             $prefix = '/etc/midgard2/conf.d';
96
-        }
97
-        else
95
+        } else
98 96
         {
99 97
             $prefix = getenv('HOME') . '/.midgard2/conf.d';
100 98
         }
@@ -141,8 +139,7 @@  discard block
 block discarded – undo
141 139
         if (is_bool($value))
142 140
         {
143 141
             $value = ($value) ? 'true' : 'false';
144
-        }
145
-        else if ($value === '')
142
+        } else if ($value === '')
146 143
         {
147 144
             $value = '""';
148 145
         }
Please login to merge, or discard this patch.
src/query.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -239,6 +239,9 @@  discard block
 block discarded – undo
239 239
         }
240 240
     }
241 241
 
242
+    /**
243
+     * @param string $targetclass
244
+     */
242 245
     protected function add_collection_join($current_table, $targetclass)
243 246
     {
244 247
         if (!array_key_exists($targetclass, $this->join_tables))
@@ -250,6 +253,9 @@  discard block
 block discarded – undo
250 253
         return $this->join_tables[$targetclass];
251 254
     }
252 255
 
256
+    /**
257
+     * @param \midgard_reflection_property $mrp
258
+     */
253 259
     protected function add_join($current_table, $mrp, $property)
254 260
     {
255 261
         $targetclass = $mrp->get_link_name($property);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             $value = (array) $value;
100 100
             $value = array_merge($value, $this->get_child_ids($mapping['targetEntity'], $parentfield, $value));
101 101
         }
102
-        else if (   $operator === 'IN'
102
+        else if ($operator === 'IN'
103 103
                  || $operator === 'NOT IN')
104 104
         {
105 105
             $value = array_values($value);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             $column = array_pop($parts);
286 286
             foreach ($parts as $part)
287 287
             {
288
-                if (   $part === 'parameter'
288
+                if ($part === 'parameter'
289 289
                     || $part === 'attachment')
290 290
                 {
291 291
                     $targetclass = 'midgard_' . $part;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
                 {
296 296
                     $mrp = new \midgard_reflection_property($targetclass);
297 297
 
298
-                    if (   !$mrp->is_link($part)
298
+                    if (!$mrp->is_link($part)
299 299
                         && !$mrp->is_special_link($part))
300 300
                     {
301 301
                         throw exception::ok();
@@ -314,14 +314,13 @@  discard block
 block discarded – undo
314 314
             $column = $cm->midgard['field_aliases'][$column];
315 315
         }
316 316
 
317
-        if (   !$cm->hasField($column)
317
+        if (!$cm->hasField($column)
318 318
             && !$cm->hasAssociation($column))
319 319
         {
320 320
             throw exception::ok();
321 321
         }
322 322
 
323
-        return array
324
-        (
323
+        return array(
325 324
             'name' => $current_table . '.' . $column,
326 325
             'column' => $column,
327 326
             'targetclass' => $targetclass
@@ -333,13 +332,13 @@  discard block
 block discarded – undo
333 332
         $parsed = $this->parse_constraint_name($name);
334 333
         $expression = $operator . ' ?' . $this->parameters;
335 334
 
336
-        if (   $operator === 'IN'
335
+        if ($operator === 'IN'
337 336
             || $operator === 'NOT IN')
338 337
         {
339 338
             $expression = $operator . '( ?' . $this->parameters . ')';
340 339
         }
341 340
 
342
-        if (   $value === 0
341
+        if ($value === 0
343 342
             || $value === null
344 343
             || is_array($value))
345 344
         {
Please login to merge, or discard this patch.
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -98,13 +98,11 @@  discard block
 block discarded – undo
98 98
 
99 99
             $value = (array) $value;
100 100
             $value = array_merge($value, $this->get_child_ids($mapping['targetEntity'], $parentfield, $value));
101
-        }
102
-        else if (   $operator === 'IN'
101
+        } else if (   $operator === 'IN'
103 102
                  || $operator === 'NOT IN')
104 103
         {
105 104
             $value = array_values($value);
106
-        }
107
-        else if (!in_array($operator, array('=', '>', '<', '<>', '<=', '>=', 'LIKE', 'NOT LIKE')))
105
+        } else if (!in_array($operator, array('=', '>', '<', '<>', '<=', '>=', 'LIKE', 'NOT LIKE')))
108 106
         {
109 107
             return false;
110 108
         }
@@ -124,8 +122,7 @@  discard block
 block discarded – undo
124 122
         try
125 123
         {
126 124
             $parsed = $this->parse_constraint_name($name);
127
-        }
128
-        catch (exception $e)
125
+        } catch (exception $e)
129 126
         {
130 127
             return false;
131 128
         }
@@ -175,12 +172,10 @@  discard block
 block discarded – undo
175 172
         if ($operator === 'OR')
176 173
         {
177 174
             $this->groupstack[] = $this->qb->expr()->orX();
178
-        }
179
-        else if ($operator === 'AND')
175
+        } else if ($operator === 'AND')
180 176
         {
181 177
             $this->groupstack[] = $this->qb->expr()->andX();
182
-        }
183
-        else
178
+        } else
184 179
         {
185 180
             return false;
186 181
         }
@@ -200,8 +195,7 @@  discard block
 block discarded – undo
200 195
             if (!empty($this->groupstack))
201 196
             {
202 197
                 $this->get_current_group()->add($group);
203
-            }
204
-            else
198
+            } else
205 199
             {
206 200
                 $this->qb->andWhere($group);
207 201
             }
@@ -262,8 +256,7 @@  discard block
 block discarded – undo
262 256
             {
263 257
                 $c = $this->join_tables[$targetclass] . "." . $mrp->get_link_target($property) . " = " . $current_table . "." . $property;
264 258
                 $this->qb->innerJoin("midgard:" . $targetclass, $this->join_tables[$targetclass], Join::WITH, $c);
265
-            }
266
-            else
259
+            } else
267 260
             {
268 261
                 $this->qb->join($current_table . '.' . $property, $this->join_tables[$targetclass]);
269 262
             }
@@ -290,8 +283,7 @@  discard block
 block discarded – undo
290 283
                 {
291 284
                     $targetclass = 'midgard_' . $part;
292 285
                     $current_table = $this->add_collection_join($current_table, $targetclass);
293
-                }
294
-                else
286
+                } else
295 287
                 {
296 288
                     $mrp = new \midgard_reflection_property($targetclass);
297 289
 
@@ -353,24 +345,21 @@  discard block
 block discarded – undo
353 345
                 {
354 346
                     $group = $this->qb->expr()->andX();
355 347
                     $group->add($parsed['name'] . ' IS NOT NULL');
356
-                }
357
-                else if ($operator === 'IN')
348
+                } else if ($operator === 'IN')
358 349
                 {
359 350
                     if (array_search(0, $value) !== false)
360 351
                     {
361 352
                         $group = $this->qb->expr()->orX();
362 353
                         $group->add($parsed['name'] . ' IS NULL');
363 354
                     }
364
-                }
365
-                else if ($operator === 'NOT IN')
355
+                } else if ($operator === 'NOT IN')
366 356
                 {
367 357
                     if (array_search(0, $value) === false)
368 358
                     {
369 359
                         $group = $this->qb->expr()->orX();
370 360
                         $group->add($parsed['name'] . ' IS NULL');
371 361
                     }
372
-                }
373
-                else
362
+                } else
374 363
                 {
375 364
                     $group = $this->qb->expr()->orX();
376 365
                     $group->add($parsed['name'] . ' IS NULL');
Please login to merge, or discard this patch.