@@ -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; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function compile() : int |
98 | 98 | { |
99 | - if (! is_dir($this->appDir)) { |
|
99 | + if (!is_dir($this->appDir)) { |
|
100 | 100 | throw new RuntimeException($this->appDir); |
101 | 101 | } |
102 | 102 | $preload = $this->compilePreload($this->appMeta, $this->context); |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | |
138 | 138 | public function registerLoader(string $appDir) : void |
139 | 139 | { |
140 | - $loaderFile = $appDir . '/vendor/autoload.php'; |
|
141 | - if (! file_exists($loaderFile)) { |
|
140 | + $loaderFile = $appDir.'/vendor/autoload.php'; |
|
141 | + if (!file_exists($loaderFile)) { |
|
142 | 142 | throw new RuntimeException('no loader'); |
143 | 143 | } |
144 | 144 | /** @var ClassLoader $loader */ |
145 | 145 | $loader = require $loaderFile; |
146 | 146 | spl_autoload_register( |
147 | 147 | /** @var class-string $class */ |
148 | - function (string $class) use ($loader) : void { |
|
148 | + function(string $class) use ($loader) : void { |
|
149 | 149 | $loader->loadClass($class); |
150 | 150 | if ($class !== NullPage::class) { |
151 | 151 | $this->classes[] = $class; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | %s |
213 | 213 | require __DIR__ . '/vendor/autoload.php'; |
214 | 214 | ", $this->context, $requiredFile); |
215 | - $fileName = realpath($appDir) . '/autoload.php'; |
|
215 | + $fileName = realpath($appDir).'/autoload.php'; |
|
216 | 216 | file_put_contents($fileName, $autoloadFile); |
217 | 217 | |
218 | 218 | return $fileName; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | require __DIR__ . '/vendor/autoload.php' |
237 | 237 | |
238 | 238 | %s", $this->context, $requiredOnceFile); |
239 | - $fileName = realpath($appMeta->appDir) . '/preload.php'; |
|
239 | + $fileName = realpath($appMeta->appDir).'/preload.php'; |
|
240 | 240 | file_put_contents($fileName, $preloadFile); |
241 | 241 | |
242 | 242 | return $fileName; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | { |
247 | 247 | $dir = (string) realpath($rootDir); |
248 | 248 | if (strpos($file, $dir) !== false) { |
249 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); |
|
249 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return $file; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $class = new ReflectionClass($className); |
279 | 279 | /** @var T $instance */ |
280 | 280 | $instance = $class->newInstanceWithoutConstructor(); |
281 | - if (! $instance instanceof $className) { |
|
281 | + if (!$instance instanceof $className) { |
|
282 | 282 | return; |
283 | 283 | } |
284 | 284 | $reader->getClassAnnotations($class); |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | private function saveNamedParam(NamedParameterInterface $namedParameter, object $instance, string $method) : void |
309 | 309 | { |
310 | 310 | // named parameter |
311 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
311 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
312 | 312 | return; |
313 | 313 | } |
314 | 314 | $callable = [$instance, $method]; |
315 | - if (! is_callable($callable)) { |
|
315 | + if (!is_callable($callable)) { |
|
316 | 316 | return; |
317 | 317 | } |
318 | 318 | try { |
@@ -332,13 +332,13 @@ discard block |
||
332 | 332 | $paths = []; |
333 | 333 | foreach ($classes as $class) { |
334 | 334 | // could be phpdoc tag by annotation loader |
335 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); |
|
335 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); |
|
336 | 336 | if ($isAutoloadFailed) { |
337 | 337 | continue; |
338 | 338 | } |
339 | 339 | assert(class_exists($class) || interface_exists($class) || trait_exists($class)); |
340 | 340 | $filePath = (string) (new ReflectionClass($class))->getFileName(); |
341 | - if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
341 | + if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
342 | 342 | continue; |
343 | 343 | } |
344 | 344 | $paths[] = $this->getRelativePath($this->appDir, $filePath); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | |
359 | 359 | private function getInstance(string $interface, string $name = '') : void |
360 | 360 | { |
361 | - $dependencyIndex = $interface . '-' . $name; |
|
361 | + $dependencyIndex = $interface.'-'.$name; |
|
362 | 362 | if (in_array($dependencyIndex, $this->compiled, true)) { |
363 | 363 | printf("S %s:%s\n", $interface, $name); |
364 | 364 | |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | |
398 | 398 | private function hookNullObjectClass(string $appDir) : void |
399 | 399 | { |
400 | - $compileScript = realpath($appDir) . '/.compile.php'; |
|
400 | + $compileScript = realpath($appDir).'/.compile.php'; |
|
401 | 401 | if (file_exists($compileScript)) { |
402 | 402 | require $compileScript; |
403 | 403 | } |
@@ -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 | } |