@@ -34,7 +34,7 @@ |
||
| 34 | 34 | |
| 35 | 35 | public function __invoke(string $interface, string $name = ''): void |
| 36 | 36 | { |
| 37 | - $dependencyIndex = $interface . '-' . $name; |
|
| 37 | + $dependencyIndex = $interface.'-'.$name; |
|
| 38 | 38 | if (in_array($dependencyIndex, $this->compiled, true)) { |
| 39 | 39 | // @codeCoverageIgnoreStart |
| 40 | 40 | printf("S %s:%s\n", $interface, $name); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $class = new ReflectionClass($className); |
| 32 | 32 | $instance = $class->newInstanceWithoutConstructor(); |
| 33 | - if (! $instance instanceof $className) { |
|
| 33 | + if (!$instance instanceof $className) { |
|
| 34 | 34 | return; // @codeCoverageIgnore |
| 35 | 35 | } |
| 36 | 36 | |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | private function saveNamedParam(NamedParameterInterface $namedParameter, object $instance, string $method): void |
| 65 | 65 | { |
| 66 | 66 | // named parameter |
| 67 | - if (! in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
| 68 | - return; // @codeCoverageIgnore |
|
| 67 | + if (!in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
| 68 | + return; // @codeCoverageIgnore |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $callable = [$instance, $method]; |
| 72 | - if (! is_callable($callable)) { |
|
| 73 | - return; // @codeCoverageIgnore |
|
| 72 | + if (!is_callable($callable)) { |
|
| 73 | + return; // @codeCoverageIgnore |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | try { |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | public function getFileInfo(string $filename): string |
| 82 | 82 | { |
| 83 | 83 | if (in_array($filename, (array) $this->overwritten, true)) { |
| 84 | - return $filename . ' (overwritten)'; |
|
| 84 | + return $filename.' (overwritten)'; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | return $filename; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | /** @var class-string $class */ |
| 123 | 123 | $filePath = (string) (new ReflectionClass($class))->getFileName(); |
| 124 | - if (! $this->isNotCompileFile($filePath)) { |
|
| 124 | + if (!$this->isNotCompileFile($filePath)) { |
|
| 125 | 125 | continue; // @codeCoverageIgnore |
| 126 | 126 | } |
| 127 | 127 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | %s |
| 152 | 152 | require __DIR__ . '/vendor/autoload.php'; |
| 153 | 153 | ", $this->context, $requiredFile); |
| 154 | - $fileName = realpath($appDir) . '/autoload.php'; |
|
| 154 | + $fileName = realpath($appDir).'/autoload.php'; |
|
| 155 | 155 | |
| 156 | 156 | ($this->filePutContents)($fileName, $autoloadFile); |
| 157 | 157 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | private function isNotAutoloadble(string $class): bool |
| 178 | 178 | { |
| 179 | - return ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); |
|
| 179 | + return !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | private function isNotCompileFile(string $filePath): bool |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | { |
| 189 | 189 | $dir = (string) realpath($rootDir); |
| 190 | 190 | if (strpos($file, $dir) !== false) { |
| 191 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file) . "'"; |
|
| 191 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file)."'"; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | return sprintf("'%s'", $file); |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | opcache_compile_file( __DIR__ . '/vendor/autoload.php'); |
| 66 | 66 | |
| 67 | 67 | %s", $this->context, $requiredOnceFile); |
| 68 | - $fileName = realpath($appMeta->appDir) . '/preload.php'; |
|
| 68 | + $fileName = realpath($appMeta->appDir).'/preload.php'; |
|
| 69 | 69 | ($this->filePutContents)($fileName, $preloadFile); |
| 70 | 70 | |
| 71 | 71 | return $fileName; |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | $requestUri = $server['REQUEST_URI']; |
| 45 | 45 | $request = new RouterMatch(); |
| 46 | 46 | [$request->method, $request->query] = $this->httpMethodParams->get($server, $globals['_GET'], $globals['_POST']); |
| 47 | - $request->path = $this->schemeHost . parse_url($requestUri, 5); // 5 = PHP_URL_PATH |
|
| 47 | + $request->path = $this->schemeHost.parse_url($requestUri, 5); // 5 = PHP_URL_PATH |
|
| 48 | 48 | |
| 49 | 49 | return $request; |
| 50 | 50 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | public function get(): Logger |
| 27 | 27 | { |
| 28 | 28 | $format = "[%datetime%] %level_name%: %message% %context%\n"; |
| 29 | - $stream = new StreamHandler($this->appMeta->logDir . '/app.log'); |
|
| 29 | + $stream = new StreamHandler($this->appMeta->logDir.'/app.log'); |
|
| 30 | 30 | $stream->setFormatter(new LineFormatter($format)); |
| 31 | 31 | |
| 32 | 32 | return new Logger($this->appMeta->name, [$stream]); |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | private function registerLoader(string $appDir, bool $prepend = true): void |
| 136 | 136 | { |
| 137 | 137 | $this->unregisterComposerLoader(); |
| 138 | - $loaderFile = $appDir . '/vendor/autoload.php'; |
|
| 139 | - if (! file_exists($loaderFile)) { |
|
| 138 | + $loaderFile = $appDir.'/vendor/autoload.php'; |
|
| 139 | + if (!file_exists($loaderFile)) { |
|
| 140 | 140 | throw new RuntimeException('no loader'); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -144,12 +144,12 @@ discard block |
||
| 144 | 144 | assert($loader instanceof ClassLoader); |
| 145 | 145 | spl_autoload_register( |
| 146 | 146 | /** @ 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 ( |
| 150 | 150 | $class !== NullPage::class |
| 151 | - && ! is_int(strpos($class, 'BEAR\Package\Compiler')) |
|
| 152 | - && ! is_int(strpos($class, NullPage::class)) |
|
| 151 | + && !is_int(strpos($class, 'BEAR\Package\Compiler')) |
|
| 152 | + && !is_int(strpos($class, NullPage::class)) |
|
| 153 | 153 | ) { |
| 154 | 154 | /** @psalm-suppress NullArgument */ |
| 155 | 155 | $this->classes[] = $class; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | private function hookNullObjectClass(string $appDir): void |
| 164 | 164 | { |
| 165 | - $compileScript = realpath($appDir) . '/.compile.php'; |
|
| 165 | + $compileScript = realpath($appDir).'/.compile.php'; |
|
| 166 | 166 | if (file_exists($compileScript)) { |
| 167 | 167 | require $compileScript; |
| 168 | 168 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | public function __invoke(string $appName, string $context, array $globals, array $server): int |
| 39 | 39 | { |
| 40 | - $injector = Injector::getInstance($appName, $context, $this->appDir); |
|
| 40 | + $injector = Injector::getInstance($appName, $context, $this->appDir); |
|
| 41 | 41 | $injector->getInstance(HttpCacheInterface::class); |
| 42 | 42 | $router = $injector->getInstance(RouterInterface::class); |
| 43 | 43 | $request = $router->match($globals, $server); |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | public static function getInstance(string $appName, string $context, string $appDir, ?CacheInterface $cache = null): InjectorInterface |
| 42 | 42 | { |
| 43 | - $injectorId = str_replace('\\', '_', $appName) . $context; |
|
| 43 | + $injectorId = str_replace('\\', '_', $appName).$context; |
|
| 44 | 44 | if (isset(self::$instances[$injectorId])) { |
| 45 | 45 | return self::$instances[$injectorId]; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $meta = new Meta($appName, $context, $appDir); |
| 49 | - $cache = $cache ?? new ChainAdapter([new ApcuAdapter($injectorId), new PhpFilesAdapter($injectorId, 0, $meta->tmpDir . '/injector')]); |
|
| 50 | - $injector = $cache->get($injectorId, static function () use ($meta, $context): InjectorInterface { |
|
| 49 | + $cache = $cache ?? new ChainAdapter([new ApcuAdapter($injectorId), new PhpFilesAdapter($injectorId, 0, $meta->tmpDir.'/injector')]); |
|
| 50 | + $injector = $cache->get($injectorId, static function() use ($meta, $context): InjectorInterface { |
|
| 51 | 51 | $injector = self::factory($meta, $context); |
| 52 | 52 | $injector->getInstance(AppInterface::class); |
| 53 | 53 | |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | private static function factory(Meta $meta, string $context): InjectorInterface |
| 63 | 63 | { |
| 64 | - $scriptDir = $meta->tmpDir . '/di'; |
|
| 65 | - ! is_dir($scriptDir) && ! @mkdir($scriptDir) && ! is_dir($scriptDir); |
|
| 64 | + $scriptDir = $meta->tmpDir.'/di'; |
|
| 65 | + !is_dir($scriptDir) && !@mkdir($scriptDir) && !is_dir($scriptDir); |
|
| 66 | 66 | $module = (new Module())($meta, $context, ''); |
| 67 | 67 | $rayInjector = new RayInjector($module, $scriptDir); |
| 68 | 68 | $isProd = $rayInjector->getInstance('', Compile::class); |
| 69 | 69 | assert(is_bool($isProd)); |
| 70 | 70 | if ($isProd) { |
| 71 | - return new ScriptInjector($scriptDir, static function () use ($scriptDir, $module) { |
|
| 71 | + return new ScriptInjector($scriptDir, static function() use ($scriptDir, $module) { |
|
| 72 | 72 | return new ScriptinjectorModule($scriptDir, $module); |
| 73 | 73 | }); |
| 74 | 74 | } |