@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $result = []; |
| 54 | 54 | foreach($arr as $k => $v){ |
| 55 | - if(!isset($result[$v])) $result[$v] = []; |
|
| 55 | + if(!isset($result[$v])) { |
|
| 56 | + $result[$v] = []; |
|
| 57 | + } |
|
| 56 | 58 | $result[$v][] = $k; |
| 57 | 59 | } |
| 58 | 60 | return $result; |
@@ -76,7 +78,9 @@ discard block |
||
| 76 | 78 | private $relationsPrepared = false; |
| 77 | 79 | |
| 78 | 80 | public function prepareEagerRelations() { |
| 79 | - if($this->relationsPrepared) return; |
|
| 81 | + if($this->relationsPrepared) { |
|
| 82 | + return; |
|
| 83 | + } |
|
| 80 | 84 | $this->relationsPrepared = true; |
| 81 | 85 | $localClass = $this->dataClass(); |
| 82 | 86 | $config = Config::forClass($localClass); |
@@ -224,7 +228,9 @@ discard block |
||
| 224 | 228 | foreach($idsQuery as $row){ |
| 225 | 229 | $relID = $row[$component['childField']]; |
| 226 | 230 | $localID = $row[$component['parentField']]; |
| 227 | - if(!isset($collection[$localID])) $collection[$localID] = []; |
|
| 231 | + if(!isset($collection[$localID])) { |
|
| 232 | + $collection[$localID] = []; |
|
| 233 | + } |
|
| 228 | 234 | $collection[$localID][] = $relID; |
| 229 | 235 | $relListReverted[$relID] = 1;//use ids as keys to avoid |
| 230 | 236 | } |
@@ -326,13 +332,18 @@ discard block |
||
| 326 | 332 | |
| 327 | 333 | public static function EnsureArray($arr, $kfield = null) |
| 328 | 334 | { |
| 329 | - if(is_array($arr)) return $arr; |
|
| 335 | + if(is_array($arr)) { |
|
| 336 | + return $arr; |
|
| 337 | + } |
|
| 330 | 338 | $result = []; |
| 331 | 339 | foreach($arr as $k => $v){ |
| 332 | 340 | $key = $k; |
| 333 | 341 | if($kfield!==null) { |
| 334 | - if(is_array($v) && isset($v[$kfield])) $key = $v[$kfield]; |
|
| 335 | - elseif(is_object($v) && isset($v->$kfield)) $key = $v->$kfield; |
|
| 342 | + if(is_array($v) && isset($v[$kfield])) { |
|
| 343 | + $key = $v[$kfield]; |
|
| 344 | + } elseif(is_object($v) && isset($v->$kfield)) { |
|
| 345 | + $key = $v->$kfield; |
|
| 346 | + } |
|
| 336 | 347 | } |
| 337 | 348 | $result[$key] = $v; |
| 338 | 349 | } |