Completed
Push — master ( b9dc46...d5a64d )
by Neomerx
10:41
created
src/Adapters/ModelQueryBuilder.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         string $relationshipName,
321 321
         iterable $relationshipFilters,
322 322
         ?iterable $relationshipSorts
323
-    ): self {
323
+    ) : self {
324 324
         $joinWith = $this->expr()->andX();
325 325
 
326 326
         return $this->addRelationshipFiltersAndSorts(
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         string $relationshipName,
355 355
         iterable $relationshipFilters,
356 356
         ?iterable $relationshipSorts
357
-    ): self {
357
+    ) : self {
358 358
         $joinWith = $this->expr()->orX();
359 359
 
360 360
         return $this->addRelationshipFiltersAndSorts(
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
         CompositeExpression $filterLink,
416 416
         iterable $relationshipFilters,
417 417
         ?iterable $relationshipSorts
418
-    ): self {
418
+    ) : self {
419 419
         $relationshipType = $this->getModelSchemes()->getRelationshipType($this->getModelClass(), $relationshipName);
420 420
         switch ($relationshipType) {
421 421
             case RelationshipTypes::BELONGS_TO:
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
         CompositeExpression $filterLink,
489 489
         iterable $relationshipFilters,
490 490
         ?iterable $relationshipSorts
491
-    ): self {
491
+    ) : self {
492 492
         $foreignKey = $this->getModelSchemes()->getForeignKey($this->getModelClass(), $relationshipName);
493 493
         list($onePrimaryKey, $oneTable) =
494 494
             $this->getModelSchemes()->getReversePrimaryKey($this->getModelClass(), $relationshipName);
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
         CompositeExpression $filterLink,
523 523
         iterable $relationshipFilters,
524 524
         ?iterable $relationshipSorts
525
-    ): self {
525
+    ) : self {
526 526
         $primaryKey = $this->getModelSchemes()->getPrimaryKey($this->getModelClass());
527 527
         list($manyForeignKey, $manyTable) =
528 528
             $this->getModelSchemes()->getReverseForeignKey($this->getModelClass(), $relationshipName);
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
         CompositeExpression $targetFilterLink,
557 557
         iterable $relationshipFilters,
558 558
         ?iterable $relationshipSorts
559
-    ): self {
559
+    ) : self {
560 560
         $primaryKey = $this->getModelSchemes()->getPrimaryKey($this->getModelClass());
561 561
         list ($intermediateTable, $intermediatePk, $intermediateFk) =
562 562
             $this->getModelSchemes()->getBelongsToManyRelationship($this->getModelClass(), $relationshipName);
@@ -606,9 +606,9 @@  discard block
 block discarded – undo
606 606
         ?CompositeExpression $targetFilterLink,
607 607
         ?iterable $targetFilterParams,
608 608
         ?iterable $relationshipSorts
609
-    ): string {
609
+    ) : string {
610 610
         $targetAlias   = $this->createAlias($targetTable);
611
-        $joinCondition = $this->buildColumnName($fromAlias, $fromColumn) . '=' .
611
+        $joinCondition = $this->buildColumnName($fromAlias, $fromColumn).'='.
612 612
             $this->buildColumnName($targetAlias, $targetColumn);
613 613
 
614 614
         $this->innerJoin(
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
         ?CompositeExpression $targetFilterLink,
668 668
         ?iterable $targetFilterParams,
669 669
         ?iterable $targetSortParams
670
-    ): string {
670
+    ) : string {
671 671
         $intNoSorting = null;
672 672
         $intAlias     = $this->innerJoinOneTable(
673 673
             $fromAlias,
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
             $intFilterParams,
679 679
             $intNoSorting
680 680
         );
681
-        $targetAlias  = $this->innerJoinOneTable(
681
+        $targetAlias = $this->innerJoinOneTable(
682 682
             $intAlias,
683 683
             $intToTargetColumn,
684 684
             $targetTable,
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
      */
699 699
     private function createAlias(string $tableName): string
700 700
     {
701
-        $alias                          = $tableName . (++$this->aliasIdCounter);
701
+        $alias                          = $tableName.(++$this->aliasIdCounter);
702 702
         $this->knownAliases[$tableName] = $alias;
703 703
 
704 704
         return $alias;
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
         if ($this->dtToDbConverter === null) {
877 877
             $type     = Type::getType(DateTimeType::DATETIME);
878 878
             $platform = $this->getConnection()->getDatabasePlatform();
879
-            $this->dtToDbConverter = function (DateTimeInterface $dateTime) use ($type, $platform) : string {
879
+            $this->dtToDbConverter = function(DateTimeInterface $dateTime) use ($type, $platform) : string {
880 880
                 return $type->convertToDatabaseValue($dateTime, $platform);
881 881
             };
882 882
         }
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
         } else {
903 903
             assert(
904 904
                 $value !== null,
905
-                'It seems you are trying to use `null` with =, >, <, or etc operator. ' .
905
+                'It seems you are trying to use `null` with =, >, <, or etc operator. '.
906 906
                 'Use `is null` or `not null` instead.'
907 907
             );
908 908
             assert(is_string($value), "Only strings, booleans and integers are supported.");
Please login to merge, or discard this patch.
src/Api/Crud.php 1 patch
Spacing   +16 added lines, -17 removed lines patch added patch discarded remove patch
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
             $classAtPath = new ArrayObject();
674 674
             $idsAtPath   = new ArrayObject();
675 675
 
676
-            $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
676
+            $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
677 677
                 self::registerModelAtPath(
678 678
                     $model,
679 679
                     static::ROOT_PATH,
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
                 assert(is_string($pathPiece));
762 762
                 $parent                    = $tmpPath;
763 763
                 $tmpPath                   = empty($tmpPath) === true ?
764
-                    $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece;
764
+                    $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece;
765 765
                 $normalizedPaths[$tmpPath] = [$parent, $pathPiece];
766 766
                 $pathsDepths[$parent]      = $parentDepth++;
767 767
             }
@@ -933,8 +933,7 @@  discard block
 block discarded – undo
933 933
             $filters = $this->getFilters();
934 934
             $sorts   = $this->getSorts();
935 935
             $this->areFiltersWithAnd() ?
936
-                $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) :
937
-                $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts);
936
+                $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts);
938 937
         }
939 938
         // ... and the input filters to actual data we select
940 939
         if ($relationshipFilters !== null) {
@@ -1053,7 +1052,7 @@  discard block
 block discarded – undo
1053 1052
 
1054 1053
         $this->clearFetchParameters();
1055 1054
 
1056
-        return (int)$deleted;
1055
+        return (int) $deleted;
1057 1056
     }
1058 1057
 
1059 1058
     /**
@@ -1067,7 +1066,7 @@  discard block
 block discarded – undo
1067 1066
 
1068 1067
         $this->clearFetchParameters();
1069 1068
 
1070
-        return (int)$deleted > 0;
1069
+        return (int) $deleted > 0;
1071 1070
     }
1072 1071
 
1073 1072
     /**
@@ -1088,7 +1087,7 @@  discard block
 block discarded – undo
1088 1087
 
1089 1088
         $this->clearBuilderParameters()->clearFetchParameters();
1090 1089
 
1091
-        $this->inTransaction(function () use ($saveMain, $toMany, &$index) {
1090
+        $this->inTransaction(function() use ($saveMain, $toMany, &$index) {
1092 1091
             $saveMain->execute();
1093 1092
 
1094 1093
             // if no index given will use last insert ID as index
@@ -1104,7 +1103,7 @@  discard block
 block discarded – undo
1104 1103
                         ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName)
1105 1104
                 );
1106 1105
                 foreach ($secondaryIds as $secondaryId) {
1107
-                    $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1106
+                    $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1108 1107
                 }
1109 1108
             }
1110 1109
         });
@@ -1133,12 +1132,12 @@  discard block
 block discarded – undo
1133 1132
             ->createBuilder($this->getModelClass())
1134 1133
             ->updateModels($allowedChanges)
1135 1134
             ->addFiltersWithAndToTable($filters);
1136
-        $saveMain       = $this->builderSaveResourceOnUpdate($saveMain);
1135
+        $saveMain = $this->builderSaveResourceOnUpdate($saveMain);
1137 1136
         $saveMain->getSQL(); // prepare
1138 1137
 
1139 1138
         $this->clearBuilderParameters()->clearFetchParameters();
1140 1139
 
1141
-        $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) {
1140
+        $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) {
1142 1141
             $updated = $saveMain->execute();
1143 1142
 
1144 1143
             foreach ($toMany as $relationshipName => $secondaryIds) {
@@ -1158,12 +1157,12 @@  discard block
 block discarded – undo
1158 1157
                         ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName)
1159 1158
                 );
1160 1159
                 foreach ($secondaryIds as $secondaryId) {
1161
-                    $updated += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1160
+                    $updated += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1162 1161
                 }
1163 1162
             }
1164 1163
         });
1165 1164
 
1166
-        return (int)$updated;
1165
+        return (int) $updated;
1167 1166
     }
1168 1167
 
1169 1168
     /**
@@ -1247,7 +1246,7 @@  discard block
 block discarded – undo
1247 1246
     /**
1248 1247
      * @inheritdoc
1249 1248
      */
1250
-    public function fetchRow(QueryBuilder $builder, string $modelClass): ?array
1249
+    public function fetchRow(QueryBuilder $builder, string $modelClass): ? array
1251 1250
     {
1252 1251
         $model = null;
1253 1252
 
@@ -1427,7 +1426,7 @@  discard block
 block discarded – undo
1427 1426
      *
1428 1427
      * @return iterable
1429 1428
      */
1430
-    protected function filterAttributesOnCreate(?string $index, iterable $attributes): iterable
1429
+    protected function filterAttributesOnCreate(?string $index, iterable $attributes) : iterable
1431 1430
     {
1432 1431
         if ($index !== null) {
1433 1432
             $pkName = $this->getModelSchemes()->getPrimaryKey($this->getModelClass());
@@ -1487,7 +1486,7 @@  discard block
 block discarded – undo
1487 1486
 
1488 1487
         $pkName = $this->getModelSchemes()->getPrimaryKey($parentClass);
1489 1488
 
1490
-        $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1489
+        $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1491 1490
             return self::registerModelAtPath(
1492 1491
                 $model,
1493 1492
                 $path,
@@ -1499,7 +1498,7 @@  discard block
 block discarded – undo
1499 1498
         };
1500 1499
 
1501 1500
         foreach ($childRelationships as $name) {
1502
-            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name;
1501
+            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name;
1503 1502
 
1504 1503
             $relationshipType = $this->getModelSchemes()->getRelationshipType($parentClass, $name);
1505 1504
             list ($targetModelClass, $reverseRelName) =
@@ -1549,7 +1548,7 @@  discard block
 block discarded – undo
1549 1548
                             [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]],
1550 1549
                             []
1551 1550
                         );
1552
-                        $children      = $this->fetchPaginatedResourcesWithoutRelationships(
1551
+                        $children = $this->fetchPaginatedResourcesWithoutRelationships(
1553 1552
                             $clonedBuilder,
1554 1553
                             $clonedBuilder->getModelClass()
1555 1554
                         );
Please login to merge, or discard this patch.