@@ -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 | |
@@ -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 */ |
@@ -33,6 +33,6 @@ |
||
| 33 | 33 | return $ro; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - throw new MethodNotAllowedException($request->resourceObject::class . "::{({$request->method}}()", 405); |
|
| 36 | + throw new MethodNotAllowedException($request->resourceObject::class."::{({$request->method}}()", 405); |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -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 |
| 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 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $scheme = array_shift($classPath); |
| 59 | 59 | assert(is_string($scheme)); |
| 60 | 60 | |
| 61 | - return strtolower("{$scheme}://self/" . implode('/', $classPath)); |
|
| 61 | + return strtolower("{$scheme}://self/".implode('/', $classPath)); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | private function getOptions(string $class): Options |
| 70 | 70 | { |
| 71 | - if (! class_exists($class)) { |
|
| 71 | + if (!class_exists($class)) { |
|
| 72 | 72 | throw new LogicException(); // @codeCoverageIgnore |
| 73 | 73 | } |
| 74 | 74 | |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | $allows = []; |
| 94 | 94 | foreach ($methods as $method) { |
| 95 | - $isRequestMethod = str_starts_with($method->name, 'on') && ! str_starts_with($method->name, 'onLink'); |
|
| 96 | - if (! $isRequestMethod) { |
|
| 95 | + $isRequestMethod = str_starts_with($method->name, 'on') && !str_starts_with($method->name, 'onLink'); |
|
| 96 | + if (!$isRequestMethod) { |
|
| 97 | 97 | continue; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | /** @param ResourceClassName $class */ |
| 107 | 107 | private function getParams(string $class, string $method): Params |
| 108 | 108 | { |
| 109 | - $refMethod = new ReflectionMethod($class, 'on' . $method); |
|
| 109 | + $refMethod = new ReflectionMethod($class, 'on'.$method); |
|
| 110 | 110 | $parameters = $refMethod->getParameters(); |
| 111 | 111 | $optionalParams = $requiredParams = []; |
| 112 | 112 | foreach ($parameters as $parameter) { |
@@ -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 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $method = new ReflectionMethod($callable[0], $callable[1]); // @phpstan-ignore-line |
| 40 | 40 | $paramMetas = $this->getAttributeParamMetas($method); |
| 41 | 41 | |
| 42 | - if (! $paramMetas) { |
|
| 42 | + if (!$paramMetas) { |
|
| 43 | 43 | $paramMetas = $this->getAnnotationParamMetas($method); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $names[$annotation->param] = new AssistedResourceParam($annotation); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if (! ($annotation instanceof Assisted)) { |
|
| 124 | + if (!($annotation instanceof Assisted)) { |
|
| 125 | 125 | continue; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | { |
| 143 | 143 | $webcontext = []; |
| 144 | 144 | foreach ($annotations as $annotation) { |
| 145 | - if (! ($annotation instanceof AbstractWebContextParam)) { |
|
| 145 | + if (!($annotation instanceof AbstractWebContextParam)) { |
|
| 146 | 146 | continue; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** @psalm-return DefaultParam<mixed>|NoDefaultParam */ |
| 221 | - private function getDefault(ReflectionParameter $parameter): DefaultParam|NoDefaultParam |
|
| 221 | + private function getDefault(ReflectionParameter $parameter): DefaultParam | NoDefaultParam |
|
| 222 | 222 | { |
| 223 | 223 | return $parameter->isDefaultValueAvailable() === true ? new DefaultParam($parameter->getDefaultValue()) : new NoDefaultParam(); |
| 224 | 224 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | private function getParam(ReflectionParameter $parameter): ParamInterface |
| 249 | 249 | { |
| 250 | 250 | $type = $parameter->getType(); |
| 251 | - if ($type instanceof ReflectionNamedType && ! $type->isBuiltin()) { |
|
| 251 | + if ($type instanceof ReflectionNamedType && !$type->isBuiltin()) { |
|
| 252 | 252 | return new ClassParam($type, $parameter); |
| 253 | 253 | } |
| 254 | 254 | |