@@ -25,6 +25,9 @@ |
||
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); |
@@ -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; |
@@ -37,6 +37,9 @@ |
||
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) |
@@ -106,6 +106,9 @@ |
||
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)) |
@@ -22,6 +22,9 @@ |
||
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 |
@@ -274,7 +274,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) |
@@ -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 | } |
@@ -61,6 +61,9 @@ discard block |
||
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 |
||
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)) |
@@ -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; |
@@ -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) |
@@ -136,6 +139,9 @@ discard block |
||
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)) |
@@ -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 | } |
@@ -239,6 +239,9 @@ discard block |
||
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 |
||
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); |
@@ -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']); |