@@ -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 | } |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __invoke(string $appName, string $context, string $appDir) : string |
43 | 43 | { |
44 | - if (! is_dir($appDir)) { |
|
44 | + if (!is_dir($appDir)) { |
|
45 | 45 | throw new \RuntimeException($appDir); |
46 | 46 | } |
47 | - $this->ns = (string) filemtime(realpath($appDir) . '/src'); |
|
47 | + $this->ns = (string) filemtime(realpath($appDir).'/src'); |
|
48 | 48 | $this->registerLoader($appDir); |
49 | 49 | $appMeta = new Meta($appName, $context, $appDir); |
50 | 50 | $autoload = $this->compileAutoload($appMeta, $context); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $module = (new Module)($appMeta, $context); |
53 | 53 | $this->compileSrc($module, $appMeta, $context); |
54 | 54 | $this->compileDiScripts($appMeta, $context); |
55 | - $logFile = realpath($appMeta->logDir) . '/compile.log'; |
|
55 | + $logFile = realpath($appMeta->logDir).'/compile.log'; |
|
56 | 56 | file_put_contents($logFile, (string) $module); |
57 | 57 | |
58 | 58 | return sprintf("Compile Log: %s\nautoload.php: %s\npreload.php: %s", $logFile, $autoload, $preload); |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | |
61 | 61 | public function registerLoader(string $appDir) : void |
62 | 62 | { |
63 | - $loaderFile = $appDir . '/vendor/autoload.php'; |
|
64 | - if (! file_exists($loaderFile)) { |
|
63 | + $loaderFile = $appDir.'/vendor/autoload.php'; |
|
64 | + if (!file_exists($loaderFile)) { |
|
65 | 65 | throw new \RuntimeException('no loader'); |
66 | 66 | } |
67 | 67 | /** @var ClassLoader $loader */ |
68 | 68 | $loader = require $loaderFile; |
69 | 69 | spl_autoload_register( |
70 | 70 | /** @var class-string $class */ |
71 | - function (string $class) use ($loader) : void { |
|
71 | + function(string $class) use ($loader) : void { |
|
72 | 72 | $loader->loadClass($class); |
73 | 73 | if ($class !== NullPage::class) { |
74 | 74 | $this->classes[] = $class; |
@@ -134,15 +134,15 @@ discard block |
||
134 | 134 | */ |
135 | 135 | private function dumpAutoload(string $appDir, array $paths) : string |
136 | 136 | { |
137 | - $autoloadFile = '<?php' . PHP_EOL; |
|
137 | + $autoloadFile = '<?php'.PHP_EOL; |
|
138 | 138 | foreach ($paths as $path) { |
139 | 139 | $autoloadFile .= sprintf( |
140 | 140 | "require %s';\n", |
141 | 141 | $this->getRelativePath($appDir, $path) |
142 | 142 | ); |
143 | 143 | } |
144 | - $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
145 | - $loaderFile = realpath($appDir) . '/autoload.php'; |
|
144 | + $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
145 | + $loaderFile = realpath($appDir).'/autoload.php'; |
|
146 | 146 | file_put_contents($loaderFile, $autoloadFile); |
147 | 147 | |
148 | 148 | return $loaderFile; |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | { |
153 | 153 | $this->loadResources($appMeta->name, $context, $appMeta->appDir); |
154 | 154 | $paths = $this->getPaths($this->classes, $appMeta->appDir); |
155 | - $output = '<?php' . PHP_EOL; |
|
156 | - $output .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
155 | + $output = '<?php'.PHP_EOL; |
|
156 | + $output .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
157 | 157 | foreach ($paths as $path) { |
158 | 158 | $output .= sprintf( |
159 | 159 | "require %s';\n", |
160 | 160 | $this->getRelativePath($appMeta->appDir, $path) |
161 | 161 | ); |
162 | 162 | } |
163 | - $preloadFile = realpath($appMeta->appDir) . '/preload.php'; |
|
163 | + $preloadFile = realpath($appMeta->appDir).'/preload.php'; |
|
164 | 164 | file_put_contents($preloadFile, $output); |
165 | 165 | |
166 | 166 | return $preloadFile; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | $dir = (string) realpath($rootDir); |
172 | 172 | if (strpos($file, $dir) !== false) { |
173 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); |
|
173 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | return $file; |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | private function saveNamedParam(NamedParameterInterface $namedParameter, object $instance, string $method) : void |
231 | 231 | { |
232 | 232 | // named parameter |
233 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
233 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
234 | 234 | return; |
235 | 235 | } |
236 | 236 | $callable = [$instance, $method]; |
237 | - if (! is_callable($callable)) { |
|
237 | + if (!is_callable($callable)) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | try { |
@@ -254,13 +254,13 @@ discard block |
||
254 | 254 | $paths = []; |
255 | 255 | foreach ($classes as $class) { |
256 | 256 | // could be phpdoc tag by annotation loader |
257 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); |
|
257 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); |
|
258 | 258 | if ($isAutoloadFailed) { |
259 | 259 | continue; |
260 | 260 | } |
261 | 261 | assert(class_exists($class) || interface_exists($class) || trait_exists($class)); |
262 | 262 | $filePath = (string) (new ReflectionClass($class))->getFileName(); |
263 | - if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
263 | + if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
264 | 264 | continue; |
265 | 265 | } |
266 | 266 | $paths[] = $this->getRelativePath($appDir, $filePath); |
@@ -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 |