@@ -24,15 +24,15 @@ |
||
24 | 24 | #[Override] |
25 | 25 | public function render(ResourceObject $ro) |
26 | 26 | { |
27 | - if (! array_key_exists('Content-Type', $ro->headers)) { |
|
27 | + if (!array_key_exists('Content-Type', $ro->headers)) { |
|
28 | 28 | $ro->headers['Content-Type'] = 'application/json'; |
29 | 29 | } |
30 | 30 | |
31 | - $ro->view = (string) json_encode($ro, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL; |
|
31 | + $ro->view = (string) json_encode($ro, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL; |
|
32 | 32 | $e = json_last_error(); |
33 | 33 | if ($e) { |
34 | 34 | // @codeCoverageIgnoreStart |
35 | - error_log('json_encode error: ' . json_last_error_msg() . ' in ' . __METHOD__); |
|
35 | + error_log('json_encode error: '.json_last_error_msg().' in '.__METHOD__); |
|
36 | 36 | |
37 | 37 | return ''; |
38 | 38 |
@@ -39,13 +39,13 @@ |
||
39 | 39 | * @param RequestQuery $query |
40 | 40 | */ |
41 | 41 | #[Override] |
42 | - public function __invoke(string $varName, array $query, InjectorInterface $injector): AbstractFileUpload|null |
|
42 | + public function __invoke(string $varName, array $query, InjectorInterface $injector): AbstractFileUpload | null |
|
43 | 43 | { |
44 | 44 | // When user sets the FileUpload object, return it directly |
45 | 45 | if (array_key_exists($varName, $query)) { |
46 | 46 | $value = $query[$varName]; |
47 | 47 | // Type check: ensure the value is a valid file upload object or null |
48 | - if ($value !== null && ! ($value instanceof FileUpload) && ! ($value instanceof ErrorFileUpload)) { |
|
48 | + if ($value !== null && !($value instanceof FileUpload) && !($value instanceof ErrorFileUpload)) { |
|
49 | 49 | throw new InvalidArgumentException($varName); |
50 | 50 | } |
51 | 51 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | #[Override] |
46 | 46 | public function toAdapter(AdapterInterface $adapter): SchemeCollectionInterface |
47 | 47 | { |
48 | - $this->collection[$this->scheme . '://' . $this->appName] = $adapter; |
|
48 | + $this->collection[$this->scheme.'://'.$this->appName] = $adapter; |
|
49 | 49 | |
50 | 50 | return $this; |
51 | 51 | } |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | #[Override] |
59 | 59 | public function getAdapter(AbstractUri $uri): AdapterInterface |
60 | 60 | { |
61 | - $schemeIndex = $uri->scheme . '://' . $uri->host; |
|
62 | - if (! array_key_exists($schemeIndex, $this->collection)) { |
|
61 | + $schemeIndex = $uri->scheme.'://'.$uri->host; |
|
62 | + if (!array_key_exists($schemeIndex, $this->collection)) { |
|
63 | 63 | if ($uri->scheme === 'http' || $uri->scheme === 'https') { |
64 | 64 | return $this->collection['http://self']; |
65 | 65 | } |
66 | 66 | |
67 | - throw new SchemeException($uri->scheme . '://' . $uri->host); |
|
67 | + throw new SchemeException($uri->scheme.'://'.$uri->host); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return $this->collection[$schemeIndex]; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** @throws ResourceDirException */ |
40 | 40 | public function __construct(string $resourceDir) |
41 | 41 | { |
42 | - if (! file_exists($resourceDir)) { |
|
42 | + if (!file_exists($resourceDir)) { |
|
43 | 43 | throw new ResourceDirException($resourceDir); |
44 | 44 | } |
45 | 45 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | $resourceClass = $this->getResourceClassName($item); |
113 | - if ($resourceClass === '' || ! class_exists($resourceClass)) { |
|
113 | + if ($resourceClass === '' || !class_exists($resourceClass)) { |
|
114 | 114 | continue; |
115 | 115 | } |
116 | 116 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | { |
126 | 126 | $isPhp = $item->isFile() |
127 | 127 | && $item->getExtension() === 'php' |
128 | - && (! str_contains($item->getBasename('.php'), '.')); |
|
128 | + && (!str_contains($item->getBasename('.php'), '.')); |
|
129 | 129 | |
130 | - return ! $isPhp; |
|
130 | + return !$isPhp; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** @return ResourceClassName|'' */ |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function addHalLink(array $body, array $methodAnnotations, Hal $hal): Hal |
35 | 35 | { |
36 | - if (! empty($methodAnnotations)) { |
|
36 | + if (!empty($methodAnnotations)) { |
|
37 | 37 | $hal = $this->linkAnnotation($body, $methodAnnotations, $hal); |
38 | 38 | } |
39 | 39 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | private function linkAnnotation(array $body, array $methodAnnotations, Hal $hal): Hal |
53 | 53 | { |
54 | 54 | foreach ($methodAnnotations as $annotation) { |
55 | - if (! $annotation instanceof Link) { |
|
55 | + if (!$annotation instanceof Link) { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | 58 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | private function bodyLink(array $body, Hal $hal): Hal |
79 | 79 | { |
80 | 80 | foreach ($body['_links'] as $rel => $link) { |
81 | - if (! is_string($rel) || ! isset($link['href'])) { |
|
81 | + if (!is_string($rel) || !isset($link['href'])) { |
|
82 | 82 | // @codeCoverageIgnoreStart |
83 | 83 | continue; |
84 | 84 | // @codeCoverageIgnoreEnd |
@@ -21,7 +21,7 @@ |
||
21 | 21 | public function __invoke(ResourceObject $ro): void |
22 | 22 | { |
23 | 23 | $unsafeMethod = ['post', 'put', 'patch', 'delete']; |
24 | - if (! in_array($ro->uri->method, $unsafeMethod, true)) { |
|
24 | + if (!in_array($ro->uri->method, $unsafeMethod, true)) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | array_shift($classPath); // "/Resource/" |
51 | 51 | $scheme = array_shift($classPath); |
52 | 52 | |
53 | - return strtolower("{$scheme}://self/" . implode('/', $classPath)); |
|
53 | + return strtolower("{$scheme}://self/".implode('/', $classPath)); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function getOptions(string $class): Options |
62 | 62 | { |
63 | - if (! class_exists($class)) { |
|
63 | + if (!class_exists($class)) { |
|
64 | 64 | throw new LogicException(); // @codeCoverageIgnore |
65 | 65 | } |
66 | 66 | |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | { |
85 | 85 | $allows = []; |
86 | 86 | foreach ($methods as $method) { |
87 | - $isRequestMethod = str_starts_with($method->name, 'on') && ! str_starts_with($method->name, 'onLink'); |
|
88 | - if (! $isRequestMethod) { |
|
87 | + $isRequestMethod = str_starts_with($method->name, 'on') && !str_starts_with($method->name, 'onLink'); |
|
88 | + if (!$isRequestMethod) { |
|
89 | 89 | continue; |
90 | 90 | } |
91 | 91 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** @param ResourceClassName $class */ |
99 | 99 | private function getParams(string $class, string $method): Params |
100 | 100 | { |
101 | - $refMethod = new ReflectionMethod($class, 'on' . $method); |
|
101 | + $refMethod = new ReflectionMethod($class, 'on'.$method); |
|
102 | 102 | $parameters = $refMethod->getParameters(); |
103 | 103 | $optionalParams = $requiredParams = []; |
104 | 104 | foreach ($parameters as $parameter) { |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | { |
12 | 12 | /** @param Query $query */ |
13 | 13 | #[Override] |
14 | - public function __invoke(array|null $query = null): ResourceObject |
|
14 | + public function __invoke(array | null $query = null): ResourceObject |
|
15 | 15 | { |
16 | 16 | return new NullResourceObject(); |
17 | 17 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | #[Override] |
60 | 60 | public function toUriWithMethod(): string |
61 | 61 | { |
62 | - return 'get ' . (string) new NullUri(); |
|
62 | + return 'get '.(string) new NullUri(); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** @return self */ |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | public function renderHal(ResourceObject $ro): void |
54 | 54 | { |
55 | 55 | [$ro, $body] = $this->valuate($ro); |
56 | - $method = 'on' . ucfirst($ro->uri->method); |
|
56 | + $method = 'on'.ucfirst($ro->uri->method); |
|
57 | 57 | $hasMethod = method_exists($ro, $method); |
58 | 58 | $annotations = $hasMethod ? (new ReflectionMethod($ro, $method))->getAnnotations() : []; |
59 | 59 | $hal = $this->getHal($ro->uri, $body, $annotations); |
60 | 60 | $json = $hal->asJson(true); |
61 | 61 | assert(is_string($json)); |
62 | - $ro->view = $json . PHP_EOL; |
|
62 | + $ro->view = $json.PHP_EOL; |
|
63 | 63 | $ro->headers['Content-Type'] = 'application/hal+json'; |
64 | 64 | } |
65 | 65 | |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | assert(is_array($ro->body)); |
69 | 69 | /** @var mixed $embeded */ |
70 | 70 | foreach ($ro->body as $key => &$embeded) { |
71 | - if (! ($embeded instanceof AbstractRequest)) { |
|
71 | + if (!($embeded instanceof AbstractRequest)) { |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | - $isNotArray = ! isset($ro->body['_embedded']) || ! is_array($ro->body['_embedded']); |
|
75 | + $isNotArray = !isset($ro->body['_embedded']) || !is_array($ro->body['_embedded']); |
|
76 | 76 | if ($isNotArray) { |
77 | 77 | $ro->body['_embedded'] = []; |
78 | 78 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | /** @codeCoverageIgnore */ |
97 | 97 | private function isDifferentSchema(ResourceObject $parentRo, ResourceObject $childRo): bool |
98 | 98 | { |
99 | - return $parentRo->uri->scheme . $parentRo->uri->host !== $childRo->uri->scheme . $childRo->uri->host; |
|
99 | + return $parentRo->uri->scheme.$parentRo->uri->host !== $childRo->uri->scheme.$childRo->uri->host; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | */ |
107 | 107 | private function getHal(AbstractUri $uri, array $body, array $annotations): Hal |
108 | 108 | { |
109 | - $query = $uri->query ? '?' . http_build_query($uri->query) : ''; |
|
110 | - $path = $uri->path . $query; |
|
109 | + $query = $uri->query ? '?'.http_build_query($uri->query) : ''; |
|
110 | + $path = $uri->path.$query; |
|
111 | 111 | $selfLink = $this->linker->getReverseLink($path, $uri->query); |
112 | 112 | $hal = new Hal($selfLink, $body); |
113 | 113 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | private function updateHeaders(ResourceObject $ro): void |
140 | 140 | { |
141 | 141 | $ro->headers['Content-Type'] = 'application/hal+json'; |
142 | - if (! isset($ro->headers['Location'])) { |
|
142 | + if (!isset($ro->headers['Location'])) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | 145 |