| @@ -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 | } | 
| @@ -40,7 +40,7 @@ discard block | ||
| 40 | 40 | |
| 41 | 41 | public function addHalLink(array $body, array $methodAnnotations, Hal $hal) : Hal | 
| 42 | 42 |      { | 
| 43 | -        if (! empty($methodAnnotations)) { | |
| 43 | +        if (!empty($methodAnnotations)) { | |
| 44 | 44 | $hal = $this->linkAnnotation($body, $methodAnnotations, $hal); | 
| 45 | 45 | } | 
| 46 | 46 |          if (isset($body['_links'])) { | 
| @@ -53,7 +53,7 @@ discard block | ||
| 53 | 53 | private function linkAnnotation(array $body, array $methodAnnotations, Hal $hal) : Hal | 
| 54 | 54 |      { | 
| 55 | 55 |          foreach ($methodAnnotations as $annotation) { | 
| 56 | -            if (! $annotation instanceof Link) { | |
| 56 | +            if (!$annotation instanceof Link) { | |
| 57 | 57 | continue; | 
| 58 | 58 | } | 
| 59 | 59 | $uri = uri_template($annotation->href, $body); | 
| @@ -22,6 +22,9 @@ | ||
| 22 | 22 | $this->router = $router; | 
| 23 | 23 | } | 
| 24 | 24 | |
| 25 | + /** | |
| 26 | + * @param string $uri | |
| 27 | + */ | |
| 25 | 28 | public function getReverseLink($uri) : string | 
| 26 | 29 |      { | 
| 27 | 30 | $urlParts = parse_url($uri); | 
| @@ -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); | 
| @@ -42,7 +42,7 @@ discard block | ||
| 42 | 42 |      { | 
| 43 | 43 | $appMeta = new AppMeta($appName, $context, $appDir); | 
| 44 | 44 | (new Unlink)->force($appMeta->tmpDir); | 
| 45 | - $cacheNs = (string) filemtime($appMeta->appDir . '/src'); | |
| 45 | + $cacheNs = (string) filemtime($appMeta->appDir.'/src'); | |
| 46 | 46 | $injector = new AppInjector($appName, $context, $appMeta, $cacheNs); | 
| 47 | 47 | $cache = $injector->getInstance(Cache::class); | 
| 48 | 48 | $reader = $injector->getInstance(AnnotationReader::class); | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 |          foreach ($appMeta->getResourceListGenerator() as list($className)) { | 
| 58 | 58 | $this->scanClass($injector, $reader, $namedParams, $className); | 
| 59 | 59 | } | 
| 60 | - $logFile = realpath($appMeta->logDir) . '/compile.log'; | |
| 60 | + $logFile = realpath($appMeta->logDir).'/compile.log'; | |
| 61 | 61 | $this->saveCompileLog($appMeta, $context, $logFile); | 
| 62 | 62 | |
| 63 | 63 | return $logFile; | 
| @@ -65,13 +65,13 @@ discard block | ||
| 65 | 65 | |
| 66 | 66 | private function compileLoader(string $appName, string $context, string $appDir) : string | 
| 67 | 67 |      { | 
| 68 | - $loaderFile = $appDir . '/vendor/autoload.php'; | |
| 69 | -        if (! file_exists($loaderFile)) { | |
| 68 | + $loaderFile = $appDir.'/vendor/autoload.php'; | |
| 69 | +        if (!file_exists($loaderFile)) { | |
| 70 | 70 | return ''; | 
| 71 | 71 | } | 
| 72 | 72 | $loaderFile = require $loaderFile; | 
| 73 | 73 | spl_autoload_register( | 
| 74 | -            function ($class) use ($loaderFile) { | |
| 74 | +            function($class) use ($loaderFile) { | |
| 75 | 75 | $loaderFile->loadClass($class); | 
| 76 | 76 |                  if ($class !== NullPage::class) { | 
| 77 | 77 | $this->classes[] = $class; | 
| @@ -82,9 +82,9 @@ discard block | ||
| 82 | 82 | ); | 
| 83 | 83 | |
| 84 | 84 | $this->invokeTypicalReuqest($appName, $context); | 
| 85 | - $fies = '<?php declare(strict_types=1);' . PHP_EOL; | |
| 85 | + $fies = '<?php declare(strict_types=1);'.PHP_EOL; | |
| 86 | 86 |          foreach ($this->classes as $class) { | 
| 87 | - $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false); // could be phpdoc tag by anotation loader | |
| 87 | + $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false); // could be phpdoc tag by anotation loader | |
| 88 | 88 |              if ($isAutoloadFailed) { | 
| 89 | 89 | continue; | 
| 90 | 90 | } | 
| @@ -93,8 +93,8 @@ discard block | ||
| 93 | 93 | $this->getRelativePath($appDir, (new \ReflectionClass($class))->getFileName()) | 
| 94 | 94 | ); | 
| 95 | 95 | } | 
| 96 | - $fies .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL; | |
| 97 | - $loaderFile = realpath($appDir) . '/autoload.php'; | |
| 96 | + $fies .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL; | |
| 97 | + $loaderFile = realpath($appDir).'/autoload.php'; | |
| 98 | 98 | file_put_contents($loaderFile, $fies); | 
| 99 | 99 | |
| 100 | 100 | return $loaderFile; | 
| @@ -104,10 +104,10 @@ discard block | ||
| 104 | 104 |      { | 
| 105 | 105 | $dir = realpath($rootDir); | 
| 106 | 106 |          if (strpos($file, $dir) !== false) { | 
| 107 | -            return preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file); | |
| 107 | +            return preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file); | |
| 108 | 108 | } | 
| 109 | 109 | |
| 110 | - return "'" . $file; | |
| 110 | + return "'".$file; | |
| 111 | 111 | } | 
| 112 | 112 | |
| 113 | 113 | private function invokeTypicalReuqest(string $appName, string $context) | 
| @@ -149,7 +149,7 @@ discard block | ||
| 149 | 149 | private function saveNamedParam(NamedParameterInterface $namedParameter, $instance, string $method) | 
| 150 | 150 |      { | 
| 151 | 151 | // named parameter | 
| 152 | -        if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { | |
| 152 | +        if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) { | |
| 153 | 153 | return; | 
| 154 | 154 | } | 
| 155 | 155 |          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 | } | 
| @@ -28,6 +28,6 @@ | ||
| 28 | 28 | */ | 
| 29 | 29 | public function get() | 
| 30 | 30 |      { | 
| 31 | - return new Logger($this->appMeta->name, [new StreamHandler($this->appMeta->logDir . '/app.log', Logger::DEBUG)]); | |
| 31 | + return new Logger($this->appMeta->name, [new StreamHandler($this->appMeta->logDir.'/app.log', Logger::DEBUG)]); | |
| 32 | 32 | } | 
| 33 | 33 | } | 
| @@ -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 | |