Passed
Pull Request — master (#464)
by Kirill
12:51
created
src/Jobs/src/JobHandler.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@
 block discarded – undo
43 43
         $method = new \ReflectionMethod($this, static::HANDLE_FUNCTION);
44 44
         $method->setAccessible(true);
45 45
 
46
-        try {
46
+        try{
47 47
             $parameters = array_merge(['payload' => $payloadData, 'id' => $jobID], $payloadData);
48 48
             $method->invokeArgs($this, $this->resolver->resolveArguments($method, $parameters));
49
-        } catch (\Throwable $e) {
49
+        }catch (\Throwable $e){
50 50
             throw new JobException(
51 51
                 sprintf('[%s] %s', get_class($this), $e->getMessage()),
52 52
                 $e->getCode(),
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,10 +43,13 @@
 block discarded – undo
43 43
         $method = new \ReflectionMethod($this, static::HANDLE_FUNCTION);
44 44
         $method->setAccessible(true);
45 45
 
46
-        try {
46
+        try
47
+        {
47 48
             $parameters = array_merge(['payload' => $payloadData, 'id' => $jobID], $payloadData);
48 49
             $method->invokeArgs($this, $this->resolver->resolveArguments($method, $parameters));
49
-        } catch (\Throwable $e) {
50
+        }
51
+        catch (\Throwable $e)
52
+        {
50 53
             throw new JobException(
51 54
                 sprintf('[%s] %s', get_class($this), $e->getMessage()),
52 55
                 $e->getCode(),
Please login to merge, or discard this patch.
src/Jobs/src/Registry/ContainerRegistry.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function getHandler(string $jobType): HandlerInterface
52 52
     {
53
-        try {
53
+        try{
54 54
             $handler = $this->container->get($this->className($jobType));
55
-        } catch (ContainerException $e) {
55
+        }catch (ContainerException $e){
56 56
             throw new JobException($e->getMessage(), $e->getCode(), $e);
57 57
         }
58 58
 
59
-        if (!$handler instanceof HandlerInterface) {
59
+        if (!$handler instanceof HandlerInterface){
60 60
             throw new JobException("Unable to resolve job handler for `{$jobType}`");
61 61
         }
62 62
 
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function getSerializer(string $jobType): SerializerInterface
71 71
     {
72
-        try {
72
+        try{
73 73
             $handler = $this->getHandler($jobType);
74
-        } catch (JobException $e) {
74
+        }catch (JobException $e){
75 75
             return $this->defaultSerializer;
76 76
         }
77 77
 
78
-        if ($handler instanceof SerializerInterface) {
78
+        if ($handler instanceof SerializerInterface){
79 79
             return $handler;
80 80
         }
81 81
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     private function className(string $jobType): string
90 90
     {
91 91
         $names = explode('.', $jobType);
92
-        $names = array_map(function (string $value) {
92
+        $names = array_map(function (string $value){
93 93
             return $this->inflector->classify($value);
94 94
         }, $names);
95 95
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,13 +50,17 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function getHandler(string $jobType): HandlerInterface
52 52
     {
53
-        try {
53
+        try
54
+        {
54 55
             $handler = $this->container->get($this->className($jobType));
55
-        } catch (ContainerException $e) {
56
+        }
57
+        catch (ContainerException $e)
58
+        {
56 59
             throw new JobException($e->getMessage(), $e->getCode(), $e);
57 60
         }
58 61
 
59
-        if (!$handler instanceof HandlerInterface) {
62
+        if (!$handler instanceof HandlerInterface)
63
+        {
60 64
             throw new JobException("Unable to resolve job handler for `{$jobType}`");
61 65
         }
62 66
 
@@ -69,13 +73,17 @@  discard block
 block discarded – undo
69 73
      */
70 74
     public function getSerializer(string $jobType): SerializerInterface
71 75
     {
72
-        try {
76
+        try
77
+        {
73 78
             $handler = $this->getHandler($jobType);
74
-        } catch (JobException $e) {
79
+        }
80
+        catch (JobException $e)
81
+        {
75 82
             return $this->defaultSerializer;
76 83
         }
77 84
 
78
-        if ($handler instanceof SerializerInterface) {
85
+        if ($handler instanceof SerializerInterface)
86
+        {
79 87
             return $handler;
80 88
         }
81 89
 
@@ -89,7 +97,8 @@  discard block
 block discarded – undo
89 97
     private function className(string $jobType): string
90 98
     {
91 99
         $names = explode('.', $jobType);
92
-        $names = array_map(function (string $value) {
100
+        $names = array_map(function (string $value)
101
+        {
93 102
             return $this->inflector->classify($value);
94 103
         }, $names);
95 104
 
Please login to merge, or discard this patch.
src/Jobs/src/Consumer.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,18 +37,18 @@
 block discarded – undo
37 37
      */
38 38
     public function serve(Worker $worker, callable $finalize = null): void
39 39
     {
40
-        while ($body = $worker->receive($context)) {
41
-            try {
40
+        while ($body = $worker->receive($context)){
41
+            try{
42 42
                 $context = json_decode($context, true);
43 43
                 $handler = $this->registry->getHandler($context['job']);
44 44
 
45 45
                 $handler->handle($context['job'], $context['id'], $body);
46 46
 
47 47
                 $worker->send('ok');
48
-            } catch (\Throwable $e) {
48
+            }catch (\Throwable $e){
49 49
                 $worker->error((string)$e->getMessage());
50
-            } finally {
51
-                if ($finalize !== null) {
50
+            }finally{
51
+                if ($finalize !== null){
52 52
                     call_user_func($finalize, $e ?? null);
53 53
                 }
54 54
             }
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,18 +37,25 @@
 block discarded – undo
37 37
      */
38 38
     public function serve(Worker $worker, callable $finalize = null): void
39 39
     {
40
-        while ($body = $worker->receive($context)) {
41
-            try {
40
+        while ($body = $worker->receive($context))
41
+        {
42
+            try
43
+            {
42 44
                 $context = json_decode($context, true);
43 45
                 $handler = $this->registry->getHandler($context['job']);
44 46
 
45 47
                 $handler->handle($context['job'], $context['id'], $body);
46 48
 
47 49
                 $worker->send('ok');
48
-            } catch (\Throwable $e) {
50
+            }
51
+            catch (\Throwable $e)
52
+            {
49 53
                 $worker->error((string)$e->getMessage());
50
-            } finally {
51
-                if ($finalize !== null) {
54
+            }
55
+            finally
56
+            {
57
+                if ($finalize !== null)
58
+                {
52 59
                     call_user_func($finalize, $e ?? null);
53 60
                 }
54 61
             }
Please login to merge, or discard this patch.
src/Jobs/src/ShortCircuit.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
     public function push(string $jobType, array $payload = [], Options $options = null): string
41 41
     {
42 42
         $payloadBody = $this->serialize($jobType, $payload);
43
-        if ($options !== null && $options->getDelay()) {
43
+        if ($options !== null && $options->getDelay()){
44 44
             sleep($options->getDelay());
45 45
         }
46 46
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,8 @@
 block discarded – undo
40 40
     public function push(string $jobType, array $payload = [], Options $options = null): string
41 41
     {
42 42
         $payloadBody = $this->serialize($jobType, $payload);
43
-        if ($options !== null && $options->getDelay()) {
43
+        if ($options !== null && $options->getDelay())
44
+        {
44 45
             sleep($options->getDelay());
45 46
         }
46 47
 
Please login to merge, or discard this patch.
src/Jobs/src/Queue.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function push(string $jobType, array $payload = [], Options $options = null): string
55 55
     {
56
-        try {
57
-            return $this->rpc->call(self::RR_SERVICE . '.Push', [
56
+        try{
57
+            return $this->rpc->call(self::RR_SERVICE.'.Push', [
58 58
                 'job'     => $this->jobName($jobType),
59 59
                 'payload' => $this->serialize($jobType, $payload),
60 60
                 'options' => $options ?? new Options(),
61 61
             ]);
62
-        } catch (RoadRunnerException | \Throwable $e) {
62
+        }catch (RoadRunnerException | \Throwable $e){
63 63
             throw new JobException($e->getMessage(), $e->getCode(), $e);
64 64
         }
65 65
     }
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function pushAsync(string $jobType, array $payload = [], Options $options = null): bool
78 78
     {
79
-        try {
80
-            return $this->rpc->call(self::RR_SERVICE . '.PushAsync', [
79
+        try{
80
+            return $this->rpc->call(self::RR_SERVICE.'.PushAsync', [
81 81
                 'job'     => $this->jobName($jobType),
82 82
                 'payload' => $this->serialize($jobType, $payload),
83 83
                 'options' => $options ?? new Options(),
84 84
             ]);
85
-        } catch (RoadRunnerException | \Throwable $e) {
85
+        }catch (RoadRunnerException | \Throwable $e){
86 86
             throw new JobException($e->getMessage(), $e->getCode(), $e);
87 87
         }
88 88
     }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     private function jobName(string $job): string
95 95
     {
96 96
         $names = explode('\\', $job);
97
-        $names = array_map(function (string $value) {
97
+        $names = array_map(function (string $value){
98 98
             return $this->inflector->camelize($value);
99 99
         }, $names);
100 100
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,13 +53,16 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function push(string $jobType, array $payload = [], Options $options = null): string
55 55
     {
56
-        try {
56
+        try
57
+        {
57 58
             return $this->rpc->call(self::RR_SERVICE . '.Push', [
58 59
                 'job'     => $this->jobName($jobType),
59 60
                 'payload' => $this->serialize($jobType, $payload),
60 61
                 'options' => $options ?? new Options(),
61 62
             ]);
62
-        } catch (RoadRunnerException | \Throwable $e) {
63
+        }
64
+        catch (RoadRunnerException | \Throwable $e)
65
+        {
63 66
             throw new JobException($e->getMessage(), $e->getCode(), $e);
64 67
         }
65 68
     }
@@ -76,13 +79,16 @@  discard block
 block discarded – undo
76 79
      */
77 80
     public function pushAsync(string $jobType, array $payload = [], Options $options = null): bool
78 81
     {
79
-        try {
82
+        try
83
+        {
80 84
             return $this->rpc->call(self::RR_SERVICE . '.PushAsync', [
81 85
                 'job'     => $this->jobName($jobType),
82 86
                 'payload' => $this->serialize($jobType, $payload),
83 87
                 'options' => $options ?? new Options(),
84 88
             ]);
85
-        } catch (RoadRunnerException | \Throwable $e) {
89
+        }
90
+        catch (RoadRunnerException | \Throwable $e)
91
+        {
86 92
             throw new JobException($e->getMessage(), $e->getCode(), $e);
87 93
         }
88 94
     }
@@ -94,7 +100,8 @@  discard block
 block discarded – undo
94 100
     private function jobName(string $job): string
95 101
     {
96 102
         $names = explode('\\', $job);
97
-        $names = array_map(function (string $value) {
103
+        $names = array_map(function (string $value)
104
+        {
98 105
             return $this->inflector->camelize($value);
99 106
         }, $names);
100 107
 
Please login to merge, or discard this patch.