@@ -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 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | protected function configure() |
30 | 30 | { |
31 | 31 | $this->bind(AbstractAppMeta::class)->toInstance($this->appMeta); |
32 | - $this->bind(AppInterface::class)->to($this->appMeta->name . '\Module\App'); |
|
32 | + $this->bind(AppInterface::class)->to($this->appMeta->name.'\Module\App'); |
|
33 | 33 | $this->bind('')->annotatedWith(AppName::class)->toInstance($this->appMeta->name); |
34 | 34 | } |
35 | 35 | } |
@@ -27,6 +27,6 @@ |
||
27 | 27 | */ |
28 | 28 | public function get() |
29 | 29 | { |
30 | - return new FilesystemCache($this->app->tmpDir . '/cache'); |
|
30 | + return new FilesystemCache($this->app->tmpDir.'/cache'); |
|
31 | 31 | } |
32 | 32 | } |
@@ -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 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | private function getParams($method, array $server, array $post) |
111 | 111 | { |
112 | 112 | // post data exists |
113 | - if ($method === 'post' && ! empty($post)) { |
|
113 | + if ($method === 'post' && !empty($post)) { |
|
114 | 114 | return $post; |
115 | 115 | } |
116 | 116 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | private function phpInput(array $server) |
132 | 132 | { |
133 | 133 | $contentType = $this->getContentType($server); |
134 | - if (! $contentType) { |
|
134 | + if (!$contentType) { |
|
135 | 135 | return []; |
136 | 136 | } |
137 | 137 | $isFormUrlEncoded = strpos($contentType, self::FORM_URL_ENCODE) !== false; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function compile(AbstractModule $module, AbstractAppMeta $appMeta, $scriptDir) |
81 | 81 | { |
82 | - $hashFile = $appMeta->tmpDir . '/compile_hash'; |
|
82 | + $hashFile = $appMeta->tmpDir.'/compile_hash'; |
|
83 | 83 | $moduleHash = md5(serialize($module)); |
84 | 84 | $isUnchanged = file_exists($hashFile) && (file_get_contents($hashFile) === $moduleHash); |
85 | 85 | if ($isUnchanged) { |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | $contextsArray = array_reverse(explode('-', $contexts)); |
105 | 105 | $module = null; |
106 | 106 | foreach ($contextsArray as $context) { |
107 | - $class = $appMeta->name . '\Module\\' . ucwords($context) . 'Module'; |
|
108 | - if (! class_exists($class)) { |
|
109 | - $class = 'BEAR\Package\Context\\' . ucwords($context) . 'Module'; |
|
107 | + $class = $appMeta->name.'\Module\\'.ucwords($context).'Module'; |
|
108 | + if (!class_exists($class)) { |
|
109 | + $class = 'BEAR\Package\Context\\'.ucwords($context).'Module'; |
|
110 | 110 | } |
111 | - if (! is_a($class, AbstractModule::class, true)) { |
|
111 | + if (!is_a($class, AbstractModule::class, true)) { |
|
112 | 112 | throw new InvalidContextException($class); |
113 | 113 | } |
114 | 114 | /* @var $module AbstractModule */ |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | */ |
124 | 124 | private function cleanupDir($tmpDir) |
125 | 125 | { |
126 | - $unlink = function ($path) use (&$unlink) { |
|
127 | - foreach (glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*') as $file) { |
|
126 | + $unlink = function($path) use (&$unlink) { |
|
127 | + foreach (glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*') as $file) { |
|
128 | 128 | is_dir($file) ? $unlink($file) : unlink($file); |
129 | 129 | @rmdir($file); |
130 | 130 | } |
@@ -29,6 +29,10 @@ |
||
29 | 29 | */ |
30 | 30 | private $appMeta; |
31 | 31 | |
32 | + /** |
|
33 | + * @param string $name |
|
34 | + * @param string $contexts |
|
35 | + */ |
|
32 | 36 | public function __construct($name, $contexts) |
33 | 37 | { |
34 | 38 | $this->appMeta = new AppMeta($name, $contexts); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function newApp(AbstractAppMeta $appMeta, $contexts, Cache $cache = null) |
60 | 60 | { |
61 | 61 | $cache = $cache ?: $this->getCache($appMeta, $contexts); |
62 | - $appId = $appMeta->name . $contexts; |
|
62 | + $appId = $appMeta->name.$contexts; |
|
63 | 63 | list($app, $scriptInjector) = $cache->fetch($appId); // $scriptInjector set cached single instance in wakeup |
64 | 64 | if ($app && $app instanceof AbstractApp) { |
65 | 65 | return $app; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | private function getCache(AbstractAppMeta $appMeta, $contexts) |
87 | 87 | { |
88 | - $isDeveop = ! is_int(strpos($contexts, 'prod')); |
|
88 | + $isDeveop = !is_int(strpos($contexts, 'prod')); |
|
89 | 89 | if ($isDeveop) { |
90 | 90 | return new VoidCache; |
91 | 91 | } |
@@ -18,21 +18,21 @@ |
||
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; |
33 | 33 | // body |
34 | 34 | $ob .= $resourceObject->view; |
35 | 35 | |
36 | - echo $ob . PHP_EOL; |
|
36 | + echo $ob.PHP_EOL; |
|
37 | 37 | } |
38 | 38 | } |
@@ -131,7 +131,7 @@ |
||
131 | 131 | /** |
132 | 132 | * @param string $uri |
133 | 133 | * |
134 | - * @return mixed |
|
134 | + * @return string |
|
135 | 135 | */ |
136 | 136 | private function getReverseMatchedLink($uri) |
137 | 137 | { |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function render(ResourceObject $ro) |
64 | 64 | { |
65 | - $method = 'on' . ucfirst($ro->uri->method); |
|
65 | + $method = 'on'.ucfirst($ro->uri->method); |
|
66 | 66 | $hasMethod = method_exists($ro, $method); |
67 | - if (! $hasMethod) { |
|
67 | + if (!$hasMethod) { |
|
68 | 68 | $ro->view = ''; // OPTIONS request no view |
69 | 69 | |
70 | 70 | return ''; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /* @var $annotations Link[] */ |
82 | 82 | /* @var $ro ResourceObject */ |
83 | 83 | $hal = $this->getHal($ro->uri, $body, $annotations); |
84 | - $ro->view = $hal->asJson(true) . PHP_EOL; |
|
84 | + $ro->view = $hal->asJson(true).PHP_EOL; |
|
85 | 85 | $this->updateHeaders($ro); |
86 | 86 | |
87 | 87 | return $ro->view; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * @param \BEAR\Resource\ResourceObject $ro |
106 | 106 | */ |
107 | - private function valuateElements(ResourceObject &$ro) |
|
107 | + private function valuateElements(ResourceObject & $ro) |
|
108 | 108 | { |
109 | 109 | foreach ($ro->body as $key => &$embeded) { |
110 | 110 | if ($embeded instanceof AbstractRequest) { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | private function isDifferentSchema(ResourceObject $parentRo, ResourceObject $childRo) |
133 | 133 | { |
134 | - return $parentRo->uri->host . $parentRo->uri->host !== $childRo->uri->scheme . $childRo->uri->host; |
|
134 | + return $parentRo->uri->host.$parentRo->uri->host !== $childRo->uri->scheme.$childRo->uri->host; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | */ |
144 | 144 | private function getHal(AbstractUri $uri, array $body, array $annotations) |
145 | 145 | { |
146 | - $query = $uri->query ? '?' . http_build_query($uri->query) : ''; |
|
147 | - $path = $uri->path . $query; |
|
146 | + $query = $uri->query ? '?'.http_build_query($uri->query) : ''; |
|
147 | + $path = $uri->path.$query; |
|
148 | 148 | $selfLink = $this->getReverseMatchedLink($path); |
149 | 149 | |
150 | 150 | $hal = new Hal($selfLink, $body); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $hal->addCurie($this->curies->name, $this->curies->href); |
210 | 210 | } |
211 | 211 | foreach ($methodAnnotations as $annotation) { |
212 | - if (! $annotation instanceof Link) { |
|
212 | + if (!$annotation instanceof Link) { |
|
213 | 213 | continue; |
214 | 214 | } |
215 | 215 | $uri = uri_template($annotation->href, $body); |