@@ -22,10 +22,10 @@ |
||
22 | 22 | |
23 | 23 | public function __invoke(string $path) |
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 | } |
@@ -30,10 +30,10 @@ |
||
30 | 30 | |
31 | 31 | public function newApp(AbstractAppMeta $appMeta, string $contexts, Cache $cache = null, string $cacheNamespace = null) : AbstractApp |
32 | 32 | { |
33 | - $cacheNamespace = is_string($cacheNamespace) ? $cacheNamespace : (string) filemtime($appMeta->appDir . '/src'); |
|
33 | + $cacheNamespace = is_string($cacheNamespace) ? $cacheNamespace : (string) filemtime($appMeta->appDir.'/src'); |
|
34 | 34 | $injector = new AppInjector($appMeta->name, $contexts, $appMeta, $cacheNamespace); |
35 | 35 | $cache = $cache instanceof Cache ? $cache : $injector->getCachedInstance(Cache::class); |
36 | - $appId = $appMeta->name . $contexts . $cacheNamespace; |
|
36 | + $appId = $appMeta->name.$contexts.$cacheNamespace; |
|
37 | 37 | $app = $cache->fetch($appId); |
38 | 38 | if ($app instanceof AbstractApp) { |
39 | 39 | return $app; |
@@ -39,11 +39,11 @@ |
||
39 | 39 | $output = $isModified ? $this->getOutput($ro, $server) : $this->condResponse->getOutput($ro->headers); |
40 | 40 | |
41 | 41 | $statusText = (new Code)->statusText[$ro->code] ?? ''; |
42 | - $ob = $output->code . ' ' . $statusText . PHP_EOL; |
|
42 | + $ob = $output->code.' '.$statusText.PHP_EOL; |
|
43 | 43 | |
44 | 44 | // header |
45 | 45 | foreach ($output->headers as $label => $value) { |
46 | - $ob .= "{$label}: {$value}" . PHP_EOL; |
|
46 | + $ob .= "{$label}: {$value}".PHP_EOL; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | // empty line |
@@ -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) { |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | if ((new Unlink)->once($this->appMeta->tmpDir)) { |
93 | 93 | return; |
94 | 94 | } |
95 | - $diDir = $this->appMeta->tmpDir . '/di'; |
|
96 | - ! is_dir($diDir) && ! mkdir($diDir) && ! is_dir($diDir); |
|
97 | - file_put_contents($this->scriptDir . ScriptInjector::MODULE, serialize($this->getModule())); |
|
95 | + $diDir = $this->appMeta->tmpDir.'/di'; |
|
96 | + !is_dir($diDir) && !mkdir($diDir) && !is_dir($diDir); |
|
97 | + file_put_contents($this->scriptDir.ScriptInjector::MODULE, serialize($this->getModule())); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | public function getCachedInstance(string $interface, $name = Name::ANY) |
101 | 101 | { |
102 | 102 | $cache = new FilesystemCache($this->appDir); |
103 | - $id = $interface . $name . $this->context . $this->cacheNamespace; |
|
103 | + $id = $interface.$name.$this->context.$this->cacheNamespace; |
|
104 | 104 | $instance = $cache->fetch($id); |
105 | 105 | if ($instance) { |
106 | 106 | return $instance; |
@@ -36,7 +36,7 @@ |
||
36 | 36 | { |
37 | 37 | $request = new RouterMatch; |
38 | 38 | [$request->method, $request->query] = $this->httpMethodParams->get($server, $globals['_GET'], $globals['_POST']); |
39 | - $request->path = $this->schemeHost . parse_url($server['REQUEST_URI'], 5); // 5 = PHP_URL_PATH |
|
39 | + $request->path = $this->schemeHost.parse_url($server['REQUEST_URI'], 5); // 5 = PHP_URL_PATH |
|
40 | 40 | |
41 | 41 | return $request; |
42 | 42 | } |
@@ -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 | } |
@@ -44,20 +44,20 @@ discard block |
||
44 | 44 | $autoload = $this->compileAutoload($appName, $context, $appDir); |
45 | 45 | $preload = $this->compilePreload($appDir); |
46 | 46 | $log = $this->compileDiScripts($appName, $context, $appDir); |
47 | - $this->ns = (string) filemtime(realpath($appDir) . '/src'); |
|
47 | + $this->ns = (string) filemtime(realpath($appDir).'/src'); |
|
48 | 48 | |
49 | 49 | return sprintf("Compile Log: %s\nautoload.php: %s\npreload.php: %s", $log, $autoload, $preload); |
50 | 50 | } |
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; |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | private function compilePreload(string $appDir) : string |
119 | 119 | { |
120 | 120 | $paths = $this->getPaths($this->classes, $appDir); |
121 | - $output = '<?php' . PHP_EOL; |
|
122 | - $output .= "opcache_compile_file(__DIR__ . '/vendor/autoload.php');" . PHP_EOL; |
|
121 | + $output = '<?php'.PHP_EOL; |
|
122 | + $output .= "opcache_compile_file(__DIR__ . '/vendor/autoload.php');".PHP_EOL; |
|
123 | 123 | foreach ($paths as $path) { |
124 | 124 | $output .= sprintf( |
125 | 125 | "opcache_compile_file(%s');\n", |
126 | 126 | $this->getRelativePath($appDir, $path) |
127 | 127 | ); |
128 | 128 | } |
129 | - $preloadFile = realpath($appDir) . '/preload.php'; |
|
129 | + $preloadFile = realpath($appDir).'/preload.php'; |
|
130 | 130 | file_put_contents($preloadFile, $output); |
131 | 131 | |
132 | 132 | return $preloadFile; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | { |
137 | 137 | $dir = (string) realpath($rootDir); |
138 | 138 | if (strpos($file, $dir) !== false) { |
139 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); |
|
139 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return $file; |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | private function saveNamedParam(NamedParameterInterface $namedParameter, $instance, string $method) : void |
183 | 183 | { |
184 | 184 | // named parameter |
185 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
185 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | $callable = [$instance, $method]; |
189 | - if (! is_callable($callable)) { |
|
189 | + if (!is_callable($callable)) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | try { |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | $paths = []; |
213 | 213 | foreach ($classes as $class) { |
214 | 214 | // could be phpdoc tag by annotation loader |
215 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); |
|
215 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); |
|
216 | 216 | if ($isAutoloadFailed) { |
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | $filePath = (string) (new ReflectionClass($class))->getFileName(); |
220 | - if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
220 | + if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | $paths[] = $this->getRelativePath($appDir, $filePath); |