@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | /** |
307 | 307 | * @inheritdoc |
308 | 308 | */ |
309 | - public function readRow($index): ?array |
|
309 | + public function readRow($index): ? array |
|
310 | 310 | { |
311 | 311 | if ($index !== null && is_scalar($index) === false) { |
312 | 312 | throw new InvalidArgumentException( |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | $deleted = $builder->execute(); |
344 | 344 | |
345 | - return (int)$deleted; |
|
345 | + return (int) $deleted; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $saveMain = $this->getRepository()->create($modelClass, $allowedChanges); |
364 | 364 | $saveMain = $this->builderSaveResourceOnCreate($saveMain); |
365 | 365 | $saveMain->getSQL(); // prepare |
366 | - $this->inTransaction(function () use ($modelClass, $saveMain, $toMany, &$index) { |
|
366 | + $this->inTransaction(function() use ($modelClass, $saveMain, $toMany, &$index) { |
|
367 | 367 | $saveMain->execute(); |
368 | 368 | // if no index given will use last insert ID as index |
369 | 369 | $index !== null ?: $index = $saveMain->getConnection()->lastInsertId(); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $saveMain = $this->getRepository()->update($modelClass, $index, $allowedChanges); |
403 | 403 | $saveMain = $this->builderSaveResourceOnUpdate($saveMain); |
404 | 404 | $saveMain->getSQL(); // prepare |
405 | - $this->inTransaction(function () use ($modelClass, $saveMain, $toMany, $index, &$updated) { |
|
405 | + $this->inTransaction(function() use ($modelClass, $saveMain, $toMany, $index, &$updated) { |
|
406 | 406 | $updated = $saveMain->execute(); |
407 | 407 | foreach ($toMany as $name => $values) { |
408 | 408 | $indexBind = ':index'; |
@@ -417,12 +417,12 @@ discard block |
||
417 | 417 | $saveToMany = $this->builderSaveRelationshipOnUpdate($name, $saveToMany); |
418 | 418 | $saveToMany->setParameter($indexBind, $index); |
419 | 419 | foreach ($values as $value) { |
420 | - $updated += (int)$saveToMany->setParameter($otherIndexBind, $value)->execute(); |
|
420 | + $updated += (int) $saveToMany->setParameter($otherIndexBind, $value)->execute(); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | }); |
424 | 424 | |
425 | - return (int)$updated; |
|
425 | + return (int) $updated; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @return array|null |
529 | 529 | */ |
530 | - protected function fetchRow(QueryBuilder $builder, string $class): ?array |
|
530 | + protected function fetchRow(QueryBuilder $builder, string $class): ? array |
|
531 | 531 | { |
532 | 532 | $statement = $builder->execute(); |
533 | 533 | $statement->setFetchMode(PDOConnection::FETCH_ASSOC); |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | foreach ($path->getPath() as $pathPiece) { |
840 | 840 | $parent = $tmpPath; |
841 | 841 | $tmpPath = empty($tmpPath) === true ? |
842 | - $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece; |
|
842 | + $pathPiece : $tmpPath.static::PATH_SEPARATOR.$pathPiece; |
|
843 | 843 | $normalizedPaths[$tmpPath] = [$parent, $pathPiece]; |
844 | 844 | $pathsDepths[$parent] = $parentDepth++; |
845 | 845 | } |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | // $models. |
891 | 891 | |
892 | 892 | foreach ($childRelationships as $name) { |
893 | - $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath . static::PATH_SEPARATOR . $name : $name; |
|
893 | + $childrenPath = $parentsPath !== static::ROOT_PATH ? $parentsPath.static::PATH_SEPARATOR.$name : $name; |
|
894 | 894 | |
895 | 895 | /** @var QueryBuilder $builder */ |
896 | 896 | list ($builder, $class, $relationshipType) = |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $queryParser = $container->get(QueryParametersParserInterface::class); |
125 | 125 | $encodingParams = $queryParser->parse($request); |
126 | 126 | |
127 | - list ($filters, , $includes) = static::mapQueryParameters($container, $encodingParams, static::SCHEMA_CLASS); |
|
127 | + list ($filters,, $includes) = static::mapQueryParameters($container, $encodingParams, static::SCHEMA_CLASS); |
|
128 | 128 | |
129 | 129 | $index = $routeParams[static::ROUTE_KEY_INDEX]; |
130 | 130 | $response = static::readImpl( |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | */ |
275 | 275 | protected static function readJsonFromRequest(ContainerInterface $container, ServerRequestInterface $request): array |
276 | 276 | { |
277 | - $body = (string)$request->getBody(); |
|
277 | + $body = (string) $request->getBody(); |
|
278 | 278 | if (empty($body) === true || ($json = json_decode($body, true)) === null) { |
279 | 279 | /** @var FactoryInterface $factory */ |
280 | 280 | $factory = $container->get(FactoryInterface::class); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | { |
403 | 403 | assert( |
404 | 404 | empty(static::ON_CREATE_VALIDATION_RULES_SET_CLASS) === false, |
405 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
405 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
406 | 406 | ); |
407 | 407 | |
408 | 408 | return static::createJsonApiValidator($container, static::ON_CREATE_VALIDATION_RULES_SET_CLASS); |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | { |
418 | 418 | assert( |
419 | 419 | empty(static::ON_UPDATE_VALIDATION_RULES_SET_CLASS) === false, |
420 | - 'Validation rules set should be defined for class ' . static::class . '.' |
|
420 | + 'Validation rules set should be defined for class '.static::class.'.' |
|
421 | 421 | ); |
422 | 422 | |
423 | 423 | return static::createJsonApiValidator($container, static::ON_UPDATE_VALIDATION_RULES_SET_CLASS); |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | /** @var JsonSchemesInterface $jsonSchemes */ |
533 | 533 | $jsonSchemes = $container->get(JsonSchemesInterface::class); |
534 | 534 | $targetSchema = $jsonSchemes->getRelationshipSchema(static::SCHEMA_CLASS, $relationshipName); |
535 | - list ($filters, $sorts, , $paging) = |
|
535 | + list ($filters, $sorts,, $paging) = |
|
536 | 536 | static::mapQueryParameters($container, $encodingParams, get_class($targetSchema)); |
537 | 537 | |
538 | 538 | /** @var SchemaInterface $schemaClass */ |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @inheritdoc |
70 | 70 | */ |
71 | - public function parseParameters(?array $parameters): array |
|
71 | + public function parseParameters(? array $parameters) : array |
|
72 | 72 | { |
73 | 73 | if ($parameters === null) { |
74 | 74 | return [0, $this->getDefaultPageSize() + 1]; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 0, |
82 | 82 | PHP_INT_MAX |
83 | 83 | ); |
84 | - $size = $this->getValue( |
|
84 | + $size = $this->getValue( |
|
85 | 85 | $parameters, |
86 | 86 | static::PARAM_PAGING_SIZE, |
87 | 87 | $this->getDefaultPageSize(), |
@@ -162,7 +162,7 @@ |
||
162 | 162 | protected function setWrapperErrors(array $wrapperErrors): self |
163 | 163 | { |
164 | 164 | if (empty($wrapperErrors) === false) { |
165 | - assert(call_user_func(function () use ($wrapperErrors) : bool { |
|
165 | + assert(call_user_func(function() use ($wrapperErrors) : bool { |
|
166 | 166 | $allAreErrors = true; |
167 | 167 | |
168 | 168 | foreach ($wrapperErrors as $error) { |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | |
53 | 53 | $container[FactoryInterface::class] = $factory; |
54 | 54 | |
55 | - $container[QueryParametersParserInterface::class] = function () use ($factory) { |
|
55 | + $container[QueryParametersParserInterface::class] = function() use ($factory) { |
|
56 | 56 | return $factory->getJsonApiFactory()->createQueryParametersParser(); |
57 | 57 | }; |
58 | 58 | |
59 | - $container[JsonSchemesInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
59 | + $container[JsonSchemesInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
60 | 60 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
61 | 61 | $modelSchemes = $container->get(ModelSchemeInfoInterface::class); |
62 | 62 | |
63 | 63 | return $factory->createJsonSchemes($settings[FluteSettings::KEY_MODEL_TO_SCHEME_MAP], $modelSchemes); |
64 | 64 | }; |
65 | 65 | |
66 | - $container[EncoderInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
66 | + $container[EncoderInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
67 | 67 | /** @var JsonSchemesInterface $jsonSchemes */ |
68 | 68 | $jsonSchemes = $container->get(JsonSchemesInterface::class); |
69 | 69 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | return $encoder; |
79 | 79 | }; |
80 | 80 | |
81 | - $container[FilterOperationsInterface::class] = function (PsrContainerInterface $container) { |
|
81 | + $container[FilterOperationsInterface::class] = function(PsrContainerInterface $container) { |
|
82 | 82 | return new FilterOperations($container); |
83 | 83 | }; |
84 | 84 | |
85 | - $container[RepositoryInterface::class] = function (PsrContainerInterface $container) use ($factory) { |
|
85 | + $container[RepositoryInterface::class] = function(PsrContainerInterface $container) use ($factory) { |
|
86 | 86 | $connection = $container->get(Connection::class); |
87 | 87 | /** @var ModelSchemeInfoInterface $modelSchemes */ |
88 | 88 | $modelSchemes = $container->get(ModelSchemeInfoInterface::class); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | return $factory->createRepository($connection, $modelSchemes, $filerOps, $formatter); |
98 | 98 | }; |
99 | 99 | |
100 | - $container[PaginationStrategyInterface::class] = function (PsrContainerInterface $container) { |
|
100 | + $container[PaginationStrategyInterface::class] = function(PsrContainerInterface $container) { |
|
101 | 101 | $settings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
102 | 102 | |
103 | 103 | return new PaginationStrategy( |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ); |
107 | 107 | }; |
108 | 108 | |
109 | - $container[JsonApiValidatorFactoryInterface::class] = function (PsrContainerInterface $container) { |
|
109 | + $container[JsonApiValidatorFactoryInterface::class] = function(PsrContainerInterface $container) { |
|
110 | 110 | $factory = new JsonApiValidatorFactory($container); |
111 | 111 | |
112 | 112 | return $factory; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public static function configureExceptionHandler(LimoncelloContainerInterface $container) |
136 | 136 | { |
137 | - $container[ThrowableHandlerInterface::class] = function (PsrContainerInterface $container) { |
|
137 | + $container[ThrowableHandlerInterface::class] = function(PsrContainerInterface $container) { |
|
138 | 138 | $appSettings = $container->get(SettingsProviderInterface::class)->get(A::class); |
139 | 139 | $fluteSettings = $container->get(SettingsProviderInterface::class)->get(FluteSettings::class); |
140 | 140 |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | assert(array_key_exists(SchemaInterface::class, class_implements($schemeClass)) === true); |
54 | 54 | $type = $schemeClass::TYPE; |
55 | 55 | |
56 | - $indexSlug = '/{' . BaseController::ROUTE_KEY_INDEX . '}'; |
|
57 | - $params = function ($method) use ($type) { |
|
58 | - return [RouteInterface::PARAM_NAME => $type . '_' . $method]; |
|
56 | + $indexSlug = '/{'.BaseController::ROUTE_KEY_INDEX.'}'; |
|
57 | + $params = function($method) use ($type) { |
|
58 | + return [RouteInterface::PARAM_NAME => $type.'_'.$method]; |
|
59 | 59 | }; |
60 | - $handler = function ($method) use ($controllerClass) { |
|
60 | + $handler = function($method) use ($controllerClass) { |
|
61 | 61 | return [$controllerClass, $method]; |
62 | 62 | }; |
63 | 63 | |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | $group->post($type, $handler(CI::METHOD_CREATE), $params(CI::METHOD_CREATE)); |
71 | 71 | } |
72 | 72 | if (in_array(ControllerReadInterface::class, $classInterfaces) === true) { |
73 | - $group->get($type . $indexSlug, $handler(CI::METHOD_READ), $params(CI::METHOD_READ)); |
|
73 | + $group->get($type.$indexSlug, $handler(CI::METHOD_READ), $params(CI::METHOD_READ)); |
|
74 | 74 | } |
75 | 75 | if (in_array(ControllerUpdateInterface::class, $classInterfaces) === true) { |
76 | - $group->patch($type . $indexSlug, $handler(CI::METHOD_UPDATE), $params(CI::METHOD_UPDATE)); |
|
76 | + $group->patch($type.$indexSlug, $handler(CI::METHOD_UPDATE), $params(CI::METHOD_UPDATE)); |
|
77 | 77 | } |
78 | 78 | if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) { |
79 | - $group->delete($type . $indexSlug, $handler(CI::METHOD_DELETE), $params(CI::METHOD_DELETE)); |
|
79 | + $group->delete($type.$indexSlug, $handler(CI::METHOD_DELETE), $params(CI::METHOD_DELETE)); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return $group; |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected static function controller(GroupInterface $group, string $subUri, string $controllerClass): GroupInterface |
93 | 93 | { |
94 | - $slugged = $subUri . '/{' . BaseController::ROUTE_KEY_INDEX . '}'; |
|
95 | - $params = function ($method) use ($subUri) { |
|
96 | - return [RouteInterface::PARAM_NAME => $subUri . '_' . $method]; |
|
94 | + $slugged = $subUri.'/{'.BaseController::ROUTE_KEY_INDEX.'}'; |
|
95 | + $params = function($method) use ($subUri) { |
|
96 | + return [RouteInterface::PARAM_NAME => $subUri.'_'.$method]; |
|
97 | 97 | }; |
98 | - $handler = function ($method) use ($controllerClass) { |
|
98 | + $handler = function($method) use ($controllerClass) { |
|
99 | 99 | return [$controllerClass, $method]; |
100 | 100 | }; |
101 | 101 | |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | $group->get($slugged, $handler(CI::METHOD_READ), $params(CI::METHOD_READ)); |
113 | 113 | } |
114 | 114 | if (in_array(ControllerUpdateInterface::class, $classInterfaces) === true) { |
115 | - $updateUri = $slugged . '/' . CI::METHOD_UPDATE; |
|
115 | + $updateUri = $slugged.'/'.CI::METHOD_UPDATE; |
|
116 | 116 | $group->post($updateUri, $handler(CI::METHOD_UPDATE), $params(CI::METHOD_UPDATE)); |
117 | 117 | } |
118 | 118 | if (in_array(ControllerDeleteInterface::class, $classInterfaces) === true) { |
119 | - $deleteUri = $slugged . '/' . CI::METHOD_DELETE; |
|
119 | + $deleteUri = $slugged.'/'.CI::METHOD_DELETE; |
|
120 | 120 | $group->post($deleteUri, $handler(CI::METHOD_DELETE), $params(CI::METHOD_DELETE)); |
121 | 121 | } |
122 | 122 | |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | /** @var string $controllerClass */ |
149 | 149 | /** @var string $schemaClass */ |
150 | 150 | |
151 | - $resourceIdUri = $subUri . '/{' . CI::ROUTE_KEY_INDEX . '}/'; |
|
152 | - $selfUri = $resourceIdUri . DocumentInterface::KEYWORD_RELATIONSHIPS . '/' . $relationshipName; |
|
151 | + $resourceIdUri = $subUri.'/{'.CI::ROUTE_KEY_INDEX.'}/'; |
|
152 | + $selfUri = $resourceIdUri.DocumentInterface::KEYWORD_RELATIONSHIPS.'/'.$relationshipName; |
|
153 | 153 | |
154 | 154 | return $group |
155 | 155 | // `self` |
156 | 156 | ->get($selfUri, [$controllerClass, $selfGetMethod]) |
157 | 157 | // `related` |
158 | - ->get($resourceIdUri . $relationshipName, [$controllerClass, $selfGetMethod]); |
|
158 | + ->get($resourceIdUri.$relationshipName, [$controllerClass, $selfGetMethod]); |
|
159 | 159 | } |
160 | 160 | } |
@@ -99,7 +99,7 @@ |
||
99 | 99 | $details = null; |
100 | 100 | if ($this->isDebug === true) { |
101 | 101 | $message = $throwable->getMessage(); |
102 | - $details = (string)$throwable; |
|
102 | + $details = (string) $throwable; |
|
103 | 103 | } |
104 | 104 | $errors->add(new Error(null, null, $httpCode, null, $message, $details)); |
105 | 105 | } |