@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @psalm-suppress RedundantCondition for BC |
| 40 | 40 | */ |
| 41 | - private function getParameterType(ReflectionParameter $parameter, array $paramDoc, string $name): string|null |
|
| 41 | + private function getParameterType(ReflectionParameter $parameter, array $paramDoc, string $name): string | null |
|
| 42 | 42 | { |
| 43 | 43 | /** @phpstan-ignore function.alreadyNarrowedType */ |
| 44 | 44 | $hasType = method_exists($parameter, 'getType') && $parameter->getType(); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $paramDoc[$name]['in'] = $ins[$parameter->name]; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if (! isset($paramDoc[$parameter->name])) { |
|
| 67 | + if (!isset($paramDoc[$parameter->name])) { |
|
| 68 | 68 | $paramDoc[$name] = []; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function addHalLink(array $body, array $methodAnnotations, Hal $hal): Hal |
| 37 | 37 | { |
| 38 | - if (! empty($methodAnnotations)) { |
|
| 38 | + if (!empty($methodAnnotations)) { |
|
| 39 | 39 | $hal = $this->linkAnnotation($body, $methodAnnotations, $hal); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | private function linkAnnotation(array $body, array $methodAnnotations, Hal $hal): Hal |
| 55 | 55 | { |
| 56 | 56 | foreach ($methodAnnotations as $annotation) { |
| 57 | - if (! $annotation instanceof Link) { |
|
| 57 | + if (!$annotation instanceof Link) { |
|
| 58 | 58 | continue; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | private function bodyLink(array $body, Hal $hal): Hal |
| 81 | 81 | { |
| 82 | 82 | foreach ($body['_links'] as $rel => $link) { |
| 83 | - if (! isset($link['href'])) { |
|
| 83 | + if (!isset($link['href'])) { |
|
| 84 | 84 | // @codeCoverageIgnoreStart |
| 85 | 85 | continue; |
| 86 | 86 | // @codeCoverageIgnoreEnd |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | private function annotationLink(LinkType $link, ResourceObject $current, AbstractRequest $request): ResourceObject |
| 111 | 111 | { |
| 112 | - if (! is_array($current->body)) { |
|
| 113 | - throw new Exception\LinkQueryException('Only array is allowed for link in ' . $current::class, 500); |
|
| 112 | + if (!is_array($current->body)) { |
|
| 113 | + throw new Exception\LinkQueryException('Only array is allowed for link in '.$current::class, 500); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $classMethod = 'on' . ucfirst($request->method); |
|
| 116 | + $classMethod = 'on'.ucfirst($request->method); |
|
| 117 | 117 | /** @var list<Link> $annotations */ |
| 118 | 118 | $annotations = (new ReflectionMethod($current::class, $classMethod))->getAnnotations(); |
| 119 | 119 | if ($link->type === LinkType::CRAWL_LINK) { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | return $this->invoker->invoke($request); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - throw new LinkRelException("rel:{$link->key} class:" . $current::class, 500); |
|
| 154 | + throw new LinkRelException("rel:{$link->key} class:".$current::class, 500); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | private function crawl(array $annotations, LinkType $link, array &$body): void |
| 191 | 191 | { |
| 192 | 192 | foreach ($annotations as $annotation) { |
| 193 | - if (! $annotation instanceof Link || $annotation->crawl !== $link->key) { |
|
| 193 | + if (!$annotation instanceof Link || $annotation->crawl !== $link->key) { |
|
| 194 | 194 | continue; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** @return Body|null */ |
| 215 | - private function getResponseBody(Request $request): array|null |
|
| 215 | + private function getResponseBody(Request $request): array | null |
|
| 216 | 216 | { |
| 217 | 217 | $body = $this->invokeRecursive($request)->body; |
| 218 | 218 | assert(is_array($body) || $body === null); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** @return Body */ |
| 36 | 36 | private function fakeResponse(string $schemaFile): array |
| 37 | 37 | { |
| 38 | - if (! class_exists(Faker::class)) { |
|
| 38 | + if (!class_exists(Faker::class)) { |
|
| 39 | 39 | throw new LogicException('"koriym/json-schema-faker" not installed. Please run "composer require koriym/json-schema-faker --dev". See more at https://github.com/bearsunday/BEAR.Resource/wiki/json_schema_faker_required'); // @codeCoverageIgnore |
| 40 | 40 | } |
| 41 | 41 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return Body |
| 52 | 52 | */ |
| 53 | - private function deepArray(array|stdClass $values): array |
|
| 53 | + private function deepArray(array | stdClass $values): array |
|
| 54 | 54 | { |
| 55 | 55 | $result = []; |
| 56 | 56 | /** @psalm-suppress MixedAssignment */ |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | private function getUserFileUploads(string $varName, array $query): array |
| 66 | 66 | { |
| 67 | 67 | $fileUploads = $query[$varName]; |
| 68 | - if (! is_array($fileUploads)) { |
|
| 68 | + if (!is_array($fileUploads)) { |
|
| 69 | 69 | throw new InvalidArgumentException($varName); // Invalid type of array |
| 70 | 70 | } |
| 71 | 71 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | assert(count($fileUploads) > 0); |
| 75 | 75 | foreach ($fileUploads as $fileUpload) { |
| 76 | - if (! ($fileUpload instanceof FileUpload) && ! ($fileUpload instanceof ErrorFileUpload)) { |
|
| 76 | + if (!($fileUpload instanceof FileUpload) && !($fileUpload instanceof ErrorFileUpload)) { |
|
| 77 | 77 | throw new InvalidArgumentException($varName); // Invalid item of array tye of FileUpload or ErrorFileUpload |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | private JsonSchemaExceptionHandlerInterface $handler, |
| 50 | 50 | private JsonSchemaRequestExceptionHandlerInterface $requestHandler, |
| 51 | 51 | #[Named('json_schema_host')] |
| 52 | - private string|null $schemaHost = null, |
|
| 52 | + private string | null $schemaHost = null, |
|
| 53 | 53 | ) { |
| 54 | 54 | } |
| 55 | 55 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | private function validateRequest(MethodInvocation $invocation, JsonSchema $jsonSchema, array $arguments): void |
| 88 | 88 | { |
| 89 | 89 | try { |
| 90 | - $schemaFile = $this->validateDir . '/' . $jsonSchema->params; |
|
| 90 | + $schemaFile = $this->validateDir.'/'.$jsonSchema->params; |
|
| 91 | 91 | $this->validateFileExists($schemaFile); |
| 92 | 92 | $this->validate($arguments, $schemaFile); |
| 93 | 93 | } catch (JsonSchemaException $e) { |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | return $json; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if (! property_exists($json, $jsonSchema->key)) { |
|
| 130 | + if (!property_exists($json, $jsonSchema->key)) { |
|
| 131 | 131 | throw new JsonSchemaKeytNotFoundException($jsonSchema->key); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** @param array<mixed>|stdClass $target */ |
| 138 | - private function validate(array|stdClass $target, string $schemaFile): void |
|
| 138 | + private function validate(array | stdClass $target, string $schemaFile): void |
|
| 139 | 139 | { |
| 140 | 140 | $validator = new Validator(); |
| 141 | - $schema = (object) ['$ref' => 'file://' . $schemaFile]; |
|
| 141 | + $schema = (object) ['$ref' => 'file://'.$schemaFile]; |
|
| 142 | 142 | $scanArray = is_array($target) ? $target : $this->deepArray($target); |
| 143 | 143 | $validator->validate($scanArray, $schema, Constraint::CHECK_MODE_TYPE_CAST); |
| 144 | 144 | $isValid = $validator->isValid(); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | private function getSchemaFile(JsonSchema $jsonSchema, ResourceObject $ro): string |
| 181 | 181 | { |
| 182 | - if (! $jsonSchema->schema) { |
|
| 182 | + if (!$jsonSchema->schema) { |
|
| 183 | 183 | // for BC only |
| 184 | 184 | new ReflectionClass($ro); |
| 185 | 185 | $roFileName = $this->getParentClassName($ro); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - $schemaFile = $this->schemaDir . '/' . $jsonSchema->schema; |
|
| 192 | + $schemaFile = $this->schemaDir.'/'.$jsonSchema->schema; |
|
| 193 | 193 | $this->validateFileExists($schemaFile); |
| 194 | 194 | |
| 195 | 195 | return $schemaFile; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | private function validateFileExists(string $schemaFile): void |
| 206 | 206 | { |
| 207 | - if (! file_exists($schemaFile) || is_dir($schemaFile)) { |
|
| 207 | + if (!file_exists($schemaFile) || is_dir($schemaFile)) { |
|
| 208 | 208 | throw new JsonSchemaNotFoundException($schemaFile); |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -52,20 +52,20 @@ discard block |
||
| 52 | 52 | /** @return OptionsMethodsResponse */ |
| 53 | 53 | public function __invoke(ResourceObject $ro, string $requestMethod): array |
| 54 | 54 | { |
| 55 | - $method = new ReflectionMethod($ro::class, 'on' . $requestMethod); |
|
| 55 | + $method = new ReflectionMethod($ro::class, 'on'.$requestMethod); |
|
| 56 | 56 | $ins = $this->getInMap($method); |
| 57 | 57 | [$doc, $paramDoc] = (new OptionsMethodDocBolck())($method); |
| 58 | 58 | $methodOption = $doc; |
| 59 | 59 | $paramMetas = (new OptionsMethodRequest())($method, $paramDoc, $ins); |
| 60 | 60 | $schema = $this->getJsonSchema($method); |
| 61 | - $request = ! empty($paramMetas) ? ['request' => $paramMetas] : []; |
|
| 61 | + $request = !empty($paramMetas) ? ['request' => $paramMetas] : []; |
|
| 62 | 62 | $methodOption += $request; |
| 63 | - if (! empty($schema)) { |
|
| 63 | + if (!empty($schema)) { |
|
| 64 | 64 | $methodOption += ['schema' => $schema]; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $extras = $this->getMethodExtras($method); |
| 68 | - if (! empty($extras)) { |
|
| 68 | + if (!empty($extras)) { |
|
| 69 | 69 | $methodOption += $extras; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $extras['links'][] = $annotation; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if (! ($annotation instanceof Embed)) { |
|
| 89 | + if (!($annotation instanceof Embed)) { |
|
| 90 | 90 | continue; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | private function getJsonSchema(ReflectionMethod $method): array |
| 109 | 109 | { |
| 110 | 110 | $schema = $method->getAnnotation(JsonSchema::class); |
| 111 | - if (! $schema instanceof JsonSchema) { |
|
| 111 | + if (!$schema instanceof JsonSchema) { |
|
| 112 | 112 | return []; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $schemaFile = $this->schemaDir . '/' . $schema->schema; |
|
| 116 | - if (! file_exists($schemaFile)) { |
|
| 115 | + $schemaFile = $this->schemaDir.'/'.$schema->schema; |
|
| 116 | + if (!file_exists($schemaFile)) { |
|
| 117 | 117 | return []; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $attributes = $parameter->getAttributes(); |
| 135 | 135 | foreach ($attributes as $attribute) { |
| 136 | 136 | $instance = $attribute->newInstance(); |
| 137 | - if (! ($instance instanceof AbstractWebContextParam)) { |
|
| 137 | + if (!($instance instanceof AbstractWebContextParam)) { |
|
| 138 | 138 | continue; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** @psalm-return DefaultParam<mixed>|NoDefaultParam */ |
| 132 | - private function getDefault(ReflectionParameter $parameter): DefaultParam|NoDefaultParam |
|
| 132 | + private function getDefault(ReflectionParameter $parameter): DefaultParam | NoDefaultParam |
|
| 133 | 133 | { |
| 134 | 134 | return $parameter->isDefaultValueAvailable() === true ? new DefaultParam($parameter->getDefaultValue()) : new NoDefaultParam(); |
| 135 | 135 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | private function getParam(ReflectionParameter $parameter): ParamInterface |
| 157 | 157 | { |
| 158 | 158 | $type = $parameter->getType(); |
| 159 | - if ($type instanceof ReflectionNamedType && ! $type->isBuiltin()) { |
|
| 159 | + if ($type instanceof ReflectionNamedType && !$type->isBuiltin()) { |
|
| 160 | 160 | return new ClassParam($type, $parameter); |
| 161 | 161 | } |
| 162 | 162 | |