@@ -53,20 +53,20 @@ discard block |
||
| 53 | 53 | /** @return OptionsMethodsResponse */ |
| 54 | 54 | public function __invoke(ResourceObject $ro, string $requestMethod): array |
| 55 | 55 | { |
| 56 | - $method = new ReflectionMethod($ro::class, 'on' . $requestMethod); |
|
| 56 | + $method = new ReflectionMethod($ro::class, 'on'.$requestMethod); |
|
| 57 | 57 | $ins = $this->getInMap($method); |
| 58 | 58 | [$doc, $paramDoc] = (new OptionsMethodDocBolck())($method); |
| 59 | 59 | $methodOption = $doc; |
| 60 | 60 | $paramMetas = (new OptionsMethodRequest())($method, $paramDoc, $ins); |
| 61 | 61 | $schema = $this->getJsonSchema($method); |
| 62 | - $request = ! empty($paramMetas) ? ['request' => $paramMetas] : []; |
|
| 62 | + $request = !empty($paramMetas) ? ['request' => $paramMetas] : []; |
|
| 63 | 63 | $methodOption += $request; |
| 64 | - if (! empty($schema)) { |
|
| 64 | + if (!empty($schema)) { |
|
| 65 | 65 | $methodOption += ['schema' => $schema]; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $extras = $this->getMethodExtras($method); |
| 69 | - if (! empty($extras)) { |
|
| 69 | + if (!empty($extras)) { |
|
| 70 | 70 | $methodOption += $extras; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $extras['links'][] = $annotation; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if (! ($annotation instanceof Embed)) { |
|
| 90 | + if (!($annotation instanceof Embed)) { |
|
| 91 | 91 | continue; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | private function getJsonSchema(ReflectionMethod $method): array |
| 119 | 119 | { |
| 120 | 120 | $schema = $method->getAnnotation(JsonSchema::class); |
| 121 | - if (! $schema instanceof JsonSchema) { |
|
| 121 | + if (!$schema instanceof JsonSchema) { |
|
| 122 | 122 | return []; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $schemaFile = $this->schemaDir . '/' . $schema->schema; |
|
| 126 | - if (! file_exists($schemaFile)) { |
|
| 125 | + $schemaFile = $this->schemaDir.'/'.$schema->schema; |
|
| 126 | + if (!file_exists($schemaFile)) { |
|
| 127 | 127 | return []; |
| 128 | 128 | } |
| 129 | 129 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | public function getInsFromMethodAnnotations(array $annotations, array $ins): array |
| 142 | 142 | { |
| 143 | 143 | foreach ($annotations as $annotation) { |
| 144 | - if (! ($annotation instanceof AbstractWebContextParam)) { |
|
| 144 | + if (!($annotation instanceof AbstractWebContextParam)) { |
|
| 145 | 145 | continue; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $attributes = $parameter->getAttributes(); |
| 170 | 170 | foreach ($attributes as $attribute) { |
| 171 | 171 | $instance = $attribute->newInstance(); |
| 172 | - if (! ($instance instanceof AbstractWebContextParam)) { |
|
| 172 | + if (!($instance instanceof AbstractWebContextParam)) { |
|
| 173 | 173 | continue; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | #[\Override] |
| 26 | 26 | public function invoke(AbstractRequest $request): ResourceObject |
| 27 | 27 | { |
| 28 | - $callable = [$request->resourceObject, 'on' . ucfirst($request->method)]; |
|
| 29 | - if (! is_callable($callable)) { |
|
| 28 | + $callable = [$request->resourceObject, 'on'.ucfirst($request->method)]; |
|
| 29 | + if (!is_callable($callable)) { |
|
| 30 | 30 | // OPTIONS or HEAD |
| 31 | 31 | return ($this->extraMethod)($request, $this); |
| 32 | 32 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | throw $e; |
| 43 | 43 | } |
| 44 | - if (! $response instanceof ResourceObject) { |
|
| 44 | + if (!$response instanceof ResourceObject) { |
|
| 45 | 45 | $request->resourceObject->body = $response; |
| 46 | 46 | $response = $request->resourceObject; |
| 47 | 47 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @param Query $query |
| 18 | 18 | */ |
| 19 | - public function __invoke(array|null $query = null): ResourceObject; |
|
| 19 | + public function __invoke(array | null $query = null): ResourceObject; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Set query |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | $type = $tagType === 'int' ? 'integer' : $tagType; |
| 70 | 70 | $params[$varName] = ['type' => $type]; |
| 71 | 71 | $description = (string) $tag->getDescription(); |
| 72 | - if (! $description) { |
|
| 72 | + if (!$description) { |
|
| 73 | 73 | continue; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | public function __invoke(string $uri, array $query = []): Uri |
| 23 | 23 | { |
| 24 | 24 | $parsedUrl = (array) parse_url($uri); |
| 25 | - if (! array_key_exists('scheme', $parsedUrl)) { |
|
| 26 | - $uri = $this->schemaHost . $uri; |
|
| 25 | + if (!array_key_exists('scheme', $parsedUrl)) { |
|
| 26 | + $uri = $this->schemaHost.$uri; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | return new Uri($uri, $query); |
@@ -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 | |
@@ -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 | |