| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 | */ | 
| 33 | 33 | public function add(Table $table): self | 
| 34 | 34 |      { | 
| 35 | -        if($this->mainTable === null) { | |
| 35 | +        if ($this->mainTable === null) { | |
| 36 | 36 | $this->mainTable = $table; | 
| 37 | 37 | } | 
| 38 | 38 | |
| @@ -48,7 +48,7 @@ discard block | ||
| 48 | 48 | */ | 
| 49 | 49 | public function getMainTable(): Table | 
| 50 | 50 |      { | 
| 51 | -        if($this->mainTable === null) { | |
| 51 | +        if ($this->mainTable === null) { | |
| 52 | 52 |              throw new QueryRelationManagerException('no main table found in TableManager'); | 
| 53 | 53 | } | 
| 54 | 54 | |
| @@ -78,10 +78,10 @@ discard block | ||
| 78 | 78 | $tableAliasChain = $this->getTableAliasChain($tableAlias, $joinConditions); | 
| 79 | 79 | $result = []; | 
| 80 | 80 | |
| 81 | -        foreach($tableAliasChain as $alias) { | |
| 81 | +        foreach ($tableAliasChain as $alias) { | |
| 82 | 82 | $table = $this->byAlias($alias); | 
| 83 | 83 | |
| 84 | -            foreach($table->primaryKey as $field) { | |
| 84 | +            foreach ($table->primaryKey as $field) { | |
| 85 | 85 |                  $result[] = "{$alias}_{$field}"; | 
| 86 | 86 | } | 
| 87 | 87 | } | 
| @@ -99,10 +99,10 @@ discard block | ||
| 99 | 99 |      { | 
| 100 | 100 | $result = []; | 
| 101 | 101 | |
| 102 | -        while(true) { | |
| 102 | +        while (true) { | |
| 103 | 103 | $result[] = $tableAlias; | 
| 104 | 104 | |
| 105 | -            if(!$joinConditions->issetByJoinAs($tableAlias)) { | |
| 105 | +            if (!$joinConditions->issetByJoinAs($tableAlias)) { | |
| 106 | 106 | break; | 
| 107 | 107 | } | 
| 108 | 108 | |
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | */ | 
| 119 | 119 | public function getIterator(): iterable | 
| 120 | 120 |      { | 
| 121 | -        foreach($this->mapByAlias as $table) { | |
| 121 | +        foreach ($this->mapByAlias as $table) { | |
| 122 | 122 | yield $table; | 
| 123 | 123 | } | 
| 124 | 124 | } | 
| @@ -141,7 +141,7 @@ discard block | ||
| 141 | 141 | */ | 
| 142 | 142 | protected function addToMap(string $mapName, string $key, Table $table): self | 
| 143 | 143 |      { | 
| 144 | -        if(isset($this->{$mapName}[$table->{$key}])) { | |
| 144 | +        if (isset($this->{$mapName}[$table->{$key}])) { | |
| 145 | 145 |              throw new QueryRelationManagerException("duplicate key '{$key}' in map '{$mapName}' of TableManager"); | 
| 146 | 146 | } | 
| 147 | 147 |          $this->{$mapName}[$table->{$key}] = $table; | 
| @@ -158,7 +158,7 @@ discard block | ||
| 158 | 158 | */ | 
| 159 | 159 | protected function getFromMap(string $mapName, string $key): Table | 
| 160 | 160 |      { | 
| 161 | -        if(!isset($this->{$mapName}[$key])) { | |
| 161 | +        if (!isset($this->{$mapName}[$key])) { | |
| 162 | 162 |              throw new QueryRelationManagerException("key '{$key}' not found in map '{$mapName}' of TableManager"); | 
| 163 | 163 | } | 
| 164 | 164 | |
| @@ -33,15 +33,15 @@ discard block | ||
| 33 | 33 | */ | 
| 34 | 34 | public function add(JoinCondition $condition): self | 
| 35 | 35 |      { | 
| 36 | -        if(isset($this->mapByJoinAs[$condition->table->alias])) { | |
| 36 | +        if (isset($this->mapByJoinAs[$condition->table->alias])) { | |
| 37 | 37 |              throw new QueryRelationManagerException("duplicate table alias '{$condition->table->alias}'"); | 
| 38 | 38 | } | 
| 39 | 39 | $this->mapByJoinAs[$condition->table->alias] = $condition; | 
| 40 | 40 | |
| 41 | -        if(!isset($this->matrixByJoinTo[$condition->joinTo->alias])) { | |
| 41 | +        if (!isset($this->matrixByJoinTo[$condition->joinTo->alias])) { | |
| 42 | 42 | $this->matrixByJoinTo[$condition->joinTo->alias] = []; | 
| 43 | 43 | } | 
| 44 | -        if(isset($this->matrixByJoinTo[$condition->joinTo->alias][$condition->table->alias])) { | |
| 44 | +        if (isset($this->matrixByJoinTo[$condition->joinTo->alias][$condition->table->alias])) { | |
| 45 | 45 |              throw new QueryRelationManagerException("duplicate table alias '{$condition->table->alias}'"); | 
| 46 | 46 | } | 
| 47 | 47 | $this->matrixByJoinTo[$condition->joinTo->alias][$condition->table->alias] = $condition; | 
| @@ -56,7 +56,7 @@ discard block | ||
| 56 | 56 | */ | 
| 57 | 57 | public function issetByJoinAs(string $joinAs): bool | 
| 58 | 58 |      { | 
| 59 | -        if(!isset($this->mapByJoinAs[$joinAs])) { | |
| 59 | +        if (!isset($this->mapByJoinAs[$joinAs])) { | |
| 60 | 60 | return false; | 
| 61 | 61 | } | 
| 62 | 62 | |
| @@ -81,7 +81,7 @@ discard block | ||
| 81 | 81 | */ | 
| 82 | 82 | public function byJoinTo(string $joinTo): array | 
| 83 | 83 |      { | 
| 84 | -        if(!isset($this->matrixByJoinTo[$joinTo])) { | |
| 84 | +        if (!isset($this->matrixByJoinTo[$joinTo])) { | |
| 85 | 85 | return []; | 
| 86 | 86 | } | 
| 87 | 87 | return $this->matrixByJoinTo[$joinTo]; | 
| @@ -93,7 +93,7 @@ discard block | ||
| 93 | 93 | */ | 
| 94 | 94 | public function getIterator(): iterable | 
| 95 | 95 |      { | 
| 96 | -        foreach($this->mapByJoinAs as $condition) { | |
| 96 | +        foreach ($this->mapByJoinAs as $condition) { | |
| 97 | 97 | yield $condition; | 
| 98 | 98 | } | 
| 99 | 99 | } | 
| @@ -184,38 +184,38 @@ discard block | ||
| 184 | 184 | $rows = $this->query->all($db); | 
| 185 | 185 | |
| 186 | 186 | $map = []; | 
| 187 | -        foreach($this->tableCollection as $table) { | |
| 187 | +        foreach ($this->tableCollection as $table) { | |
| 188 | 188 | $map[$table->alias] = []; | 
| 189 | 189 | } | 
| 190 | 190 | |
| 191 | 191 | $bufMap = []; | 
| 192 | 192 | |
| 193 | -        foreach($rows as $row) { | |
| 194 | -            foreach($this->tableCollection as $table) { | |
| 195 | -                if(!$table->issetDataInRow($row)) { | |
| 193 | +        foreach ($rows as $row) { | |
| 194 | +            foreach ($this->tableCollection as $table) { | |
| 195 | +                if (!$table->issetDataInRow($row)) { | |
| 196 | 196 | continue; | 
| 197 | 197 | } | 
| 198 | 198 | |
| 199 | 199 | [$item, $pkValue, $alias, $aliasTo, $fkValue, $containerFieldAlias, $type] | 
| 200 | 200 | = $table->getDataFromRow($row, $this->joinConditionCollection); | 
| 201 | 201 | |
| 202 | -                if(!isset($map[$alias][$pkValue])) { | |
| 202 | +                if (!isset($map[$alias][$pkValue])) { | |
| 203 | 203 | $map[$alias][$pkValue] = &$item; | 
| 204 | 204 | } | 
| 205 | 205 | |
| 206 | -                if($aliasTo !== null) { | |
| 206 | +                if ($aliasTo !== null) { | |
| 207 | 207 |                      $bufMapKey = implode('-', [$aliasTo, $fkValue, $containerFieldAlias, $pkValue]); | 
| 208 | 208 | /** @var string $type */ | 
| 209 | -                    switch($type) { | |
| 209 | +                    switch ($type) { | |
| 210 | 210 | case JoinCondition::TYPE_SINGLE: | 
| 211 | -                            if(!isset($bufMap[$bufMapKey])) { | |
| 211 | +                            if (!isset($bufMap[$bufMapKey])) { | |
| 212 | 212 | /** @var mixed[][][] $map */ | 
| 213 | 213 | $map[$aliasTo][$fkValue][$containerFieldAlias] = &$item; | 
| 214 | 214 | $bufMap[$bufMapKey] = 1; | 
| 215 | 215 | } | 
| 216 | 216 | break; | 
| 217 | 217 | case JoinCondition::TYPE_MULTIPLE: | 
| 218 | -                            if(!isset($bufMap[$bufMapKey])) { | |
| 218 | +                            if (!isset($bufMap[$bufMapKey])) { | |
| 219 | 219 | /** @var mixed[][][][] $map */ | 
| 220 | 220 | $map[$aliasTo][$fkValue][$containerFieldAlias][] = &$item; | 
| 221 | 221 | $bufMap[$bufMapKey] = 1; | 
| @@ -229,8 +229,8 @@ discard block | ||
| 229 | 229 | } | 
| 230 | 230 | } | 
| 231 | 231 | |
| 232 | -        foreach($this->modifierMap as $alias => $modifier) { | |
| 233 | -            foreach($map[$alias] as $pk => &$item) { | |
| 232 | +        foreach ($this->modifierMap as $alias => $modifier) { | |
| 233 | +            foreach ($map[$alias] as $pk => &$item) { | |
| 234 | 234 | ($modifier)($item); | 
| 235 | 235 | } | 
| 236 | 236 | unset($item); | 
| @@ -246,7 +246,7 @@ discard block | ||
| 246 | 246 | */ | 
| 247 | 247 | public function prepare(): QueryWrapperInterface | 
| 248 | 248 |      { | 
| 249 | -        foreach($this->tableCollection as $table) { | |
| 249 | +        foreach ($this->tableCollection as $table) { | |
| 250 | 250 | $table->setPkFieldChain( | 
| 251 | 251 | $this->tableCollection->getPkFieldChain($table->alias, $this->joinConditionCollection) | 
| 252 | 252 | ); | 
| @@ -255,8 +255,8 @@ discard block | ||
| 255 | 255 | $this->query = $this->createQuery(); | 
| 256 | 256 | |
| 257 | 257 | $arSelect = []; | 
| 258 | -        foreach($this->tableCollection as $table) { | |
| 259 | -            foreach($table->getFieldMap() as $fieldName => $fieldNamePrefixed) { | |
| 258 | +        foreach ($this->tableCollection as $table) { | |
| 259 | +            foreach ($table->getFieldMap() as $fieldName => $fieldNamePrefixed) { | |
| 260 | 260 | $arSelect[$fieldNamePrefixed] = $fieldName; | 
| 261 | 261 | } | 
| 262 | 262 | } | 
| @@ -267,7 +267,7 @@ discard block | ||
| 267 | 267 | ->select($arSelect) | 
| 268 | 268 | ->from([$mainTable->alias => $mainTable->name]); | 
| 269 | 269 | |
| 270 | -        foreach($this->joinConditionCollection as $cond) { | |
| 270 | +        foreach ($this->joinConditionCollection as $cond) { | |
| 271 | 271 | $this->query->join( | 
| 272 | 272 | $cond->joinType, | 
| 273 | 273 | [$cond->table->alias => $cond->table->name], | 
| @@ -276,7 +276,7 @@ discard block | ||
| 276 | 276 | ); | 
| 277 | 277 | } | 
| 278 | 278 | |
| 279 | -        foreach($this->filters as $modifier) { | |
| 279 | +        foreach ($this->filters as $modifier) { | |
| 280 | 280 | $modifier($this->query->getQuery()); | 
| 281 | 281 | } | 
| 282 | 282 | |