Completed
Branch master (411345)
by Rémi
11:20
created
src/EntityMap.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
         if (!is_null($this->sequence)) {
419 419
             return $this->sequence;
420 420
         } else {
421
-            return $this->getTable() . '_id_seq';
421
+            return $this->getTable().'_id_seq';
422 422
         }
423 423
     }
424 424
 
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      */
641 641
     public function getQualifiedKeyName() : string
642 642
     {
643
-        return $this->getTable() . '.' . $this->getKeyName();
643
+        return $this->getTable().'.'.$this->getKeyName();
644 644
     }
645 645
 
646 646
     /**
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
      */
722 722
     public function getForeignKey() : string
723 723
     {
724
-        return snake_case(class_basename($this->getClass())) . '_id';
724
+        return snake_case(class_basename($this->getClass())).'_id';
725 725
     }
726 726
 
727 727
     /**
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
      */
775 775
     protected function addSingleRelation($relation)
776 776
     {
777
-        if(! in_array($relation, $this->singleRelations)) {
777
+        if (!in_array($relation, $this->singleRelations)) {
778 778
             $this->singleRelations[] = $relation;
779 779
         }
780 780
     }
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
      */
787 787
     protected function addForeignRelation($relation)
788 788
     {
789
-        if(! in_array($relation, $this->foreignRelations)) {
789
+        if (!in_array($relation, $this->foreignRelations)) {
790 790
             $this->foreignRelations[] = $relation;
791 791
         }
792 792
     }
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
      */
799 799
     protected function addNonProxyRelation($relation)
800 800
     {
801
-        if(! in_array($relation, $this->nonProxyRelationships)) {
801
+        if (!in_array($relation, $this->nonProxyRelationships)) {
802 802
             $this->nonProxyRelationships[] = $relation;
803 803
         }
804 804
     }
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
      */
811 811
     protected function addLocalRelation($relation)
812 812
     {
813
-        if(! in_array($relation, $this->localRelations)) {
813
+        if (!in_array($relation, $this->localRelations)) {
814 814
             $this->localRelations[] = $relation;
815 815
         }
816 816
     }
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
      */
823 823
     protected function addManyRelation($relation)
824 824
     {
825
-        if(! in_array($relation, $this->manyRelations)) {
825
+        if (!in_array($relation, $this->manyRelations)) {
826 826
             $this->manyRelations[] = $relation;
827 827
         }
828 828
     }
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
      */
835 835
     protected function addPivotRelation($relation)
836 836
     {
837
-        if(! in_array($relation, $this->pivotRelations)) {
837
+        if (!in_array($relation, $this->pivotRelations)) {
838 838
             $this->pivotRelations[] = $relation;
839 839
         }
840 840
     }
@@ -870,11 +870,11 @@  discard block
 block discarded – undo
870 870
 
871 871
         // This relationship will always be eager loaded, as proxying it would
872 872
         // mean having an object that doesn't actually exists.
873
-        if(! in_array($relation, $this->with)) {
873
+        if (!in_array($relation, $this->with)) {
874 874
             $this->with[] = $relation;
875 875
         }
876 876
 
877
-        return new HasOne($relatedMapper, $entity, $relatedMap->getTable() . '.' . $foreignKey, $localKey);
877
+        return new HasOne($relatedMapper, $entity, $relatedMap->getTable().'.'.$foreignKey, $localKey);
878 878
     }
879 879
 
880 880
     /**
@@ -910,11 +910,11 @@  discard block
 block discarded – undo
910 910
 
911 911
         // This relationship will always be eager loaded, as proxying it would
912 912
         // mean having an object that doesn't actually exists.
913
-        if(! in_array($relation, $this->with)) {
913
+        if (!in_array($relation, $this->with)) {
914 914
             $this->with[] = $relation;
915 915
         }
916 916
         
917
-        return new MorphOne($relatedMapper, $entity, $table . '.' . $type, $table . '.' . $id, $localKey);
917
+        return new MorphOne($relatedMapper, $entity, $table.'.'.$type, $table.'.'.$id, $localKey);
918 918
     }
919 919
 
920 920
     /**
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
         // foreign key name by using the name of the relationship function, which
943 943
         // when combined with an "_id" should conventionally match the columns.
944 944
         if (is_null($foreignKey)) {
945
-            $foreignKey = snake_case($relation) . '_id';
945
+            $foreignKey = snake_case($relation).'_id';
946 946
         }
947 947
 
948 948
         $this->localForeignKeys[$relation] = $foreignKey;
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 
1036 1036
         $relatedMapper = Manager::getInstance()->mapper($related);
1037 1037
 
1038
-        $table = $relatedMapper->getEntityMap()->getTable() . '.' . $foreignKey;
1038
+        $table = $relatedMapper->getEntityMap()->getTable().'.'.$foreignKey;
1039 1039
 
1040 1040
         $localKey = $localKey ?: $this->getKeyName();
1041 1041
 
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
         $this->addManyRelation($relation);
1118 1118
         $this->addForeignRelation($relation);
1119 1119
 
1120
-        return new MorphMany($relatedMapper, $entity, $table . '.' . $type, $table . '.' . $id, $localKey);
1120
+        return new MorphMany($relatedMapper, $entity, $table.'.'.$type, $table.'.'.$id, $localKey);
1121 1121
     }
1122 1122
 
1123 1123
     /**
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
         // First, we will need to determine the foreign key and "other key" for the
1192 1192
         // relationship. Once we have determined the keys we will make the query
1193 1193
         // instances, as well as the relationship instances we need for these.
1194
-        $foreignKey = $foreignKey ?: $name . '_id';
1194
+        $foreignKey = $foreignKey ?: $name.'_id';
1195 1195
 
1196 1196
         $relatedMapper = Manager::getInstance()->mapper($related);
1197 1197
 
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
         // For the inverse of the polymorphic many-to-many relations, we will change
1230 1230
         // the way we determine the foreign and other keys, as it is the opposite
1231 1231
         // of the morph-to-many method since we're figuring out these inverses.
1232
-        $otherKey = $otherKey ?: $name . '_id';
1232
+        $otherKey = $otherKey ?: $name.'_id';
1233 1233
 
1234 1234
         return $this->morphToMany($entity, $related, $name, $table, $foreignKey, $otherKey, true);
1235 1235
     }
@@ -1269,9 +1269,9 @@  discard block
 block discarded – undo
1269 1269
      */
1270 1270
     protected function getMorphs($name, $type, $id)
1271 1271
     {
1272
-        $type = $type ?: $name . '_type';
1272
+        $type = $type ?: $name.'_type';
1273 1273
 
1274
-        $id = $id ?: $name . '_id';
1274
+        $id = $id ?: $name.'_id';
1275 1275
 
1276 1276
         return [$type, $id];
1277 1277
     }
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
     public function __call($method, $parameters)
1421 1421
     {
1422 1422
         if (!array_key_exists($method, $this->dynamicRelationships)) {
1423
-            throw new Exception(get_class($this) . " has no method $method");
1423
+            throw new Exception(get_class($this)." has no method $method");
1424 1424
         }
1425 1425
 
1426 1426
         // Add $this to parameters so the closure can call relationship method on the map.
Please login to merge, or discard this patch.
src/System/EntityCache.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
         $keyColumn = $this->entityMap->getKeyName();
68 68
 
69
-        foreach($results as $result) {
69
+        foreach ($results as $result) {
70 70
             $id = $result[$keyColumn];
71 71
 
72 72
             // Forget the ID field from the cache attributes
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
         $keyName = $mapper->getEntityMap()->getKeyName();
238 238
 
239
-        return $class . '.' . $entity->getEntityAttribute($keyName);
239
+        return $class.'.'.$entity->getEntityAttribute($keyName);
240 240
     }
241 241
 
242 242
     /**
Please login to merge, or discard this patch.
src/System/Wrappers/ObjectWrapper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
 
115 115
         // If the entity does not uses the attributes array to store
116 116
         // part of its attributes, we'll directly return the properties
117
-        if(! $this->entityMap->usesAttributesArray()) {
117
+        if (!$this->entityMap->usesAttributesArray()) {
118 118
             return $properties;
119 119
         }
120 120
 
121 121
         $arrayName = $this->entityMap->getAttributesArrayName();
122 122
         
123
-        if(! array_key_exists($arrayName, $properties)) {
123
+        if (!array_key_exists($arrayName, $properties)) {
124 124
             throw new MappingException("Property $arrayName not set on object of type ".$this->getEntityClass());
125 125
         }
126 126
 
127
-        if(! is_array($properties[$arrayName])) {
127
+        if (!is_array($properties[$arrayName])) {
128 128
             throw new MappingException("Property $arrayName should be an array.");
129 129
         }
130 130
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
         $attributesArrayName = $this->entityMap->getAttributesArrayName();
156 156
 
157
-        if($attributesArrayName) {
157
+        if ($attributesArrayName) {
158 158
             $propertyAttributes[$attributesArrayName] = $attributesArray;
159 159
         }
160 160
 
Please login to merge, or discard this patch.
src/System/ResultBuilder.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             // constraints have been specified for the eager load and we'll just put
111 111
             // an empty Closure with the loader so that we can treat all the same.
112 112
             if (is_numeric($name)) {
113
-                $f = function () {};
113
+                $f = function() {};
114 114
 
115 115
                 list($name, $constraints) = [$constraints, $f];
116 116
             }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $progress[] = $segment;
145 145
 
146 146
             if (!isset($results[$last = implode('.', $progress)])) {
147
-                $results[$last] = function () {};
147
+                $results[$last] = function() {};
148 148
             }
149 149
         }
150 150
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         // We want to run a relationship query without any constrains so that we will
214 214
         // not have to remove these where clauses manually which gets really hacky
215 215
         // and is error prone while we remove the developer's own where clauses.
216
-        $query = Relationship::noConstraints(function () use ($relation) {
216
+        $query = Relationship::noConstraints(function() use ($relation) {
217 217
             return $this->entityMap->$relation($this->defaultMapper->newInstance());
218 218
         });
219 219
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         // that start with the given top relations and adds them to our arrays.
245 245
         foreach ($this->eagerLoads as $name => $constraints) {
246 246
             if ($this->isNested($name, $relation)) {
247
-                $nested[substr($name, strlen($relation . '.'))] = $constraints;
247
+                $nested[substr($name, strlen($relation.'.'))] = $constraints;
248 248
             }
249 249
         }
250 250
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $dots = str_contains($name, '.');
264 264
 
265
-        return $dots && starts_with($name, $relation . '.');
265
+        return $dots && starts_with($name, $relation.'.');
266 266
     }
267 267
 
268 268
     /**
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
         $columnMap = $this->entityMap->getDiscriminatorColumnMap();
314 314
 
315
-        $class = isset($columnMap[$type]) ? $columnMap[$type]: $type;
315
+        $class = isset($columnMap[$type]) ? $columnMap[$type] : $type;
316 316
 
317 317
         if (!isset($this->builders[$type])) {
318 318
             $this->builders[$type] = new EntityBuilder(
Please login to merge, or discard this patch.
src/System/Query.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             $count = new Expression($count);
459 459
         }
460 460
 
461
-        return $this->where(new Expression('(' . $hasQuery->toSql() . ')'), $operator, $count, $boolean);
461
+        return $this->where(new Expression('('.$hasQuery->toSql().')'), $operator, $count, $boolean);
462 462
     }
463 463
 
464 464
     /**
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
      */
492 492
     protected function getHasRelationQuery($relation, $entity)
493 493
     {
494
-        return Relationship::noConstraints(function () use ($relation, $entity) {
494
+        return Relationship::noConstraints(function() use ($relation, $entity) {
495 495
             return $this->entityMap->$relation($entity);
496 496
         });
497 497
     }
Please login to merge, or discard this patch.
src/System/Aggregate.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
             return true;
246 246
         }
247 247
         
248
-        if (is_array($value) || (! $value instanceof CollectionProxy && $value instanceof Collection)) {
248
+        if (is_array($value) || (!$value instanceof CollectionProxy && $value instanceof Collection)) {
249 249
             $this->needSync[] = $relation;
250 250
         }
251 251
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
             //$value = $value->getUnderlyingCollection();
258 258
         }
259 259
 
260
-        if ($value instanceof CollectionProxy && ! $value->isProxyInitialized()) {
260
+        if ($value instanceof CollectionProxy && !$value->isProxyInitialized()) {
261 261
             $value = $value->getAddedItems();
262 262
         }
263 263
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
      */
366 366
     public function getEntityHash()
367 367
     {
368
-        return $this->getEntityClass() . '.' . $this->getEntityId();
368
+        return $this->getEntityClass().'.'.$this->getEntityId();
369 369
     }
370 370
 
371 371
     /**
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
             unset($attributes[$relation]);
559 559
         }
560 560
 
561
-        if($this->entityMap->getInheritanceType() == 'single_table') {
561
+        if ($this->entityMap->getInheritanceType() == 'single_table') {
562 562
             $attributes = $this->addDiscriminatorColumn($attributes);
563 563
         }
564 564
 
@@ -580,14 +580,14 @@  discard block
 block discarded – undo
580 580
         $discriminatorColumn = $this->entityMap->getDiscriminatorColumn();
581 581
         $entityClass = $this->entityMap->getClass();
582 582
 
583
-        if(! array_key_exists($discriminatorColumn, $attributes)) {
583
+        if (!array_key_exists($discriminatorColumn, $attributes)) {
584 584
             
585 585
             // Use key if present in discriminatorMap
586 586
             $map = $this->entityMap->getDiscriminatorColumnMap();
587 587
 
588 588
             $type = array_search($entityClass, $map);
589 589
 
590
-            if($type === false) {
590
+            if ($type === false) {
591 591
                 // Use entity FQDN if no corresponding key is set
592 592
                 $attributes[$discriminatorColumn] = $entityClass;
593 593
             }
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
             $prefix = snake_case(class_basename($embed));
625 625
 
626 626
             foreach ($valueObjectAttributes as $key=>$value) {
627
-                $valueObjectAttributes[$prefix . '_' . $key] = $value;
627
+                $valueObjectAttributes[$prefix.'_'.$key] = $value;
628 628
                 unset($valueObjectAttributes[$key]);
629 629
             }
630 630
 
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
             }
686 686
         }
687 687
 
688
-        if ( ! is_null($this->parent)) {
688
+        if (!is_null($this->parent)) {
689 689
             $foreignKeys = $foreignKeys + $this->getForeignKeyAttributesFromParent();
690 690
         }
691 691
 
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
      */
915 915
     protected function getEntityHashesFromRelation($relation)
916 916
     {
917
-        return array_map(function ($aggregate) {
917
+        return array_map(function($aggregate) {
918 918
             return $aggregate->getEntityHash();
919 919
         }, $this->relationships[$relation]);
920 920
     }
Please login to merge, or discard this patch.
src/Relationships/BelongsTo.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     {
99 99
         $query->select(new Expression('count(*)'));
100 100
 
101
-        $otherKey = $this->wrap($query->getTable() . '.' . $this->otherKey);
101
+        $otherKey = $this->wrap($query->getTable().'.'.$this->otherKey);
102 102
 
103 103
         return $query->where($this->getQualifiedForeignKey(), '=', new Expression($otherKey));
104 104
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         // execute a "where in" statement to gather up all of those related records.
135 135
         foreach ($results as $result) {
136 136
 
137
-            if(!is_null($value = $result[$this->foreignKey])) {
137
+            if (!is_null($value = $result[$this->foreignKey])) {
138 138
                 $keys[] = $value;
139 139
             }
140 140
         }
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
      */
274 274
     public function getQualifiedForeignKey()
275 275
     {
276
-        return $this->parentMap->getTable() . '.' . $this->foreignKey;
276
+        return $this->parentMap->getTable().'.'.$this->foreignKey;
277 277
     }
278 278
 
279 279
     /**
@@ -293,6 +293,6 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function getQualifiedOtherKeyName()
295 295
     {
296
-        return $this->relatedMap->getTable() . '.' . $this->otherKey;
296
+        return $this->relatedMap->getTable().'.'.$this->otherKey;
297 297
     }
298 298
 }
Please login to merge, or discard this patch.
src/Relationships/Relationship.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
         $host = $this;
238 238
 
239
-        return array_unique(array_values(array_map(function ($value) use ($key, $host) {
239
+        return array_unique(array_values(array_map(function($value) use ($key, $host) {
240 240
             if (!$value instanceof InternallyMappable) {
241 241
                 $value = $host->factory->make($value);
242 242
             }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             $key = $this->relatedMap->getKeyName();
260 260
         }
261 261
 
262
-        return array_unique(array_values(array_map(function ($value) use ($key) {
262
+        return array_unique(array_values(array_map(function($value) use ($key) {
263 263
             return $value[$key];
264 264
         }, $results)));
265 265
     }
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
         $keyName = Mapper::getMapper($class)->getEntityMap()->getKeyName();
426 426
 
427
-        return $class . '.' . $entity->getEntityAttribute($keyName);
427
+        return $class.'.'.$entity->getEntityAttribute($keyName);
428 428
     }
429 429
 
430 430
     /**
Please login to merge, or discard this patch.
src/Relationships/HasManyThrough.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             $farParentKeyName = $this->farParentMap->getKeyName();
75 75
 
76 76
             $this->query->where(
77
-                $parentTable . '.' . $this->firstKey,
77
+                $parentTable.'.'.$this->firstKey,
78 78
                 '=',
79 79
                 $this->farParent->getEntityAttribute($farParentKeyName)
80 80
             );
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
         $query->select(new Expression('count(*)'));
98 98
 
99
-        $key = $this->wrap($parentTable . '.' . $this->firstKey);
99
+        $key = $this->wrap($parentTable.'.'.$this->firstKey);
100 100
 
101 101
         return $query->where($this->getHasCompareKey(), '=', new Expression($key));
102 102
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     {
112 112
         $query = $query ?: $this->query;
113 113
 
114
-        $foreignKey = $this->relatedMap->getTable() . '.' . $this->secondKey;
114
+        $foreignKey = $this->relatedMap->getTable().'.'.$this->secondKey;
115 115
 
116 116
         $query->join($this->parentMap->getTable(), $this->getQualifiedParentKeyName(), '=', $foreignKey);
117 117
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         $table = $this->parentMap->getTable();
128 128
 
129
-        $this->query->whereIn($table . '.' . $this->firstKey, $this->getKeysFromResults($results));
129
+        $this->query->whereIn($table.'.'.$this->firstKey, $this->getKeysFromResults($results));
130 130
     }
131 131
 
132 132
     /**
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
     protected function getSelectColumns(array $columns = ['*'])
240 240
     {
241 241
         if ($columns == ['*']) {
242
-            $columns = [$this->relatedMap->getTable() . '.*'];
242
+            $columns = [$this->relatedMap->getTable().'.*'];
243 243
         }
244 244
 
245
-        return array_merge($columns, [$this->parentMap->getTable() . '.' . $this->firstKey]);
245
+        return array_merge($columns, [$this->parentMap->getTable().'.'.$this->firstKey]);
246 246
     }
247 247
 
248 248
     /**
Please login to merge, or discard this patch.