@@ -65,6 +65,7 @@ discard block |
||
65 | 65 | * This is basically a workaround for some quirks when merging detached entities with changed associations |
66 | 66 | * |
67 | 67 | * @todo: This may or may not be a bug in Doctrine |
68 | + * @param dbobject $source |
|
68 | 69 | */ |
69 | 70 | private function copy_associations($source, $target) |
70 | 71 | { |
@@ -222,6 +223,9 @@ discard block |
||
222 | 223 | return $entity; |
223 | 224 | } |
224 | 225 | |
226 | + /** |
|
227 | + * @param dbobject $target |
|
228 | + */ |
|
225 | 229 | private function copy_metadata($source, $target, $action = 'update') |
226 | 230 | { |
227 | 231 | if (!$source instanceof metadata) { |
@@ -95,6 +95,9 @@ |
||
95 | 95 | $type->add_property($property); |
96 | 96 | } |
97 | 97 | |
98 | + /** |
|
99 | + * @param string $name |
|
100 | + */ |
|
98 | 101 | private function add_mixin($name, type $type) |
99 | 102 | { |
100 | 103 | if (empty($this->mixins[$name])) { |
@@ -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 | } |
@@ -25,6 +25,10 @@ discard block |
||
25 | 25 | |
26 | 26 | private $value_properties = []; |
27 | 27 | |
28 | + /** |
|
29 | + * @param string $class |
|
30 | + * @param string $field |
|
31 | + */ |
|
28 | 32 | public function __construct($class, $field = null, $value = null) |
29 | 33 | { |
30 | 34 | parent::__construct($class); |
@@ -68,6 +72,9 @@ discard block |
||
68 | 72 | return true; |
69 | 73 | } |
70 | 74 | |
75 | + /** |
|
76 | + * @param string $property |
|
77 | + */ |
|
71 | 78 | protected function build_property_select($property) |
72 | 79 | { |
73 | 80 | $parsed = $this->parse_constraint_name($property); |
@@ -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 | //TODO: Print some error? |
15 | 15 | return; |
@@ -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 | } |
@@ -78,7 +78,7 @@ |
||
78 | 78 | $fqcn = $this->namespace . '\\' . $fqcn; |
79 | 79 | } |
80 | 80 | |
81 | - if ( array_key_exists($fqcn, $this->types) |
|
81 | + if (array_key_exists($fqcn, $this->types) |
|
82 | 82 | || $property->link['target'] === $property->get_parent()->name) { |
83 | 83 | $target_class = $property->link['target']; |
84 | 84 | } else { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | public function __get($field) |
82 | 82 | { |
83 | - if ( $field === 'metadata' |
|
83 | + if ($field === 'metadata' |
|
84 | 84 | && $this->metadata === null |
85 | 85 | && $this instanceof metadata_interface) { |
86 | 86 | $this->metadata = new metadata($this); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | foreach ($candidates as $candidate) { |
103 | 103 | if ($this->$candidate !== null) { |
104 | 104 | //Proxies become stale if the object itself is detached, so we have to re-fetch |
105 | - if ( $this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
105 | + if ($this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
106 | 106 | && $this->$candidate->__isInitialized()) { |
107 | 107 | try { |
108 | 108 | $this->$candidate->get_by_id($this->$candidate->id); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | // According to Doctrine documentation, proxies should be transparent, but in practice, |
128 | 128 | // there will be problems if we don't force-load |
129 | - if ( $entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
129 | + if ($entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
130 | 130 | && !$entity->__isInitialized()) { |
131 | 131 | try { |
132 | 132 | $entity->__load(); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | exception::duplicate(); |
176 | 176 | return false; |
177 | 177 | } |
178 | - if ( !$this->is_unique() |
|
178 | + if (!$this->is_unique() |
|
179 | 179 | || !$this->check_parent()) { |
180 | 180 | return false; |
181 | 181 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | midgard_connection::get_instance()->set_error(MGD_ERR_INVALID_PROPERTY_VALUE); |
232 | 232 | return false; |
233 | 233 | } |
234 | - if ( $check_dependencies |
|
234 | + if ($check_dependencies |
|
235 | 235 | && $this->has_dependents()) { |
236 | 236 | exception::has_dependants(); |
237 | 237 | return false; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | { |
323 | 323 | $this->initialize(); |
324 | 324 | |
325 | - if ( empty($this->cm->midgard['parentfield']) |
|
325 | + if (empty($this->cm->midgard['parentfield']) |
|
326 | 326 | || empty($this->cm->midgard['parent'])) { |
327 | 327 | return true; |
328 | 328 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $this->initialize(); |
340 | 340 | |
341 | 341 | foreach ($this->cm->fieldMappings as $name => $field) { |
342 | - if ( $field['midgard:midgard_type'] == translator::TYPE_GUID |
|
342 | + if ($field['midgard:midgard_type'] == translator::TYPE_GUID |
|
343 | 343 | && !empty($this->$name) |
344 | 344 | && !mgd_is_guid($this->$name)) { |
345 | 345 | exception::invalid_property_value("'" . $name . "' property's value is not a guid."); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $stat = ($results > 0); |
376 | 376 | } |
377 | 377 | |
378 | - if ( !$stat |
|
378 | + if (!$stat |
|
379 | 379 | && !empty($this->cm->midgard['childtypes'])) { |
380 | 380 | foreach ($this->cm->midgard['childtypes'] as $typename => $parentfield) { |
381 | 381 | $qb = connection::get_em()->createQueryBuilder(); |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | exception::not_exists(); |
741 | 741 | return false; |
742 | 742 | } |
743 | - if ( $check_dependencies |
|
743 | + if ($check_dependencies |
|
744 | 744 | && $this->has_dependents()) { |
745 | 745 | exception::has_dependants(); |
746 | 746 | return false; |
@@ -509,6 +509,7 @@ discard block |
||
509 | 509 | } |
510 | 510 | |
511 | 511 | /** |
512 | + * @param integer $up |
|
512 | 513 | * @return QueryBuilder |
513 | 514 | */ |
514 | 515 | protected function get_uniquefield_query($classname, $field, $part, $upfield, $up) |
@@ -610,7 +611,7 @@ discard block |
||
610 | 611 | /** |
611 | 612 | * @param string $domain |
612 | 613 | * @param string $name |
613 | - * @param mixed $value |
|
614 | + * @param string $value |
|
614 | 615 | * @return boolean |
615 | 616 | */ |
616 | 617 | public function set_parameter($domain, $name, $value) |
@@ -816,6 +817,9 @@ discard block |
||
816 | 817 | return new \midgard_reflection_property(get_called_class()); |
817 | 818 | } |
818 | 819 | |
820 | + /** |
|
821 | + * @param string $guid |
|
822 | + */ |
|
819 | 823 | public function set_guid($guid) |
820 | 824 | { |
821 | 825 | parent::__set('guid', $guid); |
@@ -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, |