@@ -41,7 +41,7 @@ |
||
| 41 | 41 | { |
| 42 | 42 | $request = new RouterMatch; |
| 43 | 43 | list($request->method, $request->query) = $this->httpMethodParams->get($server, $globals['_GET'], $globals['_POST']); |
| 44 | - $request->path = $this->schemeHost . parse_url($server['REQUEST_URI'], PHP_URL_PATH); |
|
| 44 | + $request->path = $this->schemeHost.parse_url($server['REQUEST_URI'], PHP_URL_PATH); |
|
| 45 | 45 | |
| 46 | 46 | return $request; |
| 47 | 47 | } |
@@ -24,6 +24,6 @@ |
||
| 24 | 24 | { |
| 25 | 25 | $string = parent::__toString(); |
| 26 | 26 | |
| 27 | - return $string . $this->postBody; |
|
| 27 | + return $string.$this->postBody; |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | /** @var ResourceObject $ro */ |
| 31 | 31 | $ro = $invocation->proceed(); |
| 32 | 32 | $isCreated = $ro->code === 201 && isset($ro->headers['Location']); |
| 33 | - if (! $isCreated) { |
|
| 33 | + if (!$isCreated) { |
|
| 34 | 34 | return $ro; |
| 35 | 35 | } |
| 36 | 36 | $ro->setRenderer($this->renderer); |
@@ -59,6 +59,9 @@ |
||
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | + /** |
|
| 63 | + * @param string $method |
|
| 64 | + */ |
|
| 62 | 65 | private function isMagicMethod($method) : bool |
| 63 | 66 | { |
| 64 | 67 | return \in_array($method, ['__sleep', '__wakeup', 'offsetGet', 'offsetSet', 'offsetExists', 'offsetUnset', 'count', 'ksort', 'asort', 'jsonSerialize'], true); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $appMeta = new AppMeta($appName, $context, $appDir); |
| 46 | 46 | (new Unlink)->force($appMeta->tmpDir); |
| 47 | - $cacheNs = (string) filemtime($appMeta->appDir . '/src'); |
|
| 47 | + $cacheNs = (string) filemtime($appMeta->appDir.'/src'); |
|
| 48 | 48 | $injector = new AppInjector($appName, $context, $appMeta, $cacheNs); |
| 49 | 49 | $cache = $injector->getInstance(Cache::class); |
| 50 | 50 | $reader = $injector->getInstance(AnnotationReader::class); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | foreach ($appMeta->getResourceListGenerator() as list($className)) { |
| 60 | 60 | $this->scanClass($injector, $reader, $namedParams, $className); |
| 61 | 61 | } |
| 62 | - $logFile = realpath($appMeta->logDir) . '/compile.log'; |
|
| 62 | + $logFile = realpath($appMeta->logDir).'/compile.log'; |
|
| 63 | 63 | $this->saveCompileLog($appMeta, $context, $logFile); |
| 64 | 64 | |
| 65 | 65 | return $logFile; |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | private function compileLoader(string $appName, string $context, string $appDir) : string |
| 69 | 69 | { |
| 70 | - $loaderFile = $appDir . '/vendor/autoload.php'; |
|
| 71 | - if (! file_exists($loaderFile)) { |
|
| 70 | + $loaderFile = $appDir.'/vendor/autoload.php'; |
|
| 71 | + if (!file_exists($loaderFile)) { |
|
| 72 | 72 | return ''; |
| 73 | 73 | } |
| 74 | 74 | $loaderFile = require $loaderFile; |
| 75 | 75 | spl_autoload_register( |
| 76 | - function ($class) use ($loaderFile) { |
|
| 76 | + function($class) use ($loaderFile) { |
|
| 77 | 77 | $loaderFile->loadClass($class); |
| 78 | 78 | if ($class !== NullPage::class) { |
| 79 | 79 | $this->classes[] = $class; |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | $this->invokeTypicalRequest($appName, $context); |
| 87 | - $fies = '<?php' . PHP_EOL; |
|
| 87 | + $fies = '<?php'.PHP_EOL; |
|
| 88 | 88 | foreach ($this->classes as $class) { |
| 89 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); // could be phpdoc tag by anotation loader |
|
| 89 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); // could be phpdoc tag by anotation loader |
|
| 90 | 90 | if ($isAutoloadFailed) { |
| 91 | 91 | continue; |
| 92 | 92 | } |
| 93 | 93 | $filePath = (string) (new \ReflectionClass($class))->getFileName(); |
| 94 | - if (! file_exists($filePath) || substr($filePath, 0, 4) === 'phar') { |
|
| 94 | + if (!file_exists($filePath) || substr($filePath, 0, 4) === 'phar') { |
|
| 95 | 95 | continue; |
| 96 | 96 | } |
| 97 | 97 | $fies .= sprintf( |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | $this->getRelativePath($appDir, $filePath) |
| 100 | 100 | ); |
| 101 | 101 | } |
| 102 | - $fies .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; |
|
| 103 | - $loaderFile = realpath($appDir) . '/autoload.php'; |
|
| 102 | + $fies .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; |
|
| 103 | + $loaderFile = realpath($appDir).'/autoload.php'; |
|
| 104 | 104 | file_put_contents($loaderFile, $fies); |
| 105 | 105 | |
| 106 | 106 | return $loaderFile; |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | { |
| 111 | 111 | $dir = (string) realpath($rootDir); |
| 112 | 112 | if (strpos($file, $dir) !== false) { |
| 113 | - return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); |
|
| 113 | + return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - return "'" . $file; |
|
| 116 | + return "'".$file; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | private function invokeTypicalRequest(string $appName, string $context) |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | private function saveNamedParam(NamedParameterInterface $namedParameter, $instance, string $method) : void |
| 156 | 156 | { |
| 157 | 157 | // named parameter |
| 158 | - if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
| 158 | + if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { |
|
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | 161 | $callable = [$instance, $method]; |
| 162 | - if (! is_callable($callable)) { |
|
| 162 | + if (!is_callable($callable)) { |
|
| 163 | 163 | return; |
| 164 | 164 | } |
| 165 | 165 | try { |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | protected function configure() |
| 31 | 31 | { |
| 32 | 32 | $this->bind(AbstractAppMeta::class)->toInstance($this->appMeta); |
| 33 | - $this->bind(AppInterface::class)->to($this->appMeta->name . '\Module\App'); |
|
| 33 | + $this->bind(AppInterface::class)->to($this->appMeta->name.'\Module\App'); |
|
| 34 | 34 | $this->bind()->annotatedWith(AppName::class)->toInstance($this->appMeta->name); |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -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() |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct(AbstractAppMeta $appMeta, string $namespace) |
| 32 | 32 | { |
| 33 | - $this->cacheDir = $appMeta->tmpDir . '/cache'; |
|
| 33 | + $this->cacheDir = $appMeta->tmpDir.'/cache'; |
|
| 34 | 34 | $this->namespace = $namespace; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -54,17 +54,17 @@ discard block |
||
| 54 | 54 | $this->context = $context; |
| 55 | 55 | $this->appMeta = $appMeta instanceof AbstractAppMeta ? $appMeta : new Meta($name, $context); |
| 56 | 56 | $this->cacheSpace = $cacheSpace; |
| 57 | - $scriptDir = $this->appMeta->tmpDir . '/di'; |
|
| 58 | - ! \file_exists($scriptDir) && \mkdir($scriptDir); |
|
| 57 | + $scriptDir = $this->appMeta->tmpDir.'/di'; |
|
| 58 | + !\file_exists($scriptDir) && \mkdir($scriptDir); |
|
| 59 | 59 | $this->scriptDir = $scriptDir; |
| 60 | - $appDir = $this->appMeta->tmpDir . '/app'; |
|
| 61 | - ! \file_exists($appDir) && \mkdir($appDir); |
|
| 62 | - touch($appDir . '/.do_not_clear'); |
|
| 60 | + $appDir = $this->appMeta->tmpDir.'/app'; |
|
| 61 | + !\file_exists($appDir) && \mkdir($appDir); |
|
| 62 | + touch($appDir.'/.do_not_clear'); |
|
| 63 | 63 | $this->appDir = $appDir; |
| 64 | - $this->injector = new ScriptInjector($this->scriptDir, function () { |
|
| 64 | + $this->injector = new ScriptInjector($this->scriptDir, function() { |
|
| 65 | 65 | return $this->getModule(); |
| 66 | 66 | }); |
| 67 | - if (! $cacheSpace) { |
|
| 67 | + if (!$cacheSpace) { |
|
| 68 | 68 | $this->clear(); |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -90,16 +90,16 @@ discard block |
||
| 90 | 90 | if ((new Unlink)->once($this->appMeta->tmpDir)) { |
| 91 | 91 | return; |
| 92 | 92 | } |
| 93 | - ! is_dir($this->appMeta->tmpDir . '/di') && \mkdir($this->appMeta->tmpDir . '/di'); |
|
| 94 | - file_put_contents($this->scriptDir . ScriptInjector::MODULE, serialize($this->getModule())); |
|
| 93 | + !is_dir($this->appMeta->tmpDir.'/di') && \mkdir($this->appMeta->tmpDir.'/di'); |
|
| 94 | + file_put_contents($this->scriptDir.ScriptInjector::MODULE, serialize($this->getModule())); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function getCachedInstance($interface, $name = Name::ANY) |
| 98 | 98 | { |
| 99 | - $lockFile = $this->appMeta->appDir . '/composer.lock'; |
|
| 99 | + $lockFile = $this->appMeta->appDir.'/composer.lock'; |
|
| 100 | 100 | $this->cacheSpace .= file_exists($lockFile) ? (string) filemtime($lockFile) : ''; |
| 101 | 101 | $cache = new FilesystemCache($this->appDir); |
| 102 | - $id = $interface . $name . $this->context . $this->cacheSpace; |
|
| 102 | + $id = $interface.$name.$this->context.$this->cacheSpace; |
|
| 103 | 103 | $instance = $cache->fetch($id); |
| 104 | 104 | if ($instance) { |
| 105 | 105 | return $instance; |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | |
| 22 | 22 | public function toString() |
| 23 | 23 | { |
| 24 | - $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL; |
|
| 24 | + $this->view = json_encode($this->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL; |
|
| 25 | 25 | |
| 26 | 26 | return $this->view; |
| 27 | 27 | } |