@@ -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 |
@@ -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 | } |
@@ -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 | if (file_exists($fileName)) { |
| 217 | 217 | $fileName .= ' (overwritten)'; |
| 218 | 218 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | require __DIR__ . '/vendor/autoload.php' |
| 240 | 240 | |
| 241 | 241 | %s", $this->context, $requiredOnceFile); |
| 242 | - $fileName = realpath($appMeta->appDir) . '/preload.php'; |
|
| 242 | + $fileName = realpath($appMeta->appDir).'/preload.php'; |
|
| 243 | 243 | if (file_exists($fileName)) { |
| 244 | 244 | $fileName .= 'overwritten'; |
| 245 | 245 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | { |
| 253 | 253 | $dir = (string) realpath($rootDir); |
| 254 | 254 | if (strpos($file, $dir) !== false) { |
| 255 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); |
|
| 255 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | return $file; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $class = new ReflectionClass($className); |
| 285 | 285 | /** @var T $instance */ |
| 286 | 286 | $instance = $class->newInstanceWithoutConstructor(); |
| 287 | - if (! $instance instanceof $className) { |
|
| 287 | + if (!$instance instanceof $className) { |
|
| 288 | 288 | return; |
| 289 | 289 | } |
| 290 | 290 | $reader->getClassAnnotations($class); |
@@ -314,11 +314,11 @@ discard block |
||
| 314 | 314 | private function saveNamedParam(NamedParameterInterface $namedParameter, object $instance, string $method) : void |
| 315 | 315 | { |
| 316 | 316 | // named parameter |
| 317 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
| 317 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
| 318 | 318 | return; |
| 319 | 319 | } |
| 320 | 320 | $callable = [$instance, $method]; |
| 321 | - if (! is_callable($callable)) { |
|
| 321 | + if (!is_callable($callable)) { |
|
| 322 | 322 | return; |
| 323 | 323 | } |
| 324 | 324 | try { |
@@ -338,13 +338,13 @@ discard block |
||
| 338 | 338 | $paths = []; |
| 339 | 339 | foreach ($classes as $class) { |
| 340 | 340 | // could be phpdoc tag by annotation loader |
| 341 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); |
|
| 341 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); |
|
| 342 | 342 | if ($isAutoloadFailed) { |
| 343 | 343 | continue; |
| 344 | 344 | } |
| 345 | 345 | assert(class_exists($class) || interface_exists($class) || trait_exists($class)); |
| 346 | 346 | $filePath = (string) (new ReflectionClass($class))->getFileName(); |
| 347 | - if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
| 347 | + if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
| 348 | 348 | continue; |
| 349 | 349 | } |
| 350 | 350 | $paths[] = $this->getRelativePath($this->appDir, $filePath); |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | |
| 365 | 365 | private function getInstance(string $interface, string $name = '') : void |
| 366 | 366 | { |
| 367 | - $dependencyIndex = $interface . '-' . $name; |
|
| 367 | + $dependencyIndex = $interface.'-'.$name; |
|
| 368 | 368 | if (in_array($dependencyIndex, $this->compiled, true)) { |
| 369 | 369 | printf("S %s:%s\n", $interface, $name); |
| 370 | 370 | |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | private function hookNullObjectClass(string $appDir) : void |
| 405 | 405 | { |
| 406 | - $compileScript = realpath($appDir) . '/.compile.php'; |
|
| 406 | + $compileScript = realpath($appDir).'/.compile.php'; |
|
| 407 | 407 | if (file_exists($compileScript)) { |
| 408 | 408 | require $compileScript; |
| 409 | 409 | } |