@@ -38,15 +38,15 @@ |
||
38 | 38 | public function getServices(): array |
39 | 39 | { |
40 | 40 | $result = []; |
41 | - foreach ($this->classes->getClasses(ServiceInterface::class) as $service) { |
|
42 | - if (!$service->isInstantiable()) { |
|
41 | + foreach ($this->classes->getClasses(ServiceInterface::class) as $service){ |
|
42 | + if (!$service->isInstantiable()){ |
|
43 | 43 | continue; |
44 | 44 | } |
45 | 45 | |
46 | 46 | $instance = $this->container->get($service->getName()); |
47 | 47 | |
48 | - foreach ($service->getInterfaces() as $interface) { |
|
49 | - if ($interface->isSubclassOf(ServiceInterface::class)) { |
|
48 | + foreach ($service->getInterfaces() as $interface){ |
|
49 | + if ($interface->isSubclassOf(ServiceInterface::class)){ |
|
50 | 50 | $result[$interface->getName()] = $instance; |
51 | 51 | } |
52 | 52 | } |
@@ -38,15 +38,19 @@ |
||
38 | 38 | public function getServices(): array |
39 | 39 | { |
40 | 40 | $result = []; |
41 | - foreach ($this->classes->getClasses(ServiceInterface::class) as $service) { |
|
42 | - if (!$service->isInstantiable()) { |
|
41 | + foreach ($this->classes->getClasses(ServiceInterface::class) as $service) |
|
42 | + { |
|
43 | + if (!$service->isInstantiable()) |
|
44 | + { |
|
43 | 45 | continue; |
44 | 46 | } |
45 | 47 | |
46 | 48 | $instance = $this->container->get($service->getName()); |
47 | 49 | |
48 | - foreach ($service->getInterfaces() as $interface) { |
|
49 | - if ($interface->isSubclassOf(ServiceInterface::class)) { |
|
50 | + foreach ($service->getInterfaces() as $interface) |
|
51 | + { |
|
52 | + if ($interface->isSubclassOf(ServiceInterface::class)) |
|
53 | + { |
|
50 | 54 | $result[$interface->getName()] = $instance; |
51 | 55 | } |
52 | 56 | } |
@@ -29,7 +29,8 @@ discard block |
||
29 | 29 | parent::tearDown(); |
30 | 30 | ini_set('error_log', 'stderr'); |
31 | 31 | |
32 | - if (file_exists(__DIR__ . '/err.log')) { |
|
32 | + if (file_exists(__DIR__ . '/err.log')) |
|
33 | + { |
|
33 | 34 | unlink(__DIR__ . '/err.log'); |
34 | 35 | } |
35 | 36 | } |
@@ -56,7 +57,8 @@ discard block |
||
56 | 57 | ); |
57 | 58 | |
58 | 59 | $psr->shouldReceive('respond')->once()->with( |
59 | - \Mockery::on(function ($r) { |
|
60 | + \Mockery::on(function ($r) |
|
61 | + { |
|
60 | 62 | $this->assertSame('Hello, dave.', (string)$r->getBody()); |
61 | 63 | return true; |
62 | 64 | }) |
@@ -78,7 +80,8 @@ discard block |
||
78 | 80 | ); |
79 | 81 | |
80 | 82 | $psr->shouldReceive('respond')->once()->with( |
81 | - \Mockery::on(function ($r) { |
|
83 | + \Mockery::on(function ($r) |
|
84 | + { |
|
82 | 85 | $this->assertContains('500', (string)$r->getBody()); |
83 | 86 | return true; |
84 | 87 | }) |
@@ -116,7 +119,8 @@ discard block |
||
116 | 119 | ); |
117 | 120 | |
118 | 121 | $psr->shouldReceive('respond')->once()->with( |
119 | - \Mockery::on(function ($r) { |
|
122 | + \Mockery::on(function ($r) |
|
123 | + { |
|
120 | 124 | $this->assertContains('undefined', (string)$r->getBody()); |
121 | 125 | return true; |
122 | 126 | }) |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function setUp(): void |
25 | 25 | { |
26 | 26 | parent::setUp(); |
27 | - ini_set('error_log', __DIR__ . '/err.log'); |
|
27 | + ini_set('error_log', __DIR__.'/err.log'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function tearDown(): void |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | parent::tearDown(); |
33 | 33 | ini_set('error_log', 'stderr'); |
34 | 34 | |
35 | - if (file_exists(__DIR__ . '/err.log')) { |
|
36 | - unlink(__DIR__ . '/err.log'); |
|
35 | + if (file_exists(__DIR__.'/err.log')){ |
|
36 | + unlink(__DIR__.'/err.log'); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ); |
60 | 60 | |
61 | 61 | $psr->shouldReceive('respond')->once()->with( |
62 | - \Mockery::on(function ($r) { |
|
62 | + \Mockery::on(function ($r){ |
|
63 | 63 | $this->assertSame('Hello, dave.', (string)$r->getBody()); |
64 | 64 | return true; |
65 | 65 | }) |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ); |
82 | 82 | |
83 | 83 | $psr->shouldReceive('respond')->once()->with( |
84 | - \Mockery::on(function ($r) { |
|
84 | + \Mockery::on(function ($r){ |
|
85 | 85 | $this->assertContains('500', (string)$r->getBody()); |
86 | 86 | return true; |
87 | 87 | }) |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $psr->shouldReceive('acceptRequest')->once()->andReturn(null); |
91 | 91 | |
92 | 92 | $files = $this->app->get(FilesInterface::class)->getFiles( |
93 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
93 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
94 | 94 | ); |
95 | 95 | |
96 | 96 | $this->assertCount(0, $files); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $this->app->get(RrDispacher::class)->serve($psr); |
99 | 99 | |
100 | 100 | $files = $this->app->get(FilesInterface::class)->getFiles( |
101 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
101 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
102 | 102 | ); |
103 | 103 | |
104 | 104 | $this->assertCount(1, $files); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | ); |
120 | 120 | |
121 | 121 | $psr->shouldReceive('respond')->once()->with( |
122 | - \Mockery::on(function ($r) { |
|
122 | + \Mockery::on(function ($r){ |
|
123 | 123 | $this->assertContains('undefined', (string)$r->getBody()); |
124 | 124 | return true; |
125 | 125 | }) |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $psr->shouldReceive('acceptRequest')->once()->andReturn(null); |
129 | 129 | |
130 | 130 | $files = $this->app->get(FilesInterface::class)->getFiles( |
131 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
131 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | $this->assertCount(0, $files); |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | $this->app->get(RrDispacher::class)->serve($psr); |
137 | 137 | |
138 | 138 | $files = $this->app->get(FilesInterface::class)->getFiles( |
139 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
139 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
140 | 140 | ); |
141 | 141 | |
142 | 142 | $this->assertCount(1, $files); |
143 | 143 | |
144 | - $this->assertContains('undefined', file_get_contents(__DIR__ . '/err.log')); |
|
144 | + $this->assertContains('undefined', file_get_contents(__DIR__.'/err.log')); |
|
145 | 145 | } |
146 | 146 | } |
@@ -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 | * |
@@ -41,7 +41,8 @@ |
||
41 | 41 | |
42 | 42 | $memory->saveData('cycle', $schema); |
43 | 43 | |
44 | - if ($show->hasChanges()) { |
|
44 | + if ($show->hasChanges()) |
|
45 | + { |
|
45 | 46 | $this->writeln("\n<info>ORM Schema has been synchronized</info>"); |
46 | 47 | } |
47 | 48 |
@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | $memory->saveData('cycle', $schema); |
51 | 51 | |
52 | - if ($show->hasChanges()) { |
|
52 | + if ($show->hasChanges()){ |
|
53 | 53 | $this->writeln("\n<info>ORM Schema has been synchronized</info>"); |
54 | 54 | } |
55 | 55 |
@@ -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 |