@@ -29,7 +29,7 @@ |
||
29 | 29 | protected function configure() : void |
30 | 30 | { |
31 | 31 | $this->bind(AbstractAppMeta::class)->toInstance($this->appMeta); |
32 | - $this->bind(AppInterface::class)->to($this->appMeta->name . '\Module\App')->in(Scope::SINGLETON); |
|
32 | + $this->bind(AppInterface::class)->to($this->appMeta->name.'\Module\App')->in(Scope::SINGLETON); |
|
33 | 33 | $this->bind()->annotatedWith(AppName::class)->toInstance($this->appMeta->name); |
34 | 34 | } |
35 | 35 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | } catch (\Exception $e) { |
38 | 38 | throw new RouterException($e->getMessage(), (int) $e->getCode(), $e->getPrevious()); |
39 | 39 | } |
40 | - if (! $match instanceof NullMatch) { |
|
40 | + if (!$match instanceof NullMatch) { |
|
41 | 41 | return $match; |
42 | 42 | } |
43 | 43 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | private function getParams(string $method, array $server, array $post) : array |
106 | 106 | { |
107 | 107 | // post data exists |
108 | - if ($method === 'post' && ! empty($post)) { |
|
108 | + if ($method === 'post' && !empty($post)) { |
|
109 | 109 | return $post; |
110 | 110 | } |
111 | 111 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | return $put; |
135 | 135 | } |
136 | 136 | $isApplicationJson = strpos($contentType, self::APPLICATION_JSON) !== false; |
137 | - if (! $isApplicationJson) { |
|
137 | + if (!$isApplicationJson) { |
|
138 | 138 | return []; |
139 | 139 | } |
140 | 140 | /** @var array<string, mixed> $content */ |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $request = new RouterMatch; |
47 | 47 | /** @var array{HTTP_X_HTTP_METHOD_OVERRIDE?: string, REQUEST_METHOD: string} $server */ |
48 | 48 | [$request->method, $request->query] = $this->httpMethodParams->get($server, $globals['_GET'], $globals['_POST']); |
49 | - $request->path = $this->schemeHost . parse_url($requestUri, 5); // 5 = PHP_URL_PATH |
|
49 | + $request->path = $this->schemeHost.parse_url($requestUri, 5); // 5 = PHP_URL_PATH |
|
50 | 50 | |
51 | 51 | return $request; |
52 | 52 | } |
@@ -9,7 +9,6 @@ |
||
9 | 9 | use BEAR\Package\Context\Provider\ProdCacheProvider; |
10 | 10 | use BEAR\Package\Provide\Boot\ScriptinjectorModule; |
11 | 11 | use BEAR\Sunday\Extension\Application\AppInterface; |
12 | -use Doctrine\Common\Cache\Cache; |
|
13 | 12 | use Doctrine\Common\Cache\ChainCache; |
14 | 13 | use Ray\Compiler\ScriptInjector; |
15 | 14 | use Ray\Di\Injector as RayInjector; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public static function getInstance(string $appName, string $context, string $appDir, string $cacheNamespace = '') : InjectorInterface |
32 | 32 | { |
33 | - $injectorId = $appName . $context . $cacheNamespace; |
|
33 | + $injectorId = $appName.$context.$cacheNamespace; |
|
34 | 34 | if (isset(self::$instances[$injectorId])) { |
35 | 35 | return self::$instances[$injectorId]; |
36 | 36 | } |
@@ -46,18 +46,18 @@ discard block |
||
46 | 46 | |
47 | 47 | private static function factory(Meta $meta, string $context, string $cacheNamespace, ChainCache $cache) : InjectorInterface |
48 | 48 | { |
49 | - $scriptDir = $meta->tmpDir . '/di'; |
|
50 | - ! is_dir($scriptDir) && ! @mkdir($scriptDir) && ! is_dir($scriptDir); |
|
49 | + $scriptDir = $meta->tmpDir.'/di'; |
|
50 | + !is_dir($scriptDir) && !@mkdir($scriptDir) && !is_dir($scriptDir); |
|
51 | 51 | $module = (new Module)($meta, $context, $cacheNamespace); |
52 | 52 | $rayInjector = new RayInjector($module, $scriptDir); |
53 | 53 | /** @var bool $isProd */ |
54 | 54 | $isProd = $rayInjector->getInstance(DiCompile::class); |
55 | - if (! $isProd) { |
|
55 | + if (!$isProd) { |
|
56 | 56 | $rayInjector->getInstance(AppInterface::class); |
57 | 57 | |
58 | 58 | return $rayInjector; |
59 | 59 | } |
60 | - $scriptInjector = new ScriptInjector($scriptDir, function () use ($scriptDir, $module) { |
|
60 | + $scriptInjector = new ScriptInjector($scriptDir, function() use ($scriptDir, $module) { |
|
61 | 61 | return new ScriptinjectorModule($scriptDir, $module); |
62 | 62 | }); |
63 | 63 | $scriptInjector->getInstance(AppInterface::class); // cache App as a singleton |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function compile() : int |
93 | 93 | { |
94 | - if (! is_dir($this->appDir)) { |
|
94 | + if (!is_dir($this->appDir)) { |
|
95 | 95 | throw new \RuntimeException($this->appDir); |
96 | 96 | } |
97 | 97 | $preload = $this->compilePreload($this->appMeta, $this->context); |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | |
133 | 133 | public function registerLoader(string $appDir) : void |
134 | 134 | { |
135 | - $loaderFile = $appDir . '/vendor/autoload.php'; |
|
136 | - if (! file_exists($loaderFile)) { |
|
135 | + $loaderFile = $appDir.'/vendor/autoload.php'; |
|
136 | + if (!file_exists($loaderFile)) { |
|
137 | 137 | throw new \RuntimeException('no loader'); |
138 | 138 | } |
139 | 139 | /** @var ClassLoader $loader */ |
140 | 140 | $loader = require $loaderFile; |
141 | 141 | spl_autoload_register( |
142 | 142 | /** @var class-string $class */ |
143 | - function (string $class) use ($loader) : void { |
|
143 | + function(string $class) use ($loader) : void { |
|
144 | 144 | $loader->loadClass($class); |
145 | 145 | if ($class !== NullPage::class) { |
146 | 146 | $this->classes[] = $class; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | private function saveAutoloadFile(string $appDir, array $paths) : string |
195 | 195 | { |
196 | - $autoloadFile = '<?php' . PHP_EOL . 'require __DIR__ . \'/vendor/ray/di/src/ProviderInterface.php\'; |
|
196 | + $autoloadFile = '<?php'.PHP_EOL.'require __DIR__ . \'/vendor/ray/di/src/ProviderInterface.php\'; |
|
197 | 197 | ' . PHP_EOL; |
198 | 198 | foreach ($paths as $path) { |
199 | 199 | $autoloadFile .= sprintf( |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | $this->getRelativePath($appDir, $path) |
202 | 202 | ); |
203 | 203 | } |
204 | - $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
205 | - $loaderFile = realpath($appDir) . '/autoload.php'; |
|
204 | + $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
205 | + $loaderFile = realpath($appDir).'/autoload.php'; |
|
206 | 206 | file_put_contents($loaderFile, $autoloadFile); |
207 | 207 | |
208 | 208 | return $loaderFile; |
@@ -212,15 +212,15 @@ discard block |
||
212 | 212 | { |
213 | 213 | $this->loadResources($appMeta->name, $context, $appMeta->appDir); |
214 | 214 | $paths = $this->getPaths($this->classes); |
215 | - $output = '<?php' . PHP_EOL; |
|
216 | - $output .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
215 | + $output = '<?php'.PHP_EOL; |
|
216 | + $output .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
217 | 217 | foreach ($paths as $path) { |
218 | 218 | $output .= sprintf( |
219 | 219 | "require_once '%s';\n", |
220 | 220 | $this->getRelativePath($appMeta->appDir, $path) |
221 | 221 | ); |
222 | 222 | } |
223 | - $preloadFile = realpath($appMeta->appDir) . '/preload.php'; |
|
223 | + $preloadFile = realpath($appMeta->appDir).'/preload.php'; |
|
224 | 224 | file_put_contents($preloadFile, $output); |
225 | 225 | |
226 | 226 | return $preloadFile; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | $dir = (string) realpath($rootDir); |
232 | 232 | if (strpos($file, $dir) !== false) { |
233 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); |
|
233 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | return $file; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $class = new \ReflectionClass($className); |
263 | 263 | /** @var T $instance */ |
264 | 264 | $instance = $class->newInstanceWithoutConstructor(); |
265 | - if (! $instance instanceof $className) { |
|
265 | + if (!$instance instanceof $className) { |
|
266 | 266 | return; |
267 | 267 | } |
268 | 268 | $reader->getClassAnnotations($class); |
@@ -292,11 +292,11 @@ discard block |
||
292 | 292 | private function saveNamedParam(NamedParameterInterface $namedParameter, object $instance, string $method) : void |
293 | 293 | { |
294 | 294 | // named parameter |
295 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
295 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
296 | 296 | return; |
297 | 297 | } |
298 | 298 | $callable = [$instance, $method]; |
299 | - if (! is_callable($callable)) { |
|
299 | + if (!is_callable($callable)) { |
|
300 | 300 | return; |
301 | 301 | } |
302 | 302 | try { |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | $paths = []; |
317 | 317 | foreach ($classes as $class) { |
318 | 318 | // could be phpdoc tag by annotation loader |
319 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); |
|
319 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); |
|
320 | 320 | if ($isAutoloadFailed) { |
321 | 321 | continue; |
322 | 322 | } |
323 | 323 | assert(class_exists($class) || interface_exists($class) || trait_exists($class)); |
324 | 324 | $filePath = (string) (new ReflectionClass($class))->getFileName(); |
325 | - if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
325 | + if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
326 | 326 | continue; |
327 | 327 | } |
328 | 328 | $paths[] = $this->getRelativePath($this->appDir, $filePath); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | private function getInstance(string $interface, string $name = '') : void |
344 | 344 | { |
345 | - $dependencyIndex = $interface . '-' . $name; |
|
345 | + $dependencyIndex = $interface.'-'.$name; |
|
346 | 346 | if (in_array($dependencyIndex, $this->compiled, true)) { |
347 | 347 | printf("S %s:%s\n", $interface, $name); |
348 | 348 |
@@ -14,7 +14,6 @@ |
||
14 | 14 | use BEAR\Sunday\Extension\Application\AppInterface; |
15 | 15 | use Composer\Autoload\ClassLoader; |
16 | 16 | use Doctrine\Common\Annotations\Reader; |
17 | -use Doctrine\Common\Cache\Cache; |
|
18 | 17 | use function file_exists; |
19 | 18 | use Ray\Di\AbstractModule; |
20 | 19 | use Ray\Di\Exception\Unbound; |