Completed
Push — develop ( 9d9666...8087c5 )
by Neomerx
02:02
created
src/Contracts/Api/CrudInterface.php 1 patch
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     public function fetchResources(QueryBuilder $builder, string $modelClass): PaginatedDataInterface;
109 109
 
110 110
     /**
111
-     * @param QueryBuilder|null $builder
111
+     * @param QueryBuilder $builder
112 112
      * @param string|null       $modelClass
113 113
      *
114 114
      * @return mixed|null
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      * @param string       $modelClass
129 129
      * @param string       $columnName
130 130
      *
131
-     * @return iterable
131
+     * @return \Generator
132 132
      */
133 133
     public function fetchColumn(QueryBuilder $builder, string $modelClass, string $columnName): iterable;
134 134
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     ): array;
212 212
 
213 213
     /**
214
-     * @param int|string    $index
214
+     * @param string    $index
215 215
      * @param string        $name
216 216
      * @param iterable|null $relationshipFilters
217 217
      * @param iterable|null $relationshipSorts
Please login to merge, or discard this patch.
src/Api/Crud.php 1 patch
Spacing   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                 assert(is_string($pathPiece));
675 675
                 $parent                    = $tmpPath;
676 676
                 $tmpPath                   = empty($tmpPath) === true ?
677
-                    $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece;
677
+                    $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece;
678 678
                 $normalizedPaths[$tmpPath] = [$parent, $pathPiece];
679 679
                 $pathsDepths[$parent]      = $parentDepth++;
680 680
             }
@@ -842,8 +842,7 @@  discard block
 block discarded – undo
842 842
             $filters = $this->getFilters();
843 843
             $sorts   = $this->getSorts();
844 844
             $this->areFiltersWithAnd() ?
845
-                $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) :
846
-                $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts);
845
+                $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts);
847 846
         }
848 847
         // ... and the input filters to actual data we select
849 848
         if ($relationshipFilters !== null) {
@@ -962,7 +961,7 @@  discard block
 block discarded – undo
962 961
 
963 962
         $this->clearFetchParameters();
964 963
 
965
-        return (int)$deleted;
964
+        return (int) $deleted;
966 965
     }
967 966
 
968 967
     /**
@@ -991,7 +990,7 @@  discard block
 block discarded – undo
991 990
 
992 991
         $this->clearBuilderParameters()->clearFetchParameters();
993 992
 
994
-        $this->inTransaction(function () use ($saveMain, $toMany, &$index) {
993
+        $this->inTransaction(function() use ($saveMain, $toMany, &$index) {
995 994
             $saveMain->execute();
996 995
 
997 996
             // if no index given will use last insert ID as index
@@ -1007,7 +1006,7 @@  discard block
 block discarded – undo
1007 1006
                         ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName)
1008 1007
                 );
1009 1008
                 foreach ($secondaryIds as $secondaryId) {
1010
-                    $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1009
+                    $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1011 1010
                 }
1012 1011
             }
1013 1012
         });
@@ -1036,12 +1035,12 @@  discard block
 block discarded – undo
1036 1035
             ->createBuilder($this->getModelClass())
1037 1036
             ->updateModels($allowedChanges)
1038 1037
             ->addFiltersWithAndToTable($filters);
1039
-        $saveMain       = $this->builderSaveResourceOnUpdate($saveMain);
1038
+        $saveMain = $this->builderSaveResourceOnUpdate($saveMain);
1040 1039
         $saveMain->getSQL(); // prepare
1041 1040
 
1042 1041
         $this->clearBuilderParameters()->clearFetchParameters();
1043 1042
 
1044
-        $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) {
1043
+        $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) {
1045 1044
             $updated = $saveMain->execute();
1046 1045
 
1047 1046
             foreach ($toMany as $relationshipName => $secondaryIds) {
@@ -1061,12 +1060,12 @@  discard block
 block discarded – undo
1061 1060
                         ->prepareCreateInToManyRelationship($relationshipName, $index, $secondaryIdBindName)
1062 1061
                 );
1063 1062
                 foreach ($secondaryIds as $secondaryId) {
1064
-                    $updated += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1063
+                    $updated += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1065 1064
                 }
1066 1065
             }
1067 1066
         });
1068 1067
 
1069
-        return (int)$updated;
1068
+        return (int) $updated;
1070 1069
     }
1071 1070
 
1072 1071
     /**
@@ -1150,7 +1149,7 @@  discard block
 block discarded – undo
1150 1149
     /**
1151 1150
      * @inheritdoc
1152 1151
      */
