@@ -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 Ray\Di\Exception\Unbound; |
19 | 18 | use function file_exists; |
20 | 19 | use Ray\Di\AbstractModule; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function compile() : int |
93 | 93 | { |
94 | - if (! is_dir($this->appDir)) { |
|
94 | + if (!is_dir($this->appDir)) { |
|
95 | 95 | throw new \RuntimeException($this->appDir); |
96 | 96 | } |
97 | 97 | $preload = $this->compilePreload($this->appMeta, $this->context); |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | |
133 | 133 | public function registerLoader(string $appDir) : void |
134 | 134 | { |
135 | - $loaderFile = $appDir . '/vendor/autoload.php'; |
|
136 | - if (! file_exists($loaderFile)) { |
|
135 | + $loaderFile = $appDir.'/vendor/autoload.php'; |
|
136 | + if (!file_exists($loaderFile)) { |
|
137 | 137 | throw new \RuntimeException('no loader'); |
138 | 138 | } |
139 | 139 | /** @var ClassLoader $loader */ |
140 | 140 | $loader = require $loaderFile; |
141 | 141 | spl_autoload_register( |
142 | 142 | /** @var class-string $class */ |
143 | - function (string $class) use ($loader) : void { |
|
143 | + function(string $class) use ($loader) : void { |
|
144 | 144 | $loader->loadClass($class); |
145 | 145 | if ($class !== NullPage::class) { |
146 | 146 | $this->classes[] = $class; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | private function saveAutoloadFile(string $appDir, array $paths) : string |
195 | 195 | { |
196 | - $autoloadFile = '<?php' . PHP_EOL . 'require __DIR__ . \'/vendor/ray/di/src/ProviderInterface.php\'; |
|
196 | + $autoloadFile = '<?php'.PHP_EOL.'require __DIR__ . \'/vendor/ray/di/src/ProviderInterface.php\'; |
|
197 | 197 | ' . PHP_EOL; |
198 | 198 | foreach ($paths as $path) { |
199 | 199 | $autoloadFile .= sprintf( |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | $this->getRelativePath($appDir, $path) |
202 | 202 | ); |
203 | 203 | } |
204 | - $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
205 | - $loaderFile = realpath($appDir) . '/autoload.php'; |
|
204 | + $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
205 | + $loaderFile = realpath($appDir).'/autoload.php'; |
|
206 | 206 | file_put_contents($loaderFile, $autoloadFile); |
207 | 207 | |
208 | 208 | return $loaderFile; |
@@ -212,15 +212,15 @@ discard block |
||
212 | 212 | { |
213 | 213 | $this->loadResources($appMeta->name, $context, $appMeta->appDir); |
214 | 214 | $paths = $this->getPaths($this->classes); |
215 | - $output = '<?php' . PHP_EOL; |
|
216 | - $output .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
215 | + $output = '<?php'.PHP_EOL; |
|
216 | + $output .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
217 | 217 | foreach ($paths as $path) { |
218 | 218 | $output .= sprintf( |
219 | 219 | "require_once '%s';\n", |
220 | 220 | $this->getRelativePath($appMeta->appDir, $path) |
221 | 221 | ); |
222 | 222 | } |
223 | - $preloadFile = realpath($appMeta->appDir) . '/preload.php'; |
|
223 | + $preloadFile = realpath($appMeta->appDir).'/preload.php'; |
|
224 | 224 | file_put_contents($preloadFile, $output); |
225 | 225 | |
226 | 226 | return $preloadFile; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | $dir = (string) realpath($rootDir); |
232 | 232 | if (strpos($file, $dir) !== false) { |
233 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); |
|
233 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | return $file; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $class = new \ReflectionClass($className); |
263 | 263 | /** @var T $instance */ |
264 | 264 | $instance = $class->newInstanceWithoutConstructor(); |
265 | - if (! $instance instanceof $className) { |
|
265 | + if (!$instance instanceof $className) { |
|
266 | 266 | return; |
267 | 267 | } |
268 | 268 | $reader->getClassAnnotations($class); |
@@ -292,11 +292,11 @@ discard block |
||
292 | 292 | private function saveNamedParam(NamedParameterInterface $namedParameter, object $instance, string $method) : void |
293 | 293 | { |
294 | 294 | // named parameter |
295 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
295 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
296 | 296 | return; |
297 | 297 | } |
298 | 298 | $callable = [$instance, $method]; |
299 | - if (! is_callable($callable)) { |
|
299 | + if (!is_callable($callable)) { |
|
300 | 300 | return; |
301 | 301 | } |
302 | 302 | try { |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | $paths = []; |
317 | 317 | foreach ($classes as $class) { |
318 | 318 | // could be phpdoc tag by annotation loader |
319 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); |
|
319 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); |
|
320 | 320 | if ($isAutoloadFailed) { |
321 | 321 | continue; |
322 | 322 | } |
323 | 323 | assert(class_exists($class) || interface_exists($class) || trait_exists($class)); |
324 | 324 | $filePath = (string) (new ReflectionClass($class))->getFileName(); |
325 | - if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
325 | + if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) { |
|
326 | 326 | continue; |
327 | 327 | } |
328 | 328 | $paths[] = $this->getRelativePath($this->appDir, $filePath); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | |
343 | 343 | private function getInstance(string $interface, string $name = '') : void |
344 | 344 | { |
345 | - $dependencyIndex = $interface . '-' . $name; |
|
345 | + $dependencyIndex = $interface.'-'.$name; |
|
346 | 346 | if (in_array($dependencyIndex, $this->compiled, true)) { |
347 | 347 | printf("S %s:%s\n", $interface, $name); |
348 | 348 |