@@ -66,7 +66,7 @@ |
||
66 | 66 | $crc = crc32($this->exceptionAsString); |
67 | 67 | $crcHex = dechex($crc & 0xFFFFFFFF); // Ensure positive hex value |
68 | 68 | |
69 | - return 'e-bear-resource-' . $crcHex; |
|
69 | + return 'e-bear-resource-'.$crcHex; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** @return array<string, mixed> */ |
@@ -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 | $hasType = method_exists($parameter, 'getType') && $parameter->getType(); |
44 | 44 | if ($hasType) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $paramDoc[$name]['in'] = $ins[$parameter->name]; |
64 | 64 | } |
65 | 65 | |
66 | - if (! isset($paramDoc[$parameter->name])) { |
|
66 | + if (!isset($paramDoc[$parameter->name])) { |
|
67 | 67 | $paramDoc[$name] = []; |
68 | 68 | } |
69 | 69 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | #[Override] |
30 | 30 | public function href(string $rel, AbstractRequest $request, array $query): array |
31 | 31 | { |
32 | - $classMethod = 'on' . ucfirst($request->method); |
|
32 | + $classMethod = 'on'.ucfirst($request->method); |
|
33 | 33 | $annotations = (new ReflectionMethod($request->resourceObject::class, $classMethod))->getAnnotations(); |
34 | 34 | foreach ($annotations as $annotation) { |
35 | 35 | if ($this->isValidLinkAnnotation($annotation, $rel)) { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | - throw new LinkException("rel:{$rel} class:" . $request->resourceObject::class, 500); |
|
42 | + throw new LinkException("rel:{$rel} class:".$request->resourceObject::class, 500); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | private function isValidLinkAnnotation(object $annotation, string $rel): bool |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $ro->headers['Content-Type'] = 'application/json'; |
47 | 47 | $allows = $this->getAllows((new ReflectionClass($ro))->getMethods()); |
48 | 48 | $ro->headers['Allow'] = implode(', ', $allows); |
49 | - $ro->view = $this->optionsBody ? (string) json_encode($this->getEntityBody($ro, $allows), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL : ''; |
|
49 | + $ro->view = $this->optionsBody ? (string) json_encode($this->getEntityBody($ro, $allows), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL : ''; |
|
50 | 50 | |
51 | 51 | return $ro->view; |
52 | 52 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | { |
64 | 64 | $allows = []; |
65 | 65 | foreach ($methods as $method) { |
66 | - if (! in_array($method->name, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
66 | + if (!in_array($method->name, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
67 | 67 | continue; |
68 | 68 | } |
69 | 69 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $method = new ReflectionMethod($callable[0], $callable[1]); |
38 | 38 | $paramMetas = $this->getAttributeParamMetas($method); |
39 | 39 | |
40 | - if (! $paramMetas) { |
|
40 | + if (!$paramMetas) { |
|
41 | 41 | $paramMetas = $this->getAnnotationParamMetas($method); |
42 | 42 | } |
43 | 43 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $names[$annotation->param] = new AssistedResourceParam($annotation); |
120 | 120 | } |
121 | 121 | |
122 | - if (! ($annotation instanceof Assisted)) { |
|
122 | + if (!($annotation instanceof Assisted)) { |
|
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | $webcontext = []; |
142 | 142 | foreach ($annotations as $annotation) { |
143 | - if (! ($annotation instanceof AbstractWebContextParam)) { |
|
143 | + if (!($annotation instanceof AbstractWebContextParam)) { |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | /** @psalm-return DefaultParam<mixed>|NoDefaultParam */ |
219 | - private function getDefault(ReflectionParameter $parameter): DefaultParam|NoDefaultParam |
|
219 | + private function getDefault(ReflectionParameter $parameter): DefaultParam | NoDefaultParam |
|
220 | 220 | { |
221 | 221 | return $parameter->isDefaultValueAvailable() === true ? new DefaultParam($parameter->getDefaultValue()) : new NoDefaultParam(); |
222 | 222 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | private function getParam(ReflectionParameter $parameter): ParamInterface |
247 | 247 | { |
248 | 248 | $type = $parameter->getType(); |
249 | - if ($type instanceof ReflectionNamedType && ! $type->isBuiltin()) { |
|
249 | + if ($type instanceof ReflectionNamedType && !$type->isBuiltin()) { |
|
250 | 250 | return new ClassParam($type, $parameter); |
251 | 251 | } |
252 | 252 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | public function __construct( |
25 | 25 | private readonly string $jsonSchemaDir = '', |
26 | 26 | private readonly string $jsonValidateDir = '', |
27 | - AbstractModule|null $module = null, |
|
27 | + AbstractModule | null $module = null, |
|
28 | 28 | ) { |
29 | 29 | parent::__construct($module); |
30 | 30 | } |
@@ -17,9 +17,9 @@ |
||
17 | 17 | /** @param string $jsonSchemaHost Json-schema host name ex) https://example.com/schema/ */ |
18 | 18 | public function __construct( |
19 | 19 | private readonly string $jsonSchemaHost, |
20 | - AbstractModule|null $module = null, |
|
20 | + AbstractModule | null $module = null, |
|
21 | 21 | ) { |
22 | - if (! filter_var($jsonSchemaHost, FILTER_VALIDATE_URL)) { |
|
22 | + if (!filter_var($jsonSchemaHost, FILTER_VALIDATE_URL)) { |
|
23 | 23 | throw new InvalidSchemaUriException($jsonSchemaHost); |
24 | 24 | } |
25 | 25 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | private readonly JsonSchemaExceptionHandlerInterface $handler, |
45 | 45 | private readonly JsonSchemaRequestExceptionHandlerInterface $requestHandler, |
46 | 46 | #[Named('json_schema_host')] |
47 | - private readonly string|null $schemaHost = null, |
|
47 | + private readonly string | null $schemaHost = null, |
|
48 | 48 | ) { |
49 | 49 | } |
50 | 50 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | private function validateRequest(MethodInvocation $invocation, JsonSchema $jsonSchema, array $arguments): void // @phpstan-ignore-line |
76 | 76 | { |
77 | 77 | try { |
78 | - $schemaFile = $this->validateDir . '/' . $jsonSchema->params; |
|
78 | + $schemaFile = $this->validateDir.'/'.$jsonSchema->params; |
|
79 | 79 | $this->validateFileExists($schemaFile); |
80 | 80 | $this->validate($arguments, $schemaFile); |
81 | 81 | } catch (JsonSchemaException $e) { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return $json; |
116 | 116 | } |
117 | 117 | |
118 | - if (! property_exists($json, $jsonSchema->key)) { |
|
118 | + if (!property_exists($json, $jsonSchema->key)) { |
|
119 | 119 | throw new JsonSchemaKeytNotFoundException($jsonSchema->key); |
120 | 120 | } |
121 | 121 | |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | /** @param array<mixed>|stdClass $target */ |
126 | - private function validate(array|stdClass $target, string $schemaFile): void |
|
126 | + private function validate(array | stdClass $target, string $schemaFile): void |
|
127 | 127 | { |
128 | 128 | $validator = new Validator(); |
129 | - $schema = (object) ['$ref' => 'file://' . $schemaFile]; |
|
129 | + $schema = (object) ['$ref' => 'file://'.$schemaFile]; |
|
130 | 130 | $scanArray = is_array($target) ? $target : $this->deepArray($target); |
131 | 131 | $validator->validate($scanArray, $schema, Constraint::CHECK_MODE_TYPE_CAST); |
132 | 132 | $isValid = $validator->isValid(); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | private function getSchemaFile(JsonSchema $jsonSchema, ResourceObject $ro): string |
168 | 168 | { |
169 | - if (! $jsonSchema->schema) { |
|
169 | + if (!$jsonSchema->schema) { |
|
170 | 170 | // for BC only |
171 | 171 | new ReflectionClass($ro); |
172 | 172 | $roFileName = $this->getParentClassName($ro); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - $schemaFile = $this->schemaDir . '/' . $jsonSchema->schema; |
|
179 | + $schemaFile = $this->schemaDir.'/'.$jsonSchema->schema; |
|
180 | 180 | $this->validateFileExists($schemaFile); |
181 | 181 | |
182 | 182 | return $schemaFile; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | private function validateFileExists(string $schemaFile): void |
193 | 193 | { |
194 | - if (! file_exists($schemaFile) || is_dir($schemaFile)) { |
|
194 | + if (!file_exists($schemaFile) || is_dir($schemaFile)) { |
|
195 | 195 | throw new JsonSchemaNotFoundException($schemaFile); |
196 | 196 | } |
197 | 197 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** @return array<int|string, mixed> */ |
35 | 35 | private function fakeResponse(string $schemaFile): array |
36 | 36 | { |
37 | - if (! class_exists(Faker::class)) { |
|
37 | + if (!class_exists(Faker::class)) { |
|
38 | 38 | 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 |
39 | 39 | } |
40 | 40 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return array<int|string, mixed> |
51 | 51 | */ |
52 | - private function deepArray(array|stdClass $values): array |
|
52 | + private function deepArray(array | stdClass $values): array |
|
53 | 53 | { |
54 | 54 | $result = []; |
55 | 55 | /** @psalm-suppress MixedAssignment */ |