Completed
Push — master ( 6366df...fbe022 )
by Kirill
23s queued 19s
created
src/Router/tests/SingleActionTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,9 +103,9 @@
 block discarded – undo
103 103
         $this->assertSame('echoed', (string)$response->getBody());
104 104
 
105 105
         $e = null;
106
-        try {
106
+        try{
107 107
             $router->handle(new ServerRequest([], [], new Uri('/test')));
108
-        } catch (UndefinedRouteException $e) {
108
+        }catch (UndefinedRouteException $e){
109 109
         }
110 110
 
111 111
         $this->assertNotNull($e, 'Autofill not fired');
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,9 +103,12 @@
 block discarded – undo
103 103
         $this->assertSame('echoed', (string)$response->getBody());
104 104
 
105 105
         $e = null;
106
-        try {
106
+        try
107
+        {
107 108
             $router->handle(new ServerRequest([], [], new Uri('/test')));
108
-        } catch (UndefinedRouteException $e) {
109
+        }
110
+        catch (UndefinedRouteException $e)
111
+        {
109 112
         }
110 113
 
111 114
         $this->assertNotNull($e, 'Autofill not fired');
Please login to merge, or discard this patch.
src/Router/tests/Diactoros/ResponseFactory.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Router/tests/Diactoros/UploadedFileFactory.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Router/tests/CallableTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
         $router = $this->makeRouter();
28 28
         $router->setRoute(
29 29
             'action',
30
-            new Route('/something', function () {
30
+            new Route('/something', function (){
31 31
                 return 'hello world';
32 32
             })
33 33
         );
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,8 @@
 block discarded – undo
27 27
         $router = $this->makeRouter();
28 28
         $router->setRoute(
29 29
             'action',
30
-            new Route('/something', function () {
30
+            new Route('/something', function ()
31
+            {
31 32
                 return 'hello world';
32 33
             })
33 34
         );
Please login to merge, or discard this patch.
src/Router/tests/TestCore.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,6 +24,6 @@
 block discarded – undo
24 24
 
25 25
     public function callAction(string $controller, string $action = null, array $parameters = [])
26 26
     {
27
-        return '@wrapped.' . $this->core->callAction($controller, $action, $parameters);
27
+        return '@wrapped.'.$this->core->callAction($controller, $action, $parameters);
28 28
     }
29 29
 }
Please login to merge, or discard this patch.
src/Router/src/Route.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function __construct(string $pattern, $target, array $defaults = [])
61 61
     {
62
-        if ($target instanceof TargetInterface) {
62
+        if ($target instanceof TargetInterface){
63 63
             parent::__construct($pattern, array_merge($target->getDefaults(), $defaults));
64
-        } else {
64
+        }else{
65 65
             parent::__construct($pattern, $defaults);
66 66
         }
67 67
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         /** @var self $route */
78 78
         $route = parent::withUriHandler($uriHandler);
79
-        if ($this->target instanceof TargetInterface) {
79
+        if ($this->target instanceof TargetInterface){
80 80
             $route->uriHandler = $route->uriHandler->withConstrains(
81 81
                 $this->target->getConstrains(),
82 82
                 $this->defaults
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $route = clone $this;
98 98
         $route->container = $container;
99 99
 
100
-        if ($route->target instanceof TargetInterface) {
100
+        if ($route->target instanceof TargetInterface){
101 101
             $route->target = clone $route->target;
102 102
         }
103 103
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function handle(ServerRequestInterface $request): ResponseInterface
116 116
     {
117
-        if (empty($this->requestHandler)) {
117
+        if (empty($this->requestHandler)){
118 118
             $this->requestHandler = $this->requestHandler();
119 119
         }
120 120
 
@@ -131,30 +131,30 @@  discard block
 block discarded – undo
131 131
      */
132 132
     protected function requestHandler(): RequestHandlerInterface
133 133
     {
134
-        if (!$this->hasContainer()) {
134
+        if (!$this->hasContainer()){
135 135
             throw new RouteException('Unable to configure route pipeline without associated container');
136 136
         }
137 137
 
138
-        if ($this->target instanceof TargetInterface) {
139
-            try {
138
+        if ($this->target instanceof TargetInterface){
139
+            try{
140 140
                 return $this->target->getHandler($this->container, $this->matches);
141
-            } catch (TargetException $e) {
141
+            }catch (TargetException $e){
142 142
                 throw new RouteException('Invalid target resolution', $e->getCode(), $e);
143 143
             }
144 144
         }
145 145
 
146
-        if ($this->target instanceof RequestHandlerInterface) {
146
+        if ($this->target instanceof RequestHandlerInterface){
147 147
             return $this->target;
148 148
         }
149 149
 
150
-        try {
151
-            if (is_object($this->target) || is_array($this->target)) {
150
+        try{
151
+            if (is_object($this->target) || is_array($this->target)){
152 152
                 $target = $this->target;
153
-            } else {
153
+            }else{
154 154
                 $target = $this->container->get($this->target);
155 155
             }
156 156
 
157
-            if ($target instanceof RequestHandlerInterface) {
157
+            if ($target instanceof RequestHandlerInterface){
158 158
                 return $target;
159 159
             }
160 160
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
                 $target,
163 163
                 $this->container->get(ResponseFactoryInterface::class)
164 164
             );
165
-        } catch (ContainerExceptionInterface $e) {
165
+        }catch (ContainerExceptionInterface $e){
166 166
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
167 167
         }
168 168
     }
Please login to merge, or discard this patch.
Braces   +34 added lines, -15 removed lines patch added patch discarded remove patch
@@ -59,9 +59,12 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function __construct(string $pattern, $target, array $defaults = [])
61 61
     {
62
-        if ($target instanceof TargetInterface) {
62
+        if ($target instanceof TargetInterface)
63
+        {
63 64
             parent::__construct($pattern, array_merge($target->getDefaults(), $defaults));
64
-        } else {
65
+        }
66
+        else
67
+        {
65 68
             parent::__construct($pattern, $defaults);
66 69
         }
67 70
 
@@ -76,7 +79,8 @@  discard block
 block discarded – undo
76 79
     {
77 80
         /** @var self $route */
78 81
         $route = parent::withUriHandler($uriHandler);
79
-        if ($this->target instanceof TargetInterface) {
82
+        if ($this->target instanceof TargetInterface)
83
+        {
80 84
             $route->uriHandler = $route->uriHandler->withConstrains(
81 85
                 $this->target->getConstrains(),
82 86
                 $this->defaults
@@ -97,7 +101,8 @@  discard block
 block discarded – undo
97 101
         $route = clone $this;
98 102
         $route->container = $container;
99 103
 
100
-        if ($route->target instanceof TargetInterface) {
104
+        if ($route->target instanceof TargetInterface)
105
+        {
101 106
             $route->target = clone $route->target;
102 107
         }
103 108
 
@@ -114,7 +119,8 @@  discard block
 block discarded – undo
114 119
      */
115 120
     public function handle(ServerRequestInterface $request): ResponseInterface
116 121
     {
117
-        if (empty($this->requestHandler)) {
122
+        if (empty($this->requestHandler))
123
+        {
118 124
             $this->requestHandler = $this->requestHandler();
119 125
         }
120 126
 
@@ -131,30 +137,41 @@  discard block
 block discarded – undo
131 137
      */
132 138
     protected function requestHandler(): RequestHandlerInterface
133 139
     {
134
-        if (!$this->hasContainer()) {
140
+        if (!$this->hasContainer())
141
+        {
135 142
             throw new RouteException('Unable to configure route pipeline without associated container');
136 143
         }
137 144
 
138
-        if ($this->target instanceof TargetInterface) {
139
-            try {
145
+        if ($this->target instanceof TargetInterface)
146
+        {
147
+            try
148
+            {
140 149
                 return $this->target->getHandler($this->container, $this->matches);
141
-            } catch (TargetException $e) {
150
+            }
151
+            catch (TargetException $e)
152
+            {
142 153
                 throw new RouteException('Invalid target resolution', $e->getCode(), $e);
143 154
             }
144 155
         }
145 156
 
146
-        if ($this->target instanceof RequestHandlerInterface) {
157
+        if ($this->target instanceof RequestHandlerInterface)
158
+        {
147 159
             return $this->target;
148 160
         }
149 161
 
150
-        try {
151
-            if (is_object($this->target) || is_array($this->target)) {
162
+        try
163
+        {
164
+            if (is_object($this->target) || is_array($this->target))
165
+            {
152 166
                 $target = $this->target;
153
-            } else {
167
+            }
168
+            else
169
+            {
154 170
                 $target = $this->container->get($this->target);
155 171
             }
156 172
 
157
-            if ($target instanceof RequestHandlerInterface) {
173
+            if ($target instanceof RequestHandlerInterface)
174
+            {
158 175
                 return $target;
159 176
             }
160 177
 
@@ -162,7 +179,9 @@  discard block
 block discarded – undo
162 179
                 $target,
163 180
                 $this->container->get(ResponseFactoryInterface::class)
164 181
             );
165
-        } catch (ContainerExceptionInterface $e) {
182
+        }
183
+        catch (ContainerExceptionInterface $e)
184
+        {
166 185
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
167 186
         }
168 187
     }
Please login to merge, or discard this patch.
src/Router/src/Target/Action.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function __construct(string $controller, $action, int $options = 0)
41 41
     {
42
-        if (!is_string($action) && !is_array($action)) {
42
+        if (!is_string($action) && !is_array($action)){
43 43
             throw new InvalidArgumentException(
44 44
                 sprintf(
45 45
                     'Action parameter must type string or array, `%s` given',
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
         $this->controller = $controller;
52 52
         $this->action = $action;
53 53
 
54
-        if (is_string($action)) {
54
+        if (is_string($action)){
55 55
             parent::__construct(
56 56
                 ['action' => $action],
57 57
                 ['action' => new Autofill($action)],
58 58
                 $options
59 59
             );
60
-        } else {
60
+        }else{
61 61
             parent::__construct(
62 62
                 ['action' => null],
63 63
                 ['action' => $action],
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     protected function resolveAction(array $matches): string
81 81
     {
82 82
         $action = $this->action;
83
-        if (is_string($action)) {
83
+        if (is_string($action)){
84 84
             return $action;
85 85
         }
86 86
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,7 +39,8 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function __construct(string $controller, $action, int $options = 0)
41 41
     {
42
-        if (!is_string($action) && !is_array($action)) {
42
+        if (!is_string($action) && !is_array($action))
43
+        {
43 44
             throw new InvalidArgumentException(
44 45
                 sprintf(
45 46
                     'Action parameter must type string or array, `%s` given',
@@ -51,13 +52,16 @@  discard block
 block discarded – undo
51 52
         $this->controller = $controller;
52 53
         $this->action = $action;
53 54
 
54
-        if (is_string($action)) {
55
+        if (is_string($action))
56
+        {
55 57
             parent::__construct(
56 58
                 ['action' => $action],
57 59
                 ['action' => new Autofill($action)],
58 60
                 $options
59 61
             );
60
-        } else {
62
+        }
63
+        else
64
+        {
61 65
             parent::__construct(
62 66
                 ['action' => null],
63 67
                 ['action' => $action],
@@ -80,7 +84,8 @@  discard block
 block discarded – undo
80 84
     protected function resolveAction(array $matches): string
81 85
     {
82 86
         $action = $this->action;
83
-        if (is_string($action)) {
87
+        if (is_string($action))
88
+        {
84 89
             return $action;
85 90
         }
86 91
 
Please login to merge, or discard this patch.
src/Router/src/Target/Namespaced.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         string $postfix = 'Controller',
41 41
         int $options = 0,
42 42
         string $defaultAction = 'index'
43
-    ) {
43
+    ){
44 44
         $this->namespace = rtrim($namespace, '\\');
45 45
         $this->postfix = ucfirst($postfix);
46 46
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     protected function resolveController(array $matches): string
60 60
     {
61
-        if (preg_match('/[^a-z_0-9\-]/i', $matches['controller'])) {
61
+        if (preg_match('/[^a-z_0-9\-]/i', $matches['controller'])){
62 62
             throw new TargetException('Invalid namespace target, controller name not allowed.');
63 63
         }
64 64
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,8 @@
 block discarded – undo
58 58
      */
59 59
     protected function resolveController(array $matches): string
60 60
     {
61
-        if (preg_match('/[^a-z_0-9\-]/i', $matches['controller'])) {
61
+        if (preg_match('/[^a-z_0-9\-]/i', $matches['controller']))
62
+        {
62 63
             throw new TargetException('Invalid namespace target, controller name not allowed.');
63 64
         }
64 65
 
Please login to merge, or discard this patch.
src/Router/src/Target/AbstractTarget.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function coreHandler(ContainerInterface $container): CoreHandler
107 107
     {
108
-        if ($this->handler !== null) {
108
+        if ($this->handler !== null){
109 109
             return $this->handler;
110 110
         }
111 111
 
112
-        try {
112
+        try{
113 113
             // construct on demand
114 114
             $this->handler = new CoreHandler(
115 115
                 $this->core ?? $container->get(CoreInterface::class),
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             );
119 119
 
120 120
             return $this->handler;
121
-        } catch (ContainerExceptionInterface $e) {
121
+        }catch (ContainerExceptionInterface $e){
122 122
             throw new TargetException($e->getMessage(), $e->getCode(), $e);
123 123
         }
124 124
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -105,11 +105,13 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function coreHandler(ContainerInterface $container): CoreHandler
107 107
     {
108
-        if ($this->handler !== null) {
108
+        if ($this->handler !== null)
109
+        {
109 110
             return $this->handler;
110 111
         }
111 112
 
112
-        try {
113
+        try
114
+        {
113 115
             // construct on demand
114 116
             $this->handler = new CoreHandler(
115 117
                 $this->core ?? $container->get(CoreInterface::class),
@@ -118,7 +120,9 @@  discard block
 block discarded – undo
118 120
             );
119 121
 
120 122
             return $this->handler;
121
-        } catch (ContainerExceptionInterface $e) {
123
+        }
124
+        catch (ContainerExceptionInterface $e)
125
+        {
122 126
             throw new TargetException($e->getMessage(), $e->getCode(), $e);
123 127
         }
124 128
     }
Please login to merge, or discard this patch.