@@ -103,6 +103,9 @@ |
||
| 103 | 103 | $type->add_property($property); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | + /** |
|
| 107 | + * @param string $name |
|
| 108 | + */ |
|
| 106 | 109 | private function add_mixin($name, type $type) |
| 107 | 110 | { |
| 108 | 111 | if (empty($this->mixins[$name])) |
@@ -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 | { |
| 15 | 15 | //TODO: Print some error? |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | $fqcn = $this->namespace . '\\' . $fqcn; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( array_key_exists($fqcn, $this->types) |
|
| 83 | + if (array_key_exists($fqcn, $this->types) |
|
| 84 | 84 | || $property->link['target'] === $property->get_parent()->name) |
| 85 | 85 | { |
| 86 | 86 | $target_class = $property->link['target']; |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | if ($property->parentfield) |
| 77 | 77 | { |
| 78 | 78 | $this->parentfield = $property->name; |
| 79 | - if ( empty($this->parent) |
|
| 79 | + if (empty($this->parent) |
|
| 80 | 80 | && $property->link) |
| 81 | 81 | { |
| 82 | 82 | $this->parent = $property->link['target']; |
@@ -200,7 +200,7 @@ |
||
| 200 | 200 | break; |
| 201 | 201 | } |
| 202 | 202 | if ( $default !== null |
| 203 | - // we need to skip working links because in this case, Doctrine expects objects as values |
|
| 203 | + // we need to skip working links because in this case, Doctrine expects objects as values |
|
| 204 | 204 | && ( !$property->link |
| 205 | 205 | || $this->manager->resolve_targetclass($property) === false)) |
| 206 | 206 | { |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $types = $this->manager->get_types(); |
| 66 | - uasort($types, function ($a, $b) { |
|
| 67 | - if ( !empty($a->extends) |
|
| 66 | + uasort($types, function($a, $b) { |
|
| 67 | + if (!empty($a->extends) |
|
| 68 | 68 | && !empty($b->extends)) { |
| 69 | 69 | return strnatcmp($a->extends, $b->extends); |
| 70 | 70 | } elseif (!empty($a->extends)) { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $prefix = $this->get_class_prefix($namespace); |
| 106 | 106 | |
| 107 | 107 | foreach ($this->manager->get_types() as $type) { |
| 108 | - if ( $prefix !== '' |
|
| 108 | + if ($prefix !== '' |
|
| 109 | 109 | && !class_exists($type->name)) { |
| 110 | 110 | $this->add_line('class_alias( "' . $prefix . $type->name . '", "' . $type->name . '");'); |
| 111 | 111 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | foreach ($this->manager->get_inherited_mapping() as $child => $parent) { |
| 115 | 115 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $prefix . $child . '");'); |
| 116 | - if ( $prefix !== '' |
|
| 116 | + if ($prefix !== '' |
|
| 117 | 117 | && !class_exists($child)) { |
| 118 | 118 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $child . '");'); |
| 119 | 119 | } |
@@ -177,9 +177,9 @@ discard block |
||
| 177 | 177 | $objects[$name] = 'new midgard_datetime("0001-01-01 00:00:00")'; |
| 178 | 178 | break; |
| 179 | 179 | } |
| 180 | - if ( $default !== null |
|
| 180 | + if ($default !== null |
|
| 181 | 181 | // we need to skip working links because in this case, Doctrine expects objects as values |
| 182 | - && ( !$property->link |
|
| 182 | + && (!$property->link |
|
| 183 | 183 | || $this->manager->resolve_targetclass($property) === false)) { |
| 184 | 184 | $line .= ' = ' . $default; |
| 185 | 185 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $this->add_line('class ' . $type->name . ' extends ' . $type->extends); |
| 225 | 225 | $mixins = $type->get_mixins(); |
| 226 | - $interfaces = array_filter(array_map(function ($name) { |
|
| 226 | + $interfaces = array_filter(array_map(function($name) { |
|
| 227 | 227 | if (interface_exists('\\midgard\\portable\\storage\\' . $name . '\\entity')) { |
| 228 | 228 | return '\\midgard\\portable\\storage\\' . $name . '\\entity'; |
| 229 | 229 | } |
@@ -131,6 +131,9 @@ discard block |
||
| 131 | 131 | return null; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | + /** |
|
| 135 | + * @param integer $id |
|
| 136 | + */ |
|
| 134 | 137 | public function get_by_id($id) |
| 135 | 138 | { |
| 136 | 139 | $entity = connection::get_em()->find(get_class($this), $id); |
@@ -171,6 +174,9 @@ discard block |
||
| 171 | 174 | return true; |
| 172 | 175 | } |
| 173 | 176 | |
| 177 | + /** |
|
| 178 | + * @param string $guid |
|
| 179 | + */ |
|
| 174 | 180 | public function get_by_guid($guid) |
| 175 | 181 | { |
| 176 | 182 | if (!mgd_is_guid($guid)) |
@@ -546,7 +552,8 @@ discard block |
||
| 546 | 552 | } |
| 547 | 553 | |
| 548 | 554 | /** |
| 549 | - * @return int |
|
| 555 | + * @param integer $up |
|
| 556 | + * @return \Doctrine\ORM\QueryBuilder |
|
| 550 | 557 | */ |
| 551 | 558 | protected function get_uniquefield_query($classname, $field, $part, $upfield, $up) |
| 552 | 559 | { |
@@ -639,6 +646,9 @@ discard block |
||
| 639 | 646 | } |
| 640 | 647 | } |
| 641 | 648 | |
| 649 | + /** |
|
| 650 | + * @param string $value |
|
| 651 | + */ |
|
| 642 | 652 | public function set_parameter($domain, $name, $value) |
| 643 | 653 | { |
| 644 | 654 | $constraints = array |
@@ -729,7 +739,7 @@ discard block |
||
| 729 | 739 | * |
| 730 | 740 | * @param array $constraints |
| 731 | 741 | * @param boolean $delete_blob |
| 732 | - * @return boolean False if one or more attachments couldn't be deleted |
|
| 742 | + * @return integer False if one or more attachments couldn't be deleted |
|
| 733 | 743 | * @todo Implement delete_blob & return value |
| 734 | 744 | */ |
| 735 | 745 | public function purge_attachments(array $constraints = array(), $delete_blob = true) |
@@ -834,6 +844,9 @@ discard block |
||
| 834 | 844 | return new \midgard_reflection_property(get_called_class()); |
| 835 | 845 | } |
| 836 | 846 | |
| 847 | + /** |
|
| 848 | + * @param string $guid |
|
| 849 | + */ |
|
| 837 | 850 | public function set_guid($guid) |
| 838 | 851 | { |
| 839 | 852 | parent::__set('guid', $guid); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | public function __get($field) |
| 79 | 79 | { |
| 80 | - if ( $field === 'metadata' |
|
| 80 | + if ($field === 'metadata' |
|
| 81 | 81 | && property_exists($this, 'metadata') |
| 82 | 82 | && $this->metadata === null) { |
| 83 | 83 | $this->metadata = new metadata($this); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | foreach ($candidates as $candidate) { |
| 100 | 100 | if ($this->$candidate !== null) { |
| 101 | 101 | //Proxies become stale if the object itself is detached, so we have to re-fetch |
| 102 | - if ( $this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 102 | + if ($this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 103 | 103 | && $this->$candidate->__isInitialized()) { |
| 104 | 104 | try { |
| 105 | 105 | $this->$candidate->get_by_id($this->$candidate->id); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | // According to Doctrine documentation, proxies should be transparent, but in practice, |
| 125 | 125 | // there will be problems if we don't force-load |
| 126 | - if ( $entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 126 | + if ($entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 127 | 127 | && !$entity->__isInitialized()) { |
| 128 | 128 | try { |
| 129 | 129 | $entity->__load(); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | exception::duplicate(); |
| 170 | 170 | return false; |
| 171 | 171 | } |
| 172 | - if ( !$this->is_unique() |
|
| 172 | + if (!$this->is_unique() |
|
| 173 | 173 | || !$this->check_parent()) { |
| 174 | 174 | return false; |
| 175 | 175 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | midgard_connection::get_instance()->set_error(MGD_ERR_INVALID_PROPERTY_VALUE); |
| 221 | 221 | return false; |
| 222 | 222 | } |
| 223 | - if ( $check_dependencies |
|
| 223 | + if ($check_dependencies |
|
| 224 | 224 | && $this->has_dependents()) { |
| 225 | 225 | exception::has_dependants(); |
| 226 | 226 | return false; |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | { |
| 303 | 303 | $this->initialize(); |
| 304 | 304 | |
| 305 | - if ( empty($this->cm->midgard['parentfield']) |
|
| 305 | + if (empty($this->cm->midgard['parentfield']) |
|
| 306 | 306 | || empty($this->cm->midgard['parent'])) { |
| 307 | 307 | return true; |
| 308 | 308 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $this->initialize(); |
| 320 | 320 | |
| 321 | 321 | foreach ($this->cm->fieldMappings as $name => $field) { |
| 322 | - if ( $field['midgard:midgard_type'] == translator::TYPE_GUID |
|
| 322 | + if ($field['midgard:midgard_type'] == translator::TYPE_GUID |
|
| 323 | 323 | && !empty($this->$name) |
| 324 | 324 | && !mgd_is_guid($this->$name)) { |
| 325 | 325 | exception::invalid_property_value("'" . $name . "' property's value is not a guid."); |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $stat = ($results > 0); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - if ( !$stat |
|
| 358 | + if (!$stat |
|
| 359 | 359 | && !empty($this->cm->midgard['childtypes'])) { |
| 360 | 360 | foreach ($this->cm->midgard['childtypes'] as $typename => $parentfield) { |
| 361 | 361 | $qb = connection::get_em()->createQueryBuilder(); |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | exception::not_exists(); |
| 685 | 685 | return false; |
| 686 | 686 | } |
| 687 | - if ( $check_dependencies |
|
| 687 | + if ($check_dependencies |
|
| 688 | 688 | && $this->has_dependents()) { |
| 689 | 689 | exception::has_dependants(); |
| 690 | 690 | return false; |
@@ -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 |
@@ -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 | } |