@@ -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 |
@@ -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 Exception; |
19 | 18 | use function file_exists; |
20 | 19 | use Ray\Di\AbstractModule; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function compile() : int |
97 | 97 | { |
98 | - if (! is_dir($this->appDir)) { |
|
98 | + if (!is_dir($this->appDir)) { |
|
99 | 99 | throw new RuntimeException($this->appDir); |
100 | 100 | } |
101 | 101 | $preload = $this->compilePreload($this->appMeta, $this->context); |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | |
137 | 137 | public function registerLoader(string $appDir) : void |
138 | 138 | { |
139 | - $loaderFile = $appDir . '/vendor/autoload.php'; |
|
140 | - if (! file_exists($loaderFile)) { |
|
139 | + $loaderFile = $appDir.'/vendor/autoload.php'; |
|
140 | + if (!file_exists($loaderFile)) { |
|
141 | 141 | throw new RuntimeException('no loader'); |
142 | 142 | } |
143 | 143 | /** @var ClassLoader $loader */ |
144 | 144 | $loader = require $loaderFile; |
145 | 145 | spl_autoload_register( |
146 | 146 | /** @var class-string $class */ |
147 | - function (string $class) use ($loader) : void { |
|
147 | + function(string $class) use ($loader) : void { |
|
148 | 148 | $loader->loadClass($class); |
149 | 149 | if ($class !== NullPage::class) { |
150 | 150 | $this->classes[] = $class; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | private function saveAutoloadFile(string $appDir, array $paths) : string |
199 | 199 | { |
200 | - $autoloadFile = '<?php' . PHP_EOL . 'require __DIR__ . \'/vendor/ray/di/src/ProviderInterface.php\'; |
|
200 | + $autoloadFile = '<?php'.PHP_EOL.'require __DIR__ . \'/vendor/ray/di/src/ProviderInterface.php\'; |
|
201 | 201 | ' . PHP_EOL; |
202 | 202 | foreach ($paths as $path) { |
203 | 203 | $autoloadFile .= sprintf( |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | $this->getRelativePath($appDir, $path) |
206 | 206 | ); |
207 | 207 | } |
208 | - $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
209 | - $loaderFile = realpath($appDir) . '/autoload.php'; |
|
208 | + $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
209 | + $loaderFile = realpath($appDir).'/autoload.php'; |
|
210 | 210 | file_put_contents($loaderFile, $autoloadFile); |
211 | 211 | |
212 | 212 | return $loaderFile; |
@@ -216,15 +216,15 @@ discard block |
||
216 | 216 | { |
217 | 217 | $this->loadResources($appMeta->name, $context, $appMeta->appDir); |
218 | 218 | $paths = $this->getPaths($this->classes); |
219 | - $output = '<?php' . PHP_EOL; |
|
220 | - $output .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
219 | + $output = '<?php'.PHP_EOL; |
|
220 | + $output .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
221 | 221 | foreach ($paths as $path) { |
222 | 222 | $output .= sprintf( |
223 | 223 | "require_once %s';\n", |
224 | 224 | $this->getRelativePath($appMeta->appDir, $path) |
225 | 225 | ); |
226 | 226 | } |
227 | - $preloadFile = realpath($appMeta->appDir) . '/preload.php'; |
|
227 | + $preloadFile = realpath($appMeta->appDir).'/preload.php'; |
|
228 | 228 | file_put_contents($preloadFile, $output); |
229 | 229 | |
230 | 230 | return $preloadFile; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | { |
235 | 235 | $dir = (string) realpath($rootDir); |
236 | 236 | if (strpos($file, $dir) !== false) { |
237 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); |
|
237 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | return $file; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $class = new ReflectionClass($className); |
267 | 267 | /** @var T $instance */ |
268 | 268 | $instance = $class->newInstanceWithoutConstructor(); |
269 | - if (! $instance instanceof $className) { |
|
269 | + if (!$instance instanceof $className) { |
|
270 | 270 | return; |
271 | 271 | } |
272 | 272 | $reader->getClassAnnotations($class); |
@@ -296,11 +296,11 @@ discard block |
||
296 | 296 | private function saveNamedParam(NamedParameterInterface $namedParameter, object $instance, string $method) : void |
297 | 297 | { |
298 | 298 | // named parameter |
299 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
299 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
300 | 300 | return; |
301 | 301 | } |
302 | 302 | $callable = [$instance, $method]; |
303 | - if (! is_callable($callable)) { |
|
303 | + if (!is_callable($callable)) { |
|
304 | 304 | return; |
305 | 305 | } |
306 | 306 | try { |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | $paths = []; |
321 | 321 | foreach ($classes as $class) { |
322 | 322 | // could be phpdoc tag by annotation loader |
323 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); |
|
323 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); |
|
324 | 324 | if ($isAutoloadFailed) { |
325 | 325 | continue; |
326 | 326 | } |
327 | 327 | assert(class_exists($class) || interface_exists($class) || trait_exists($class)); |
328 | 328 | $filePath = (string) (new ReflectionClass($class))->getFileName(); |
329 | - if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
329 | + if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
330 | 330 | continue; |
331 | 331 | } |
332 | 332 | $paths[] = $this->getRelativePath($this->appDir, $filePath); |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | |
347 | 347 | private function getInstance(string $interface, string $name = '') : void |
348 | 348 | { |
349 | - $dependencyIndex = $interface . '-' . $name; |
|
349 | + $dependencyIndex = $interface.'-'.$name; |
|
350 | 350 | if (in_array($dependencyIndex, $this->compiled, true)) { |
351 | 351 | printf("S %s:%s\n", $interface, $name); |
352 | 352 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | |
386 | 386 | private function hookNullObjectClass(string $appDir) : void |
387 | 387 | { |
388 | - $compileScript = realpath($appDir) . '/.compile.php'; |
|
388 | + $compileScript = realpath($appDir).'/.compile.php'; |
|
389 | 389 | if (file_exists($compileScript)) { |
390 | 390 | require $compileScript; |
391 | 391 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | public function __construct(Exception $e) |
20 | 20 | { |
21 | - $this->ref = hash('crc32b', get_class($e) . $e->getMessage() . $e->getFile() . $e->getLine()); |
|
21 | + $this->ref = hash('crc32b', get_class($e).$e->getMessage().$e->getFile().$e->getLine()); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function __toString() |
@@ -38,7 +38,7 @@ |
||
38 | 38 | } catch (Exception $e) { |
39 | 39 | throw new RouterException($e->getMessage(), (int) $e->getCode(), $e->getPrevious()); |
40 | 40 | } |
41 | - if (! $match instanceof NullMatch) { |
|
41 | + if (!$match instanceof NullMatch) { |
|
42 | 42 | return $match; |
43 | 43 | } |
44 | 44 | } |