@@ -41,7 +41,7 @@ |
||
41 | 41 | { |
42 | 42 | $request = new RouterMatch; |
43 | 43 | list($request->method, $request->query) = $this->httpMethodParams->get($server, $globals['_GET'], $globals['_POST']); |
44 | - $request->path = $this->schemeHost . parse_url($server['REQUEST_URI'], PHP_URL_PATH); |
|
44 | + $request->path = $this->schemeHost.parse_url($server['REQUEST_URI'], PHP_URL_PATH); |
|
45 | 45 | |
46 | 46 | return $request; |
47 | 47 | } |
@@ -24,6 +24,6 @@ |
||
24 | 24 | { |
25 | 25 | $string = parent::__toString(); |
26 | 26 | |
27 | - return $string . $this->postBody; |
|
27 | + return $string.$this->postBody; |
|
28 | 28 | } |
29 | 29 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | $this->rename(RouterInterface::class, 'original'); |
24 | 24 | $this->bind(RouterInterface::class)->to(CliRouter::class); |
25 | 25 | $this->bind(TransferInterface::class)->to(CliResponder::class); |
26 | - $stdIn = tempnam(sys_get_temp_dir(), 'stdin-' . crc32(__FILE__)); |
|
26 | + $stdIn = tempnam(sys_get_temp_dir(), 'stdin-'.crc32(__FILE__)); |
|
27 | 27 | $this->bind()->annotatedWith(StdIn::class)->toInstance($stdIn); |
28 | 28 | } |
29 | 29 | } |
@@ -18,15 +18,15 @@ |
||
18 | 18 | public function __invoke(ResourceObject $resourceObject, array $server) |
19 | 19 | { |
20 | 20 | unset($server); |
21 | - if (! $resourceObject->view) { |
|
21 | + if (!$resourceObject->view) { |
|
22 | 22 | $resourceObject->toString(); |
23 | 23 | } |
24 | 24 | // code |
25 | 25 | $statusText = (new Code)->statusText[$resourceObject->code]; |
26 | - $ob = $resourceObject->code . ' ' . $statusText . PHP_EOL; |
|
26 | + $ob = $resourceObject->code.' '.$statusText.PHP_EOL; |
|
27 | 27 | // header |
28 | 28 | foreach ($resourceObject->headers as $label => $value) { |
29 | - $ob .= "{$label}: {$value}" . PHP_EOL; |
|
29 | + $ob .= "{$label}: {$value}".PHP_EOL; |
|
30 | 30 | } |
31 | 31 | // empty line |
32 | 32 | $ob .= PHP_EOL; |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function toString() |
23 | 23 | { |
24 | - $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL; |
|
24 | + $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | private function getHeader() : array |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function toString() |
23 | 23 | { |
24 | - $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL; |
|
24 | + $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | private function getHeader($code) : array |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | public function addHalLink(array $body, array $methodAnnotations, Hal $hal) : Hal |
42 | 42 | { |
43 | - if (! empty($methodAnnotations)) { |
|
43 | + if (!empty($methodAnnotations)) { |
|
44 | 44 | $hal = $this->linkAnnotation($body, $methodAnnotations, $hal); |
45 | 45 | } |
46 | 46 | if (isset($body['_links'])) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | private function linkAnnotation(array $body, array $methodAnnotations, Hal $hal) : Hal |
54 | 54 | { |
55 | 55 | foreach ($methodAnnotations as $annotation) { |
56 | - if (! $annotation instanceof Link) { |
|
56 | + if (!$annotation instanceof Link) { |
|
57 | 57 | continue; |
58 | 58 | } |
59 | 59 | $uri = uri_template($annotation->href, $body); |
@@ -22,6 +22,9 @@ |
||
22 | 22 | $this->router = $router; |
23 | 23 | } |
24 | 24 | |
25 | + /** |
|
26 | + * @param string $uri |
|
27 | + */ |
|
25 | 28 | public function getReverseLink($uri) : string |
26 | 29 | { |
27 | 30 | $urlParts = parse_url($uri); |
@@ -30,7 +30,7 @@ |
||
30 | 30 | /** @var ResourceObject $ro */ |
31 | 31 | $ro = $invocation->proceed(); |
32 | 32 | $isCreated = $ro->code === 201 && isset($ro->headers['Location']); |
33 | - if (! $isCreated) { |
|
33 | + if (!$isCreated) { |
|
34 | 34 | return $ro; |
35 | 35 | } |
36 | 36 | $ro->setRenderer($this->renderer); |
@@ -59,6 +59,9 @@ |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | + /** |
|
63 | + * @param string $method |
|
64 | + */ |
|
62 | 65 | private function isMagicMethod($method) : bool |
63 | 66 | { |
64 | 67 | return \in_array($method, ['__sleep', '__wakeup', 'offsetGet', 'offsetSet', 'offsetExists', 'offsetUnset', 'count', 'ksort', 'asort', 'jsonSerialize'], true); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | foreach ($appMeta->getResourceListGenerator() as list($className)) { |
59 | 59 | $this->scanClass($injector, $reader, $namedParams, $className); |
60 | 60 | } |
61 | - $logFile = $appMeta->logDir . '/compile.log'; |
|
61 | + $logFile = $appMeta->logDir.'/compile.log'; |
|
62 | 62 | $this->saveCompileLog($appMeta, $context, $logFile); |
63 | 63 | |
64 | 64 | return $logFile; |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | |
67 | 67 | private function compileLoader(string $appName, string $context, string $appDir) : string |
68 | 68 | { |
69 | - $loader = $appDir . '/vendor/autoload.php'; |
|
70 | - if (! file_exists($loader)) { |
|
69 | + $loader = $appDir.'/vendor/autoload.php'; |
|
70 | + if (!file_exists($loader)) { |
|
71 | 71 | return ''; |
72 | 72 | } |
73 | 73 | $loader = require $loader; |
74 | 74 | spl_autoload_register( |
75 | - function ($class) use ($loader) { |
|
75 | + function($class) use ($loader) { |
|
76 | 76 | $loader->loadClass($class); |
77 | 77 | if ($class !== NullPage::class) { |
78 | 78 | $this->classes[] = $class; |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | ); |
84 | 84 | |
85 | 85 | $this->invokeTypicalReuqest($appName, $context); |
86 | - $fies = '<?php' . PHP_EOL; |
|
86 | + $fies = '<?php'.PHP_EOL; |
|
87 | 87 | foreach ($this->classes as $class) { |
88 | 88 | $fies .= sprintf( |
89 | 89 | "require %s';\n", |
90 | 90 | $this->getRelaticePath($appDir, (new \ReflectionClass($class))->getFileName()) |
91 | 91 | ); |
92 | 92 | } |
93 | - $fies .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL . PHP_EOL; |
|
94 | - $laoder = $appDir . '/autoload.php'; |
|
93 | + $fies .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL.PHP_EOL; |
|
94 | + $laoder = $appDir.'/autoload.php'; |
|
95 | 95 | file_put_contents($laoder, $fies); |
96 | 96 | |
97 | 97 | return $laoder; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return str_replace("{$rootDir}", "__DIR__ . '", $file); |
104 | 104 | } |
105 | 105 | |
106 | - return "'" . $file; |
|
106 | + return "'".$file; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | private function invokeTypicalReuqest(string $appName, string $context) |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | private function saveNamedParam(NamedParameterInterface $namedParameter, $instance, string $method) |
140 | 140 | { |
141 | 141 | // named parameter |
142 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
142 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | 145 | try { |