Completed
Push — master ( 6173d9...210649 )
by Neomerx
04:26
created
src/Contracts/Api/CrudInterface.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     public function fetchResources(QueryBuilder $builder, string $modelClass): PaginatedDataInterface;
121 121
 
122 122
     /**
123
-     * @param QueryBuilder|null $builder
123
+     * @param QueryBuilder $builder
124 124
      * @param string|null       $modelClass
125 125
      *
126 126
      * @return mixed|null
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      * @param string       $modelClass
141 141
      * @param string       $columnName
142 142
      *
143
-     * @return iterable
143
+     * @return \Generator
144 144
      */
145 145
     public function fetchColumn(QueryBuilder $builder, string $modelClass, string $columnName): iterable;
146 146
 
Please login to merge, or discard this patch.
src/Contracts/Validation/JsonApiDataRulesSerializerInterface.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@
 block discarded – undo
161 161
     public static function readRulesEndIndexes(array $arrayRuleIndexes): array;
162 162
 
163 163
     /**
164
-     * @param array  $arrayRuleIndexes
164
+     * @param integer[]  $arrayRuleIndexes
165 165
      * @param string $name
166 166
      *
167 167
      * @return array
Please login to merge, or discard this patch.
src/Api/Crud.php 1 patch
Spacing   +23 added lines, -24 removed lines patch added patch discarded remove patch
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public function withIndexesFilter(array $indexes): CrudInterface
210 210
     {
211
-        assert(call_user_func(function () use ($indexes) {
211
+        assert(call_user_func(function() use ($indexes) {
212 212
             $allOk = true;
213 213
 
214 214
             foreach ($indexes as $index) {
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
             $classAtPath = new ArrayObject();
761 761
             $idsAtPath   = new ArrayObject();
762 762
 
763
-            $registerModelAtRoot = function ($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
763
+            $registerModelAtRoot = function($model) use ($modelStorage, $modelsAtPath, $idsAtPath): void {
764 764
                 self::registerModelAtPath(
765 765
                     $model,
766 766
                     static::ROOT_PATH,
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
                 assert(is_string($pathPiece));
849 849
                 $parent                    = $tmpPath;
850 850
                 $tmpPath                   = empty($tmpPath) === true ?
851
-                    $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece;
851
+                    $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece;
852 852
                 $normalizedPaths[$tmpPath] = [$parent, $pathPiece];
853 853
                 $pathsDepths[$parent]      = $parentDepth++;
854 854
             }
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
     ): ModelQueryBuilder {
1018 1018
         assert(
1019 1019
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $relationshipName),
1020
-            "Relationship `$relationshipName` do not exist in model `" . $this->getModelClass() . '`'
1020
+            "Relationship `$relationshipName` do not exist in model `".$this->getModelClass().'`'
1021 1021
         );
1022 1022
 
1023 1023
         // as we read data from a relationship our main table and model would be the table/model in the relationship
@@ -1036,8 +1036,7 @@  discard block
 block discarded – undo
1036 1036
             $filters = $this->getFilters();
1037 1037
             $sorts   = $this->getSorts();
1038 1038
             $this->areFiltersWithAnd() ?
1039
-                $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) :
1040
-                $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts);
1039
+                $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts);
1041 1040
         }
1042 1041
         // ... and the input filters to actual data we select
1043 1042
         if ($relationshipFilters !== null) {
@@ -1067,7 +1066,7 @@  discard block
 block discarded – undo
1067 1066
     ) {
1068 1067
         assert(
1069 1068
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name),
1070
-            "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`'
1069
+            "Relationship `$name` do not exist in model `".$this->getModelClass().'`'
1071 1070
         );
1072 1071
 
1073 1072
         // depending on the relationship type we expect the result to be either single resource or a collection
@@ -1096,7 +1095,7 @@  discard block
 block discarded – undo
1096 1095
     ): array {
1097 1096
         assert(
1098 1097
             $this->getModelSchemas()->hasRelationship($this->getModelClass(), $name),
1099
-            "Relationship `$name` do not exist in model `" . $this->getModelClass() . '`'
1098
+            "Relationship `$name` do not exist in model `".$this->getModelClass().'`'
1100 1099
         );
1101 1100
 
1102 1101
         // depending on the relationship type we expect the result to be either single resource or a collection
@@ -1172,7 +1171,7 @@  discard block
 block discarded – undo
1172 1171
 
1173 1172
         $this->clearFetchParameters();
1174 1173
 
1175
-        return (int)$deleted;
1174
+        return (int) $deleted;
1176 1175
     }
1177 1176
 
1178 1177
     /**
@@ -1188,7 +1187,7 @@  discard block
 block discarded – undo
1188 1187
 
1189 1188
         $this->clearFetchParameters();
1190 1189
 
1191
-        return (int)$deleted > 0;
1190
+        return (int) $deleted > 0;
1192 1191
     }
1193 1192
 
1194 1193
     /**
@@ -1213,7 +1212,7 @@  discard block
 block discarded – undo
1213 1212
 
1214 1213
         $this->clearBuilderParameters()->clearFetchParameters();
1215 1214
 
1216
-        $this->inTransaction(function () use ($saveMain, $toMany, &$index) {
1215
+        $this->inTransaction(function() use ($saveMain, $toMany, &$index) {
1217 1216
             $saveMain->execute();
1218 1217
 
1219 1218
             // if no index given will use last insert ID as index
@@ -1254,12 +1253,12 @@  discard block
 block discarded – undo
1254 1253
             ->createBuilder($this->getModelClass())
1255 1254
             ->updateModels($allowedChanges)
1256 1255
             ->addFiltersWithAndToTable($filters);
1257
-        $saveMain       = $this->builderSaveResourceOnUpdate($saveMain);
1256
+        $saveMain = $this->builderSaveResourceOnUpdate($saveMain);
1258 1257
         $saveMain->getSQL(); // prepare
1259 1258
 
1260 1259
         $this->clearBuilderParameters()->clearFetchParameters();
1261 1260
 
1262
-        $this->inTransaction(function () use ($saveMain, $toMany, $index, &$updated) {
1261
+        $this->inTransaction(function() use ($saveMain, $toMany, $index, &$updated) {
1263 1262
             $updated = $saveMain->execute();
1264 1263
 
1265 1264
             $builderHook = Closure::fromCallable([$this, 'builderSaveRelationshipOnUpdate']);
@@ -1275,7 +1274,7 @@  discard block
 block discarded – undo
1275 1274
                 )->execute();
1276 1275
 
1277 1276
                 // add new ones
1278
-                $updated   += $this->addInToManyRelationship(
1277
+                $updated += $this->addInToManyRelationship(
1279 1278
                     $connection,
1280 1279
                     $index,
1281 1280
                     $relationshipName,
@@ -1285,7 +1284,7 @@  discard block
 block discarded – undo
1285 1284
             }
1286 1285
         });
1287 1286
 
1288
-        return (int)$updated;
1287
+        return (int) $updated;
1289 1288
     }
1290 1289
 
1291 1290
     /**
@@ -1300,9 +1299,9 @@  discard block
 block discarded – undo
1300 1299
     public function createInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int
1301 1300
     {
1302 1301
         // Check that relationship is `BelongsToMany`
1303
-        assert(call_user_func(function () use ($name): bool {
1302
+        assert(call_user_func(function() use ($name): bool {
1304 1303
             $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name);
1305
-            $errMsg  = "Relationship `$name` of class `" . $this->getModelClass() .
1304
+            $errMsg  = "Relationship `$name` of class `".$this->getModelClass().
1306 1305
                 '` either is not `belongsToMany` or do not exist in the class.';
1307 1306
             $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY;
1308 1307
 
@@ -1324,9 +1323,9 @@  discard block
 block discarded – undo
1324 1323
     public function removeInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int
1325 1324
     {
1326 1325
         // Check that relationship is `BelongsToMany`
1327
-        assert(call_user_func(function () use ($name): bool {
1326
+        assert(call_user_func(function() use ($name): bool {
1328 1327
             $relType = $this->getModelSchemas()->getRelationshipType($this->getModelClass(), $name);
1329
-            $errMsg  = "Relationship `$name` of class `" . $this->getModelClass() .
1328
+            $errMsg  = "Relationship `$name` of class `".$this->getModelClass().
1330 1329
                 '` either is not `belongsToMany` or do not exist in the class.';
1331 1330
             $isOk = $relType === RelationshipTypes::BELONGS_TO_MANY;
1332 1331
 
@@ -1494,7 +1493,7 @@  discard block
 block discarded – undo
1494 1493
     {
1495 1494
         $countBuilder = $this->createBuilder($this->getModelClass());
1496 1495
         $countBuilder->setParameters($builder->getParameters());
1497
-        $countBuilder->select('COUNT(*)')->from('(' . $builder->getSQL() . ') AS RESULT');
1496
+        $countBuilder->select('COUNT(*)')->from('('.$builder->getSQL().') AS RESULT');
1498 1497
 
1499 1498
         return $countBuilder;
1500 1499
     }
@@ -1526,7 +1525,7 @@  discard block
 block discarded – undo
1526 1525
 
1527 1526
         foreach ($secondaryIdentities as $secondaryId) {
1528 1527
             try {
1529
-                $inserted += (int)$saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1528
+                $inserted += (int) $saveToMany->setParameter($secondaryIdBindName, $secondaryId)->execute();
1530 1529
             } /** @noinspection PhpRedundantCatchClauseInspection */ catch (UcvException $exception) {
1531 1530
                 // Spec: If all of the specified resources can be added to, or are already present in,
1532 1531
                 // the relationship then the server MUST return a successful response.
@@ -1773,7 +1772,7 @@  discard block
 block discarded – undo
1773 1772
 
1774 1773
         $pkName = $this->getModelSchemas()->getPrimaryKey($parentClass);
1775 1774
 
1776
-        $registerModelAtPath = function ($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1775
+        $registerModelAtPath = function($model, string $path) use ($deDup, $modelsAtPath, $idsAtPath) {
1777 1776
             return self::registerModelAtPath(
1778 1777
                 $model,
1779 1778
                 $path,
@@ -1785,7 +1784,7 @@  discard block
 block discarded – undo
1785 1784
         };
1786 1785
 
1787 1786
         foreach ($childRelationships as $name) {
1788
-            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name;
1787
+            $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name;
1789 1788
 
1790 1789
             $relationshipType = $this->getModelSchemas()->getRelationshipType($parentClass, $name);
1791 1790
             list ($targetModelClass, $reverseRelName) =
@@ -1840,7 +1839,7 @@  discard block
 block discarded – undo
1840 1839
                             [$pkName => [FilterParameterInterface::OPERATION_EQUALS => [$parent->{$pkName}]]],
1841 1840
                             []
1842 1841
                         );
1843
-                        $children      = $this->fetchPaginatedResourcesWithoutRelationships(
1842
+                        $children = $this->fetchPaginatedResourcesWithoutRelationships(
1844 1843
                             $clonedBuilder,
1845 1844
                             $clonedBuilder->getModelClass()
1846 1845
                         );
Please login to merge, or discard this patch.
src/Validation/JsonApi/DataParser.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -245,8 +245,7 @@
 block discarded – undo
245 245
             $this->executeStarts($this->getSerializer()::readRuleStartIndexes($ruleIndexes));
246 246
             $ruleIndex = $this->getSerializer()::readRuleIndex($ruleIndexes);
247 247
             $isFoundInToOne === true ?
248
-                $this->validateAsToOneRelationship($ruleIndex, $name, $jsonData) :
249
-                $this->validateAsToManyRelationship($ruleIndex, $name, $jsonData);
248
+                $this->validateAsToOneRelationship($ruleIndex, $name, $jsonData) : $this->validateAsToManyRelationship($ruleIndex, $name, $jsonData);
250 249
             $this->executeEnds($this->getSerializer()::readRuleEndIndexes($ruleIndexes));
251 250
 
252 251
             if (count($this->getErrorAggregator()) > 0) {
Please login to merge, or discard this patch.
src/Validation/JsonApi/Execution/JsonApiQueryRulesSerializer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     private $serializedRules = [];
36 36
 
37 37
     /** Index key */
38
-    protected const IDENTITY_RULE= 0;
38
+    protected const IDENTITY_RULE = 0;
39 39
 
40 40
     /** Index key */
41 41
     protected const FILTER_RULES = self::IDENTITY_RULE + 1;
Please login to merge, or discard this patch.
src/Http/Traits/DefaultControllerMethodsTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
         $modelClass = $schemaClass::MODEL;
650 650
         assert($schemaInfo->hasRelationship($modelClass, $modelRelName));
651 651
         assert(
652
-            ($type =$schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO ||
652
+            ($type = $schemaInfo->getRelationshipType($modelClass, $modelRelName)) === RelationshipTypes::BELONGS_TO ||
653 653
             $type === RelationshipTypes::BELONGS_TO_MANY
654 654
         );
655 655
 
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
      */
905 905
     private static function assertClassValueDefined(?string $value): void
906 906
     {
907
-        assert(empty($value) === false, 'Value should be defined in `' . static::class . '`.');
907
+        assert(empty($value) === false, 'Value should be defined in `'.static::class.'`.');
908 908
     }
909 909
 
910 910
     /**
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
     {
918 918
         assert(
919 919
             array_key_exists($interface, class_implements($class)) === true,
920
-            "Class `$class` should implement `" . $interface . '` interface.'
920
+            "Class `$class` should implement `".$interface.'` interface.'
921 921
         );
922 922
     }
923 923
 }
Please login to merge, or discard this patch.