@@ -21,17 +21,17 @@ |
||
| 21 | 21 | $contextsArray = array_reverse(explode('-', $context)); |
| 22 | 22 | $module = new AssistedModule; |
| 23 | 23 | foreach ($contextsArray as $contextItem) { |
| 24 | - $class = $appMeta->name . '\Module\\' . ucwords($contextItem) . 'Module'; |
|
| 25 | - if (! class_exists($class)) { |
|
| 26 | - $class = 'BEAR\Package\Context\\' . ucwords($contextItem) . 'Module'; |
|
| 24 | + $class = $appMeta->name.'\Module\\'.ucwords($contextItem).'Module'; |
|
| 25 | + if (!class_exists($class)) { |
|
| 26 | + $class = 'BEAR\Package\Context\\'.ucwords($contextItem).'Module'; |
|
| 27 | 27 | } |
| 28 | - if (! is_a($class, AbstractModule::class, true)) { |
|
| 28 | + if (!is_a($class, AbstractModule::class, true)) { |
|
| 29 | 29 | throw new InvalidContextException($contextItem); |
| 30 | 30 | } |
| 31 | 31 | /* @var $module AbstractModule */ |
| 32 | 32 | $module = is_subclass_of($class, AbstractAppModule::class) ? new $class($appMeta, $module) : new $class($module); |
| 33 | 33 | } |
| 34 | - if (! $module instanceof AbstractModule) { |
|
| 34 | + if (!$module instanceof AbstractModule) { |
|
| 35 | 35 | throw new InvalidModuleException; // @codeCoverageIgnore |
| 36 | 36 | } |
| 37 | 37 | $module->override(new AppMetaModule($appMeta)); |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | protected function configure() : void |
| 29 | 29 | { |
| 30 | 30 | $this->bind(AbstractAppMeta::class)->toInstance($this->appMeta); |
| 31 | - $this->bind(AppInterface::class)->to($this->appMeta->name . '\Module\App'); |
|
| 31 | + $this->bind(AppInterface::class)->to($this->appMeta->name.'\Module\App'); |
|
| 32 | 32 | $this->bind()->annotatedWith(AppName::class)->toInstance($this->appMeta->name); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -22,10 +22,10 @@ |
||
| 22 | 22 | |
| 23 | 23 | public function __invoke(string $path) : void |
| 24 | 24 | { |
| 25 | - if ($this->isOptional && file_exists($path . '/.do_not_clear')) { |
|
| 25 | + if ($this->isOptional && file_exists($path.'/.do_not_clear')) { |
|
| 26 | 26 | return; |
| 27 | 27 | } |
| 28 | - foreach ((array) glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*') as $file) { |
|
| 28 | + foreach ((array) glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*') as $file) { |
|
| 29 | 29 | is_dir((string) $file) ? $this->__invoke((string) $file) : unlink((string) $file); |
| 30 | 30 | @rmdir((string) $file); |
| 31 | 31 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | public function get() : Logger |
| 29 | 29 | { |
| 30 | 30 | $format = "[%datetime%] %level_name%: %message% %context%\n"; |
| 31 | - $stream = new StreamHandler($this->appMeta->logDir . '/app.log', Logger::DEBUG); |
|
| 31 | + $stream = new StreamHandler($this->appMeta->logDir.'/app.log', Logger::DEBUG); |
|
| 32 | 32 | $stream->setFormatter(new LineFormatter($format)); |
| 33 | 33 | |
| 34 | 34 | return new Logger($this->appMeta->name, [$stream]); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | private function getParams(string $method, array $server, array $post) : array |
| 88 | 88 | { |
| 89 | 89 | // post data exists |
| 90 | - if ($method === 'post' && ! empty($post)) { |
|
| 90 | + if ($method === 'post' && !empty($post)) { |
|
| 91 | 91 | return $post; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | return $put; |
| 112 | 112 | } |
| 113 | 113 | $isApplicationJson = strpos($contentType, self::APPLICATION_JSON) !== false; |
| 114 | - if (! $isApplicationJson) { |
|
| 114 | + if (!$isApplicationJson) { |
|
| 115 | 115 | return []; |
| 116 | 116 | } |
| 117 | 117 | $content = json_decode($this->getRawBody($server), true); |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | $this->context = $context; |
| 57 | 57 | $this->appMeta = $appMeta instanceof AbstractAppMeta ? $appMeta : new Meta($name, $context); |
| 58 | 58 | $this->cacheNamespace = (string) $cacheNamespace; |
| 59 | - $scriptDir = $this->appMeta->tmpDir . '/di'; |
|
| 60 | - ! is_dir($scriptDir) && ! mkdir($scriptDir) && ! is_dir($scriptDir); |
|
| 59 | + $scriptDir = $this->appMeta->tmpDir.'/di'; |
|
| 60 | + !is_dir($scriptDir) && !mkdir($scriptDir) && !is_dir($scriptDir); |
|
| 61 | 61 | $this->scriptDir = $scriptDir; |
| 62 | - $appDir = $this->appMeta->tmpDir . '/app'; |
|
| 63 | - ! is_dir($appDir) && ! mkdir($appDir) && ! is_dir($appDir); |
|
| 64 | - touch($appDir . '/.do_not_clear'); |
|
| 62 | + $appDir = $this->appMeta->tmpDir.'/app'; |
|
| 63 | + !is_dir($appDir) && !mkdir($appDir) && !is_dir($appDir); |
|
| 64 | + touch($appDir.'/.do_not_clear'); |
|
| 65 | 65 | $this->appDir = $appDir; |
| 66 | - $this->injector = new ScriptInjector($this->scriptDir, function () { |
|
| 66 | + $this->injector = new ScriptInjector($this->scriptDir, function() { |
|
| 67 | 67 | return $this->getModule(); |
| 68 | 68 | }); |
| 69 | 69 | if ($cacheNamespace === null) { |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | if ((new Unlink)->once($this->appMeta->tmpDir)) { |
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | - $diDir = $this->appMeta->tmpDir . '/di'; |
|
| 104 | - ! is_dir($diDir) && ! mkdir($diDir) && ! is_dir($diDir); |
|
| 105 | - file_put_contents($this->scriptDir . ScriptInjector::MODULE, serialize($this->getModule())); |
|
| 103 | + $diDir = $this->appMeta->tmpDir.'/di'; |
|
| 104 | + !is_dir($diDir) && !mkdir($diDir) && !is_dir($diDir); |
|
| 105 | + file_put_contents($this->scriptDir.ScriptInjector::MODULE, serialize($this->getModule())); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | public function getCachedInstance(string $interface, string $name = Name::ANY) |
| 112 | 112 | { |
| 113 | 113 | $cache = new FilesystemCache($this->appDir); |
| 114 | - $id = $interface . $name . $this->context . $this->cacheNamespace; |
|
| 114 | + $id = $interface.$name.$this->context.$this->cacheNamespace; |
|
| 115 | 115 | $instance = $cache->fetch($id); |
| 116 | 116 | if ($instance) { |
| 117 | 117 | return $instance; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function __invoke(string $appName, string $context, string $appDir) : string |
| 42 | 42 | { |
| 43 | - $this->ns = (string) filemtime(realpath($appDir) . '/src'); |
|
| 43 | + $this->ns = (string) filemtime(realpath($appDir).'/src'); |
|
| 44 | 44 | $this->registerLoader($appDir); |
| 45 | 45 | $autoload = $this->compileAutoload($appName, $context, $appDir); |
| 46 | 46 | $preload = $this->compilePreload($appDir); |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | public function registerLoader(string $appDir) : void |
| 53 | 53 | { |
| 54 | - $loaderFile = $appDir . '/vendor/autoload.php'; |
|
| 55 | - if (! file_exists($loaderFile)) { |
|
| 54 | + $loaderFile = $appDir.'/vendor/autoload.php'; |
|
| 55 | + if (!file_exists($loaderFile)) { |
|
| 56 | 56 | throw new \RuntimeException('no loader'); |
| 57 | 57 | } |
| 58 | 58 | $loaderFile = require $loaderFile; |
| 59 | 59 | spl_autoload_register( |
| 60 | - function ($class) use ($loaderFile) : void { |
|
| 60 | + function($class) use ($loaderFile) : void { |
|
| 61 | 61 | $loaderFile->loadClass($class); |
| 62 | 62 | if ($class !== NullPage::class) { |
| 63 | 63 | $this->classes[] = $class; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | foreach ($appMeta->getResourceListGenerator() as [$className]) { |
| 86 | 86 | $this->scanClass($injector, $reader, $namedParams, (string) $className); |
| 87 | 87 | } |
| 88 | - $logFile = realpath($appMeta->logDir) . '/compile.log'; |
|
| 88 | + $logFile = realpath($appMeta->logDir).'/compile.log'; |
|
| 89 | 89 | $this->saveCompileLog($appMeta, $context, $logFile); |
| 90 | 90 | |
| 91 | 91 | return $logFile; |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | private function dumpAutoload(string $appDir, array $paths) : string |
| 103 | 103 | { |
| 104 | - $autoloadFile = '<?php' . PHP_EOL; |
|
| 104 | + $autoloadFile = '<?php'.PHP_EOL; |
|
| 105 | 105 | foreach ($paths as $path) { |
| 106 | 106 | $autoloadFile .= sprintf( |
| 107 | 107 | "require %s';\n", |
| 108 | 108 | $this->getRelativePath($appDir, $path) |
| 109 | 109 | ); |
| 110 | 110 | } |
| 111 | - $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
| 112 | - $loaderFile = realpath($appDir) . '/autoload.php'; |
|
| 111 | + $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
| 112 | + $loaderFile = realpath($appDir).'/autoload.php'; |
|
| 113 | 113 | file_put_contents($loaderFile, $autoloadFile); |
| 114 | 114 | |
| 115 | 115 | return $loaderFile; |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $this->loadResources($appName, $context, $appDir); |
| 121 | 121 | $paths = $this->getPaths($this->classes, $appDir); |
| 122 | - $output = '<?php' . PHP_EOL; |
|
| 123 | - $output .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
| 122 | + $output = '<?php'.PHP_EOL; |
|
| 123 | + $output .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
| 124 | 124 | foreach ($paths as $path) { |
| 125 | 125 | $output .= sprintf( |
| 126 | 126 | "require %s';\n", |
| 127 | 127 | $this->getRelativePath($appDir, $path) |
| 128 | 128 | ); |
| 129 | 129 | } |
| 130 | - $preloadFile = realpath($appDir) . '/preload.php'; |
|
| 130 | + $preloadFile = realpath($appDir).'/preload.php'; |
|
| 131 | 131 | file_put_contents($preloadFile, $output); |
| 132 | 132 | |
| 133 | 133 | return $preloadFile; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $dir = (string) realpath($rootDir); |
| 139 | 139 | if (strpos($file, $dir) !== false) { |
| 140 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); |
|
| 140 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | return $file; |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | private function saveNamedParam(NamedParameterInterface $namedParameter, object $instance, string $method) : void |
| 184 | 184 | { |
| 185 | 185 | // named parameter |
| 186 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
| 186 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
| 187 | 187 | return; |
| 188 | 188 | } |
| 189 | 189 | $callable = [$instance, $method]; |
| 190 | - if (! is_callable($callable)) { |
|
| 190 | + if (!is_callable($callable)) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | try { |
@@ -213,12 +213,12 @@ discard block |
||
| 213 | 213 | $paths = []; |
| 214 | 214 | foreach ($classes as $class) { |
| 215 | 215 | // could be phpdoc tag by annotation loader |
| 216 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); |
|
| 216 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); |
|
| 217 | 217 | if ($isAutoloadFailed) { |
| 218 | 218 | continue; |
| 219 | 219 | } |
| 220 | 220 | $filePath = (string) (new ReflectionClass($class))->getFileName(); |
| 221 | - if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
| 221 | + if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
| 222 | 222 | continue; |
| 223 | 223 | } |
| 224 | 224 | $paths[] = $this->getRelativePath($appDir, $filePath); |