1153
-    public function fetchRow(QueryBuilder $builder, string $modelClass): ?array
1152
+    public function fetchRow(QueryBuilder $builder, string $modelClass): ? array
1154 1153
     {
1155 1154
         $model = null;
1156 1155
 
@@ -1300,7 +1299,7 @@  discard block
 block discarded – undo
1300 1299
      *
1301 1300
      * @return iterable
1302 1301
      */
1303
-    protected function filterAttributesOnCreate(?string $index, iterable $attributes): iterable
1302
+    protected function filterAttributesOnCreate(?string $index, iterable $attributes) : iterable
1304 1303
     {
1305 1304
         if ($index !== null) {
1306 1305
             $pkName = $this->getModelSchemes()->getPrimaryKey($this->getModelClass());
@@ -1359,7 +1358,7 @@  discard block
 block discarded – undo
1359 1358
         $pkName = $this->getModelSchemes()->getPrimaryKey($parentClass);
1360 1359
 
1361 1360
         foreach ($childRelationships as $name) {
1362
-            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name;
1361
+            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name;
1363 1362
 
1364 1363
             $relationshipType = $this->getModelSchemes()->getRelationshipType($parentClass, $name);
1365 1364
             list ($targetModelClass, $reverseRelName) =
@@ -1380,7 +1379,7 @@  discard block
 block discarded – undo
1380 1379
                             [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]],
1381 1380
                             []
1382 1381
                         );
1383
-                        $child         = $deDup->register($this->fetchResourceWithoutRelationships(
1382
+                        $child = $deDup->register($this->fetchResourceWithoutRelationships(
1384 1383
                             $clonedBuilder,
1385 1384
                             $clonedBuilder->getModelClass()
1386 1385
                         ));
@@ -1401,7 +1400,7 @@  discard block
 block discarded – undo
1401 1400
                             [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]],
1402 1401
                             []
1403 1402
                         );
1404
-                        $children      = $this->fetchPaginatedResourcesWithoutRelationships(
1403
+                        $children = $this->fetchPaginatedResourcesWithoutRelationships(
1405 1404
                             $clonedBuilder,
1406 1405
                             $clonedBuilder->getModelClass()
1407 1406
                         );
Please login to merge, or discard this patch.
src/Http/BaseController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     protected static function readJsonFromRequest(ContainerInterface $container, ServerRequestInterface $request): array
242 242
     {
243
-        $body = (string)$request->getBody();
243
+        $body = (string) $request->getBody();
244 244
         if (empty($body) === true || ($json = json_decode($body, true)) === null) {
245 245
             /** @var FactoryInterface $factory */
246 246
             $factory = $container->get(FactoryInterface::class);
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
     {
384 384
         assert(
385 385
             empty(static::ON_CREATE_VALIDATION_RULES_SET_CLASS) === false,
386
-            'Validation rules set should be defined for class ' . static::class . '.'
386
+            'Validation rules set should be defined for class '.static::class.'.'
387 387
         );
388 388
 
389 389
         return static::createJsonApiValidator($container, static::ON_CREATE_VALIDATION_RULES_SET_CLASS);
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
     {
399 399
         assert(
400 400
             empty(static::ON_UPDATE_VALIDATION_RULES_SET_CLASS) === false,
401
-            'Validation rules set should be defined for class ' . static::class . '.'
401
+            'Validation rules set should be defined for class '.static::class.'.'
402 402
         );
403 403
 
404 404
         return static::createJsonApiValidator($container, static::ON_UPDATE_VALIDATION_RULES_SET_CLASS);
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
         ContainerInterface $container,
607 607
         ServerRequestInterface $request
608 608
     ): array {
609
-        $jsonData  = static::normalizeIndexValueOnUpdate(
609
+        $jsonData = static::normalizeIndexValueOnUpdate(
610 610
             $routeParams,
611 611
             $container,
612 612
             static::readJsonFromRequest($container, $request)
Please login to merge, or discard this patch.