@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
33 | 33 | { |
34 | - if (!$this->targetAcceptable($source)) { |
|
34 | + if (!$this->targetAcceptable($source)){ |
|
35 | 35 | return null; |
36 | 36 | } |
37 | 37 | |
38 | - if ($specification instanceof Specification\Filter\Postgres\ILike) { |
|
38 | + if ($specification instanceof Specification\Filter\Postgres\ILike){ |
|
39 | 39 | return $source->where( |
40 | 40 | $specification->getExpression(), |
41 | 41 | 'ILIKE', |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | class_exists(SelectQuery::class) |
57 | 57 | && $target instanceof SelectQuery |
58 | 58 | && $target->getDriver() instanceof PostgresDriver |
59 | - ) { |
|
59 | + ){ |
|
60 | 60 | return true; |
61 | 61 | } |
62 | 62 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | class_exists(Select::class) |
65 | 65 | && $target instanceof Select |
66 | 66 | && $target->buildQuery()->getDriver() instanceof PostgresDriver |
67 | - ) { |
|
67 | + ){ |
|
68 | 68 | return true; |
69 | 69 | } |
70 | 70 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | protected function fetchValue($value) |
81 | 81 | { |
82 | - if ($value instanceof Specification\ValueInterface) { |
|
82 | + if ($value instanceof Specification\ValueInterface){ |
|
83 | 83 | throw new CompilerException('Value expects user input, none given'); |
84 | 84 | } |
85 | 85 |
@@ -31,11 +31,13 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function write($source, SpecificationInterface $specification, Compiler $compiler) |
33 | 33 | { |
34 | - if (!$this->targetAcceptable($source)) { |
|
34 | + if (!$this->targetAcceptable($source)) |
|
35 | + { |
|
35 | 36 | return null; |
36 | 37 | } |
37 | 38 | |
38 | - if ($specification instanceof Specification\Filter\Postgres\ILike) { |
|
39 | + if ($specification instanceof Specification\Filter\Postgres\ILike) |
|
40 | + { |
|
39 | 41 | return $source->where( |
40 | 42 | $specification->getExpression(), |
41 | 43 | 'ILIKE', |
@@ -79,7 +81,8 @@ discard block |
||
79 | 81 | */ |
80 | 82 | protected function fetchValue($value) |
81 | 83 | { |
82 | - if ($value instanceof Specification\ValueInterface) { |
|
84 | + if ($value instanceof Specification\ValueInterface) |
|
85 | + { |
|
83 | 86 | throw new CompilerException('Value expects user input, none given'); |
84 | 87 | } |
85 | 88 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | $core = TestCore::init([ |
25 | 25 | 'root' => __DIR__, |
26 | - 'config' => __DIR__ . '/config' |
|
26 | + 'config' => __DIR__.'/config' |
|
27 | 27 | ]); |
28 | 28 | |
29 | 29 | /** @var TestConfig $config */ |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $core = TestCore::init([ |
38 | 38 | 'root' => __DIR__, |
39 | - 'config' => __DIR__ . '/config', |
|
39 | + 'config' => __DIR__.'/config', |
|
40 | 40 | ]); |
41 | 41 | |
42 | 42 | /** @var ConfiguratorInterface $config */ |
@@ -59,7 +59,7 @@ |
||
59 | 59 | |
60 | 60 | public function addLoader(string $ext, FileLoaderInterface $loader): void |
61 | 61 | { |
62 | - if (!isset($this->loaders[$ext]) || get_class($this->loaders[$ext]) !== get_class($loader)) { |
|
62 | + if (!isset($this->loaders[$ext]) || get_class($this->loaders[$ext]) !== get_class($loader)){ |
|
63 | 63 | $this->loaders[$ext] = $loader; |
64 | 64 | $this->container->bindSingleton(ConfigManager::class, $this->createConfigManager()); |
65 | 65 | } |
@@ -59,7 +59,8 @@ |
||
59 | 59 | |
60 | 60 | public function addLoader(string $ext, FileLoaderInterface $loader): void |
61 | 61 | { |
62 | - if (!isset($this->loaders[$ext]) || get_class($this->loaders[$ext]) !== get_class($loader)) { |
|
62 | + if (!isset($this->loaders[$ext]) || get_class($this->loaders[$ext]) !== get_class($loader)) |
|
63 | + { |
|
63 | 64 | $this->loaders[$ext] = $loader; |
64 | 65 | $this->container->bindSingleton(ConfigManager::class, $this->createConfigManager()); |
65 | 66 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | DirectoriesInterface::class, |
52 | 52 | new Directories( |
53 | 53 | [ |
54 | - 'app' => __DIR__ . '/fixtures', |
|
55 | - 'cache' => __DIR__ . '/cache' |
|
54 | + 'app' => __DIR__.'/fixtures', |
|
55 | + 'cache' => __DIR__.'/cache' |
|
56 | 56 | ] |
57 | 57 | ) |
58 | 58 | ); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $this->container->bind( |
62 | 62 | ConfiguratorInterface::class, |
63 | 63 | new ConfigManager( |
64 | - new DirectoryLoader(__DIR__ . '/config/', [ |
|
64 | + new DirectoryLoader(__DIR__.'/config/', [ |
|
65 | 65 | 'php' => $this->container->get(PhpLoader::class), |
66 | 66 | 'json' => $this->container->get(JsonLoader::class), |
67 | 67 | ]), |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | FinalizerInterface $finalizer, |
50 | 50 | ContainerInterface $container, |
51 | 51 | FactoryInterface $factory |
52 | - ) { |
|
52 | + ){ |
|
53 | 53 | $this->env = $env; |
54 | 54 | $this->finalizer = $finalizer; |
55 | 55 | $this->container = $container; |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | |
76 | 76 | /** @var Http $http */ |
77 | 77 | $http = $this->container->get(Http::class); |
78 | - while ($request = $client->acceptRequest()) { |
|
79 | - try { |
|
78 | + while ($request = $client->acceptRequest()){ |
|
79 | + try{ |
|
80 | 80 | $client->respond($http->handle($request)); |
81 | - } catch (\Throwable $e) { |
|
81 | + }catch (\Throwable $e){ |
|
82 | 82 | $this->handleException($client, $e); |
83 | - } finally { |
|
83 | + }finally{ |
|
84 | 84 | $this->finalizer->finalize(false); |
85 | 85 | } |
86 | 86 | } |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | { |
95 | 95 | $handler = new HtmlHandler(); |
96 | 96 | |
97 | - try { |
|
97 | + try{ |
|
98 | 98 | /** @var SnapshotInterface $snapshot */ |
99 | 99 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
100 | 100 | error_log($snapshot->getMessage()); |
101 | 101 | |
102 | 102 | // on demand |
103 | 103 | $state = $this->container->get(StateInterface::class); |
104 | - if ($state !== null) { |
|
104 | + if ($state !== null){ |
|
105 | 105 | $handler = $handler->withState($state); |
106 | 106 | } |
107 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
107 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
108 | 108 | error_log((string)$e); |
109 | 109 | } |
110 | 110 |
@@ -75,12 +75,18 @@ discard block |
||
75 | 75 | |
76 | 76 | /** @var Http $http */ |
77 | 77 | $http = $this->container->get(Http::class); |
78 | - while ($request = $client->acceptRequest()) { |
|
79 | - try { |
|
78 | + while ($request = $client->acceptRequest()) |
|
79 | + { |
|
80 | + try |
|
81 | + { |
|
80 | 82 | $client->respond($http->handle($request)); |
81 | - } catch (\Throwable $e) { |
|
83 | + } |
|
84 | + catch (\Throwable $e) |
|
85 | + { |
|
82 | 86 | $this->handleException($client, $e); |
83 | - } finally { |
|
87 | + } |
|
88 | + finally |
|
89 | + { |
|
84 | 90 | $this->finalizer->finalize(false); |
85 | 91 | } |
86 | 92 | } |
@@ -94,17 +100,21 @@ discard block |
||
94 | 100 | { |
95 | 101 | $handler = new HtmlHandler(); |
96 | 102 | |
97 | - try { |
|
103 | + try |
|
104 | + { |
|
98 | 105 | /** @var SnapshotInterface $snapshot */ |
99 | 106 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
100 | 107 | error_log($snapshot->getMessage()); |
101 | 108 | |
102 | 109 | // on demand |
103 | 110 | $state = $this->container->get(StateInterface::class); |
104 | - if ($state !== null) { |
|
111 | + if ($state !== null) |
|
112 | + { |
|
105 | 113 | $handler = $handler->withState($state); |
106 | 114 | } |
107 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
115 | + } |
|
116 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
117 | + { |
|
108 | 118 | error_log((string)$e); |
109 | 119 | } |
110 | 120 |
@@ -43,8 +43,8 @@ |
||
43 | 43 | { |
44 | 44 | $state->setTag('php', phpversion()); |
45 | 45 | |
46 | - if ($this->container->has(DispatcherInterface::class)) { |
|
47 | - switch (get_class($this->container->get(DispatcherInterface::class))) { |
|
46 | + if ($this->container->has(DispatcherInterface::class)){ |
|
47 | + switch (get_class($this->container->get(DispatcherInterface::class))){ |
|
48 | 48 | case LegacyRrDispatcher::class: |
49 | 49 | $state->setTag('dispatcher', 'roadrunner'); |
50 | 50 | break; |
@@ -43,8 +43,10 @@ |
||
43 | 43 | { |
44 | 44 | $state->setTag('php', phpversion()); |
45 | 45 | |
46 | - if ($this->container->has(DispatcherInterface::class)) { |
|
47 | - switch (get_class($this->container->get(DispatcherInterface::class))) { |
|
46 | + if ($this->container->has(DispatcherInterface::class)) |
|
47 | + { |
|
48 | + switch (get_class($this->container->get(DispatcherInterface::class))) |
|
49 | + { |
|
48 | 50 | case LegacyRrDispatcher::class: |
49 | 51 | $state->setTag('dispatcher', 'roadrunner'); |
50 | 52 | break; |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function boot(Container $container) |
41 | 41 | { |
42 | - $container->bindSingleton(RPC::class, function (EnvironmentInterface $env) { |
|
42 | + $container->bindSingleton(RPC::class, function (EnvironmentInterface $env){ |
|
43 | 43 | return $this->rpc($env); |
44 | 44 | }); |
45 | 45 | |
46 | - $container->bindSingleton(Worker::class, function (EnvironmentInterface $env) { |
|
46 | + $container->bindSingleton(Worker::class, function (EnvironmentInterface $env){ |
|
47 | 47 | return $this->worker($env); |
48 | 48 | }); |
49 | 49 | |
50 | - $container->bindSingleton(MetricsInterface::class, function (RPC $rpc) { |
|
50 | + $container->bindSingleton(MetricsInterface::class, function (RPC $rpc){ |
|
51 | 51 | return new Metrics($rpc); |
52 | 52 | }); |
53 | 53 | } |
@@ -60,21 +60,21 @@ discard block |
||
60 | 60 | { |
61 | 61 | $conn = $env->get('RR_RPC', self::RPC_DEFAULT); |
62 | 62 | |
63 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
63 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
64 | 64 | throw new BootException( |
65 | 65 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
66 | 66 | ); |
67 | 67 | } |
68 | 68 | |
69 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
69 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
70 | 70 | throw new BootException( |
71 | 71 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
72 | 72 | ); |
73 | 73 | } |
74 | 74 | |
75 | - if ($parts[1] == 'unix') { |
|
75 | + if ($parts[1] == 'unix'){ |
|
76 | 76 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
77 | - } else { |
|
77 | + }else{ |
|
78 | 78 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
79 | 79 | } |
80 | 80 | |
@@ -89,25 +89,25 @@ discard block |
||
89 | 89 | { |
90 | 90 | $conn = $env->get('RR_RELAY', self::WORKER_DEFAULT); |
91 | 91 | |
92 | - if ($conn === 'pipes' || empty($conn)) { |
|
92 | + if ($conn === 'pipes' || empty($conn)){ |
|
93 | 93 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
94 | 94 | } |
95 | 95 | |
96 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
96 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
97 | 97 | throw new BootException( |
98 | 98 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
99 | 99 | ); |
100 | 100 | } |
101 | 101 | |
102 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
102 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
103 | 103 | throw new BootException( |
104 | 104 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
105 | 105 | ); |
106 | 106 | } |
107 | 107 | |
108 | - if ($parts[1] == 'unix') { |
|
108 | + if ($parts[1] == 'unix'){ |
|
109 | 109 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
110 | - } else { |
|
110 | + }else{ |
|
111 | 111 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
112 | 112 | } |
113 | 113 |
@@ -39,15 +39,18 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function boot(Container $container) |
41 | 41 | { |
42 | - $container->bindSingleton(RPC::class, function (EnvironmentInterface $env) { |
|
42 | + $container->bindSingleton(RPC::class, function (EnvironmentInterface $env) |
|
43 | + { |
|
43 | 44 | return $this->rpc($env); |
44 | 45 | }); |
45 | 46 | |
46 | - $container->bindSingleton(Worker::class, function (EnvironmentInterface $env) { |
|
47 | + $container->bindSingleton(Worker::class, function (EnvironmentInterface $env) |
|
48 | + { |
|
47 | 49 | return $this->worker($env); |
48 | 50 | }); |
49 | 51 | |
50 | - $container->bindSingleton(MetricsInterface::class, function (RPC $rpc) { |
|
52 | + $container->bindSingleton(MetricsInterface::class, function (RPC $rpc) |
|
53 | + { |
|
51 | 54 | return new Metrics($rpc); |
52 | 55 | }); |
53 | 56 | } |
@@ -60,21 +63,26 @@ discard block |
||
60 | 63 | { |
61 | 64 | $conn = $env->get('RR_RPC', self::RPC_DEFAULT); |
62 | 65 | |
63 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
66 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
67 | + { |
|
64 | 68 | throw new BootException( |
65 | 69 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
66 | 70 | ); |
67 | 71 | } |
68 | 72 | |
69 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
73 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
74 | + { |
|
70 | 75 | throw new BootException( |
71 | 76 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
72 | 77 | ); |
73 | 78 | } |
74 | 79 | |
75 | - if ($parts[1] == 'unix') { |
|
80 | + if ($parts[1] == 'unix') |
|
81 | + { |
|
76 | 82 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
77 | - } else { |
|
83 | + } |
|
84 | + else |
|
85 | + { |
|
78 | 86 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
79 | 87 | } |
80 | 88 | |
@@ -89,25 +97,31 @@ discard block |
||
89 | 97 | { |
90 | 98 | $conn = $env->get('RR_RELAY', self::WORKER_DEFAULT); |
91 | 99 | |
92 | - if ($conn === 'pipes' || empty($conn)) { |
|
100 | + if ($conn === 'pipes' || empty($conn)) |
|
101 | + { |
|
93 | 102 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
94 | 103 | } |
95 | 104 | |
96 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
105 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
106 | + { |
|
97 | 107 | throw new BootException( |
98 | 108 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
99 | 109 | ); |
100 | 110 | } |
101 | 111 | |
102 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
112 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
113 | + { |
|
103 | 114 | throw new BootException( |
104 | 115 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
105 | 116 | ); |
106 | 117 | } |
107 | 118 | |
108 | - if ($parts[1] == 'unix') { |
|
119 | + if ($parts[1] == 'unix') |
|
120 | + { |
|
109 | 121 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
110 | - } else { |
|
122 | + } |
|
123 | + else |
|
124 | + { |
|
111 | 125 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
112 | 126 | } |
113 | 127 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | private function isLegacy(): bool |
44 | 44 | { |
45 | - if (\class_exists(InstalledVersions::class)) { |
|
45 | + if (\class_exists(InstalledVersions::class)){ |
|
46 | 46 | $version = InstalledVersions::getVersion('spiral/roadrunner'); |
47 | 47 | |
48 | 48 | return \str_starts_with($version, '1.'); |
@@ -42,7 +42,8 @@ |
||
42 | 42 | */ |
43 | 43 | private function isLegacy(): bool |
44 | 44 | { |
45 | - if (\class_exists(InstalledVersions::class)) { |
|
45 | + if (\class_exists(InstalledVersions::class)) |
|
46 | + { |
|
46 | 47 | $version = InstalledVersions::getVersion('spiral/roadrunner'); |
47 | 48 | |
48 | 49 | return \str_starts_with($version, '1.'); |
@@ -47,12 +47,12 @@ |
||
47 | 47 | { |
48 | 48 | $kernel->addDispatcher($jobs); |
49 | 49 | |
50 | - if (\class_exists(LegacyRPC::class)) { |
|
51 | - $container->bindSingleton(QueueInterface::class, function (LegacyRPC $rpc, JobRegistry $registry) { |
|
50 | + if (\class_exists(LegacyRPC::class)){ |
|
51 | + $container->bindSingleton(QueueInterface::class, function (LegacyRPC $rpc, JobRegistry $registry){ |
|
52 | 52 | return new JobQueue($rpc, $registry); |
53 | 53 | }); |
54 | - } else { |
|
55 | - $container->bindSingleton(QueueInterface::class, function (RPC $rpc, JobRegistry $registry) { |
|
54 | + }else{ |
|
55 | + $container->bindSingleton(QueueInterface::class, function (RPC $rpc, JobRegistry $registry){ |
|
56 | 56 | return new JobQueue($rpc, $registry); |
57 | 57 | }); |
58 | 58 | } |
@@ -47,12 +47,17 @@ |
||
47 | 47 | { |
48 | 48 | $kernel->addDispatcher($jobs); |
49 | 49 | |
50 | - if (\class_exists(LegacyRPC::class)) { |
|
51 | - $container->bindSingleton(QueueInterface::class, function (LegacyRPC $rpc, JobRegistry $registry) { |
|
50 | + if (\class_exists(LegacyRPC::class)) |
|
51 | + { |
|
52 | + $container->bindSingleton(QueueInterface::class, function (LegacyRPC $rpc, JobRegistry $registry) |
|
53 | + { |
|
52 | 54 | return new JobQueue($rpc, $registry); |
53 | 55 | }); |
54 | - } else { |
|
55 | - $container->bindSingleton(QueueInterface::class, function (RPC $rpc, JobRegistry $registry) { |
|
56 | + } |
|
57 | + else |
|
58 | + { |
|
59 | + $container->bindSingleton(QueueInterface::class, function (RPC $rpc, JobRegistry $registry) |
|
60 | + { |
|
56 | 61 | return new JobQueue($rpc, $registry); |
57 | 62 | }); |
58 | 63 | } |