@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $output = trim(join("\n", $output), "\n ,"); |
| 60 | 60 | |
| 61 | - if ($output !== '') { |
|
| 61 | + if ($output !== ''){ |
|
| 62 | 62 | $this->files->deleteDirectory($tmpDir); |
| 63 | 63 | throw new CompileException($output); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // copying files (using relative path and namespace) |
| 67 | 67 | $result = []; |
| 68 | - foreach ($this->files->getFiles($tmpDir) as $file) { |
|
| 68 | + foreach ($this->files->getFiles($tmpDir) as $file){ |
|
| 69 | 69 | $result[] = $this->copy($tmpDir, $file); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | private function copy(string $tmpDir, string $file): string |
| 83 | 83 | { |
| 84 | 84 | $source = ltrim($this->files->relativePath($file, $tmpDir), '\\/'); |
| 85 | - if (strpos($source, $this->baseNamespace) === 0) { |
|
| 85 | + if (strpos($source, $this->baseNamespace) === 0){ |
|
| 86 | 86 | $source = ltrim(substr($source, strlen($this->baseNamespace)), '\\/'); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - $target = $this->files->normalizePath($this->basePath . '/' . $source); |
|
| 89 | + $target = $this->files->normalizePath($this->basePath.'/'.$source); |
|
| 90 | 90 | |
| 91 | 91 | $this->files->ensureDirectory(dirname($target)); |
| 92 | 92 | $this->files->copy($file, $target); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | private function tmpDir(): string |
| 101 | 101 | { |
| 102 | - $directory = sys_get_temp_dir() . '/' . spl_object_hash($this); |
|
| 102 | + $directory = sys_get_temp_dir().'/'.spl_object_hash($this); |
|
| 103 | 103 | $this->files->ensureDirectory($directory); |
| 104 | 104 | |
| 105 | 105 | return $this->files->normalizePath($directory, true); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | private function getProtoFiles(string $protoFile): array |
| 115 | 115 | { |
| 116 | - return array_filter($this->files->getFiles(dirname($protoFile)), function ($file) { |
|
| 116 | + return array_filter($this->files->getFiles(dirname($protoFile)), function ($file){ |
|
| 117 | 117 | return strpos($file, '.proto') !== false; |
| 118 | 118 | }); |
| 119 | 119 | } |
@@ -58,14 +58,16 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $output = trim(join("\n", $output), "\n ,"); |
| 60 | 60 | |
| 61 | - if ($output !== '') { |
|
| 61 | + if ($output !== '') |
|
| 62 | + { |
|
| 62 | 63 | $this->files->deleteDirectory($tmpDir); |
| 63 | 64 | throw new CompileException($output); |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | 67 | // copying files (using relative path and namespace) |
| 67 | 68 | $result = []; |
| 68 | - foreach ($this->files->getFiles($tmpDir) as $file) { |
|
| 69 | + foreach ($this->files->getFiles($tmpDir) as $file) |
|
| 70 | + { |
|
| 69 | 71 | $result[] = $this->copy($tmpDir, $file); |
| 70 | 72 | } |
| 71 | 73 | |
@@ -82,7 +84,8 @@ discard block |
||
| 82 | 84 | private function copy(string $tmpDir, string $file): string |
| 83 | 85 | { |
| 84 | 86 | $source = ltrim($this->files->relativePath($file, $tmpDir), '\\/'); |
| 85 | - if (strpos($source, $this->baseNamespace) === 0) { |
|
| 87 | + if (strpos($source, $this->baseNamespace) === 0) |
|
| 88 | + { |
|
| 86 | 89 | $source = ltrim(substr($source, strlen($this->baseNamespace)), '\\/'); |
| 87 | 90 | } |
| 88 | 91 | |
@@ -113,7 +116,8 @@ discard block |
||
| 113 | 116 | */ |
| 114 | 117 | private function getProtoFiles(string $protoFile): array |
| 115 | 118 | { |
| 116 | - return array_filter($this->files->getFiles(dirname($protoFile)), function ($file) { |
|
| 119 | + return array_filter($this->files->getFiles(dirname($protoFile)), function ($file) |
|
| 120 | + { |
|
| 117 | 121 | return strpos($file, '.proto') !== false; |
| 118 | 122 | }); |
| 119 | 123 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | use Spiral\Debug\Dumper; |
| 11 | 11 | |
| 12 | -if (!function_exists('bind')) { |
|
| 12 | +if (!function_exists('bind')){ |
|
| 13 | 13 | /** |
| 14 | 14 | * Shortcut to container Autowire definition. |
| 15 | 15 | * |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -if (!function_exists('dumprr')) { |
|
| 30 | +if (!function_exists('dumprr')){ |
|
| 31 | 31 | /** |
| 32 | 32 | * Dumprr is similar to Dump function but always redirect output to STDERR. |
| 33 | 33 | * |
@@ -9,7 +9,8 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | use Spiral\Debug\Dumper; |
| 11 | 11 | |
| 12 | -if (!function_exists('bind')) { |
|
| 12 | +if (!function_exists('bind')) |
|
| 13 | +{ |
|
| 13 | 14 | /** |
| 14 | 15 | * Shortcut to container Autowire definition. |
| 15 | 16 | * |
@@ -27,7 +28,8 @@ discard block |
||
| 27 | 28 | } |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | -if (!function_exists('dumprr')) { |
|
| 31 | +if (!function_exists('dumprr')) |
|
| 32 | +{ |
|
| 31 | 33 | /** |
| 32 | 34 | * Dumprr is similar to Dump function but always redirect output to STDERR. |
| 33 | 35 | * |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | string $clientFilename = null, |
| 27 | 27 | string $clientMediaType = null |
| 28 | 28 | ): UploadedFileInterface { |
| 29 | - if ($size === null) { |
|
| 29 | + if ($size === null){ |
|
| 30 | 30 | $size = $stream->getSize(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -26,7 +26,8 @@ |
||
| 26 | 26 | string $clientFilename = null, |
| 27 | 27 | string $clientMediaType = null |
| 28 | 28 | ): UploadedFileInterface { |
| 29 | - if ($size === null) { |
|
| 29 | + if ($size === null) |
|
| 30 | + { |
|
| 30 | 31 | $size = $stream->getSize(); |
| 31 | 32 | } |
| 32 | 33 | |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
| 41 | 41 | $response = $response->withAddedHeader($header, $value); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -37,7 +37,8 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
| 41 | + { |
|
| 41 | 42 | $response = $response->withAddedHeader($header, $value); |
| 42 | 43 | } |
| 43 | 44 | |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | |
| 67 | 67 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 68 | 68 | |
| 69 | - if (class_exists(PSR7Client::class)) { |
|
| 69 | + if (class_exists(PSR7Client::class)){ |
|
| 70 | 70 | $kernel->addDispatcher($factory->make(RrDispacher::class)); |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -66,7 +66,8 @@ |
||
| 66 | 66 | |
| 67 | 67 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 68 | 68 | |
| 69 | - if (class_exists(PSR7Client::class)) { |
|
| 69 | + if (class_exists(PSR7Client::class)) |
|
| 70 | + { |
|
| 70 | 71 | $kernel->addDispatcher($factory->make(RrDispacher::class)); |
| 71 | 72 | } |
| 72 | 73 | } |
@@ -40,21 +40,21 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
| 42 | 42 | |
| 43 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 43 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
| 44 | 44 | throw new BootException( |
| 45 | 45 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 46 | 46 | ); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 49 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
| 50 | 50 | throw new BootException( |
| 51 | 51 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 52 | 52 | ); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ($parts[1] == 'unix') { |
|
| 55 | + if ($parts[1] == 'unix'){ |
|
| 56 | 56 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 57 | - } else { |
|
| 57 | + }else{ |
|
| 58 | 58 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -69,25 +69,25 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $conn = $env->get('RR_RELAY', static::WORKER_DEFAULT); |
| 71 | 71 | |
| 72 | - if ($conn === 'pipes' || empty($conn)) { |
|
| 72 | + if ($conn === 'pipes' || empty($conn)){ |
|
| 73 | 73 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 76 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
| 77 | 77 | throw new BootException( |
| 78 | 78 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 79 | 79 | ); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 82 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
| 83 | 83 | throw new BootException( |
| 84 | 84 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ($parts[1] == 'unix') { |
|
| 88 | + if ($parts[1] == 'unix'){ |
|
| 89 | 89 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 90 | - } else { |
|
| 90 | + }else{ |
|
| 91 | 91 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -40,21 +40,26 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
| 42 | 42 | |
| 43 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 43 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
| 44 | + { |
|
| 44 | 45 | throw new BootException( |
| 45 | 46 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 46 | 47 | ); |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 50 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
| 51 | + { |
|
| 50 | 52 | throw new BootException( |
| 51 | 53 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 52 | 54 | ); |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | - if ($parts[1] == 'unix') { |
|
| 57 | + if ($parts[1] == 'unix') |
|
| 58 | + { |
|
| 56 | 59 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 57 | - } else { |
|
| 60 | + } |
|
| 61 | + else |
|
| 62 | + { |
|
| 58 | 63 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 59 | 64 | } |
| 60 | 65 | |
@@ -69,25 +74,31 @@ discard block |
||
| 69 | 74 | { |
| 70 | 75 | $conn = $env->get('RR_RELAY', static::WORKER_DEFAULT); |
| 71 | 76 | |
| 72 | - if ($conn === 'pipes' || empty($conn)) { |
|
| 77 | + if ($conn === 'pipes' || empty($conn)) |
|
| 78 | + { |
|
| 73 | 79 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
| 74 | 80 | } |
| 75 | 81 | |
| 76 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 82 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
| 83 | + { |
|
| 77 | 84 | throw new BootException( |
| 78 | 85 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 79 | 86 | ); |
| 80 | 87 | } |
| 81 | 88 | |
| 82 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 89 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
| 90 | + { |
|
| 83 | 91 | throw new BootException( |
| 84 | 92 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 85 | 93 | ); |
| 86 | 94 | } |
| 87 | 95 | |
| 88 | - if ($parts[1] == 'unix') { |
|
| 96 | + if ($parts[1] == 'unix') |
|
| 97 | + { |
|
| 89 | 98 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 90 | - } else { |
|
| 99 | + } |
|
| 100 | + else |
|
| 101 | + { |
|
| 91 | 102 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 92 | 103 | } |
| 93 | 104 | |
@@ -17,10 +17,10 @@ |
||
| 17 | 17 | public function makeApp(array $env = []): TestApp |
| 18 | 18 | { |
| 19 | 19 | return TestApp::init([ |
| 20 | - 'root' => __DIR__ . '/../..', |
|
| 21 | - 'app' => __DIR__ . '/../app', |
|
| 22 | - 'runtime' => sys_get_temp_dir() . '/spiral', |
|
| 23 | - 'cache' => sys_get_temp_dir() . '/spiral', |
|
| 20 | + 'root' => __DIR__.'/../..', |
|
| 21 | + 'app' => __DIR__.'/../app', |
|
| 22 | + 'runtime' => sys_get_temp_dir().'/spiral', |
|
| 23 | + 'cache' => sys_get_temp_dir().'/spiral', |
|
| 24 | 24 | ], new Environment($env), false); |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -37,8 +37,8 @@ |
||
| 37 | 37 | public function locateCommands(): array |
| 38 | 38 | { |
| 39 | 39 | $commands = []; |
| 40 | - foreach ($this->classes->getClasses(SymfonyCommand::class) as $class) { |
|
| 41 | - if ($class->isAbstract()) { |
|
| 40 | + foreach ($this->classes->getClasses(SymfonyCommand::class) as $class){ |
|
| 41 | + if ($class->isAbstract()){ |
|
| 42 | 42 | continue; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -37,8 +37,10 @@ |
||
| 37 | 37 | public function locateCommands(): array |
| 38 | 38 | { |
| 39 | 39 | $commands = []; |
| 40 | - foreach ($this->classes->getClasses(SymfonyCommand::class) as $class) { |
|
| 41 | - if ($class->isAbstract()) { |
|
| 40 | + foreach ($this->classes->getClasses(SymfonyCommand::class) as $class) |
|
| 41 | + { |
|
| 42 | + if ($class->isAbstract()) |
|
| 43 | + { |
|
| 42 | 44 | continue; |
| 43 | 45 | } |
| 44 | 46 | |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | string $mergeMode = self::FOLLOW, |
| 46 | 46 | int $mode = FilesInterface::READONLY |
| 47 | 47 | ): void { |
| 48 | - if (!$this->files->isFile($filename)) { |
|
| 48 | + if (!$this->files->isFile($filename)){ |
|
| 49 | 49 | throw new PublishException("Given '{$filename}' is not valid file"); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if ($this->files->exists($destination)) { |
|
| 53 | - if ($this->files->md5($destination) == $this->files->md5($filename)) { |
|
| 52 | + if ($this->files->exists($destination)){ |
|
| 53 | + if ($this->files->md5($destination) == $this->files->md5($filename)){ |
|
| 54 | 54 | //Nothing to do |
| 55 | 55 | return; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ($mergeMode == self::FOLLOW) { |
|
| 58 | + if ($mergeMode == self::FOLLOW){ |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | string $mergeMode = self::REPLACE, |
| 78 | 78 | int $mode = FilesInterface::READONLY |
| 79 | 79 | ): void { |
| 80 | - if (!$this->files->isDirectory($directory)) { |
|
| 80 | + if (!$this->files->isDirectory($directory)){ |
|
| 81 | 81 | throw new PublishException("Given '{$directory}' is not valid directory"); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | /** |
| 88 | 88 | * @var SplFileInfo $file |
| 89 | 89 | */ |
| 90 | - foreach ($finder->getIterator() as $file) { |
|
| 90 | + foreach ($finder->getIterator() as $file){ |
|
| 91 | 91 | $this->publish( |
| 92 | 92 | (string)$file, |
| 93 | - $destination . '/' . $file->getRelativePathname(), |
|
| 93 | + $destination.'/'.$file->getRelativePathname(), |
|
| 94 | 94 | $mergeMode, |
| 95 | 95 | $mode |
| 96 | 96 | ); |
@@ -45,17 +45,21 @@ discard block |
||
| 45 | 45 | string $mergeMode = self::FOLLOW, |
| 46 | 46 | int $mode = FilesInterface::READONLY |
| 47 | 47 | ): void { |
| 48 | - if (!$this->files->isFile($filename)) { |
|
| 48 | + if (!$this->files->isFile($filename)) |
|
| 49 | + { |
|
| 49 | 50 | throw new PublishException("Given '{$filename}' is not valid file"); |
| 50 | 51 | } |
| 51 | 52 | |
| 52 | - if ($this->files->exists($destination)) { |
|
| 53 | - if ($this->files->md5($destination) == $this->files->md5($filename)) { |
|
| 53 | + if ($this->files->exists($destination)) |
|
| 54 | + { |
|
| 55 | + if ($this->files->md5($destination) == $this->files->md5($filename)) |
|
| 56 | + { |
|
| 54 | 57 | //Nothing to do |
| 55 | 58 | return; |
| 56 | 59 | } |
| 57 | 60 | |
| 58 | - if ($mergeMode == self::FOLLOW) { |
|
| 61 | + if ($mergeMode == self::FOLLOW) |
|
| 62 | + { |
|
| 59 | 63 | return; |
| 60 | 64 | } |
| 61 | 65 | } |
@@ -77,7 +81,8 @@ discard block |
||
| 77 | 81 | string $mergeMode = self::REPLACE, |
| 78 | 82 | int $mode = FilesInterface::READONLY |
| 79 | 83 | ): void { |
| 80 | - if (!$this->files->isDirectory($directory)) { |
|
| 84 | + if (!$this->files->isDirectory($directory)) |
|
| 85 | + { |
|
| 81 | 86 | throw new PublishException("Given '{$directory}' is not valid directory"); |
| 82 | 87 | } |
| 83 | 88 | |
@@ -87,7 +92,8 @@ discard block |
||
| 87 | 92 | /** |
| 88 | 93 | * @var SplFileInfo $file |
| 89 | 94 | */ |
| 90 | - foreach ($finder->getIterator() as $file) { |
|
| 95 | + foreach ($finder->getIterator() as $file) |
|
| 96 | + { |
|
| 91 | 97 | $this->publish( |
| 92 | 98 | (string)$file, |
| 93 | 99 | $destination . '/' . $file->getRelativePathname(), |