Test Failed
Pull Request — master (#917)
by Maxim
07:57
created
src/Router/src/AbstractRoute.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public function __construct(
21 21
         protected string $pattern,
22 22
         array $defaults = []
23
-    ) {
23
+    ){
24 24
         $this->defaults = $defaults;
25 25
     }
26 26
 
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function match(Request $request): ?static
41 41
     {
42
-        if (!\in_array(\strtoupper($request->getMethod()), $this->getVerbs(), true)) {
42
+        if (!\in_array(\strtoupper($request->getMethod()), $this->getVerbs(), true)){
43 43
             return null;
44 44
         }
45 45
 
46 46
         $matches = $this->uriHandler->match($request->getUri(), $this->defaults);
47
-        if ($matches === null) {
47
+        if ($matches === null){
48 48
             return null;
49 49
         }
50 50
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,12 +39,14 @@
 block discarded – undo
39 39
 
40 40
     public function match(Request $request): ?static
41 41
     {
42
-        if (!\in_array(\strtoupper($request->getMethod()), $this->getVerbs(), true)) {
42
+        if (!\in_array(\strtoupper($request->getMethod()), $this->getVerbs(), true))
43
+        {
43 44
             return null;
44 45
         }
45 46
 
46 47
         $matches = $this->uriHandler->match($request->getUri(), $this->defaults);
47
-        if ($matches === null) {
48
+        if ($matches === null)
49
+        {
48 50
             return null;
49 51
         }
50 52
 
Please login to merge, or discard this patch.
src/Router/src/Route.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function __construct(
52 52
         string $pattern,
53
-        string|callable|RequestHandlerInterface|TargetInterface $target,
53
+        string | callable | RequestHandlerInterface | TargetInterface $target,
54 54
         array $defaults = []
55
-    ) {
55
+    ){
56 56
         parent::__construct(
57 57
             $pattern,
58 58
             $target instanceof TargetInterface
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     public function withUriHandler(UriHandler $uriHandler): static
67 67
     {
68 68
         $route = parent::withUriHandler($uriHandler);
69
-        if ($this->target instanceof TargetInterface) {
69
+        if ($this->target instanceof TargetInterface){
70 70
             $route->uriHandler = $route->uriHandler->withConstrains(
71 71
                 $this->target->getConstrains(),
72 72
                 $this->defaults
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         $route = clone $this;
85 85
         $route->container = $container;
86 86
 
87
-        if ($route->target instanceof TargetInterface) {
87
+        if ($route->target instanceof TargetInterface){
88 88
             $route->target = clone $route->target;
89 89
         }
90 90
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function handle(ServerRequestInterface $request): ResponseInterface
113 113
     {
114
-        if (empty($this->requestHandler)) {
114
+        if (empty($this->requestHandler)){
115 115
             $this->requestHandler = $this->requestHandler();
116 116
         }
117 117
 
@@ -126,28 +126,28 @@  discard block
 block discarded – undo
126 126
      */
127 127
     protected function requestHandler(): RequestHandlerInterface
128 128
     {
129
-        if (!$this->hasContainer()) {
129
+        if (!$this->hasContainer()){
130 130
             throw new RouteException('Unable to configure route pipeline without associated container');
131 131
         }
132 132
 
133
-        if ($this->target instanceof TargetInterface) {
134
-            try {
133
+        if ($this->target instanceof TargetInterface){
134
+            try{
135 135
                 return $this->target->getHandler($this->container, $this->matches);
136
-            } catch (TargetException $e) {
136
+            }catch (TargetException $e){
137 137
                 throw new RouteException('Invalid target resolution', $e->getCode(), $e);
138 138
             }
139 139
         }
140 140
 
141
-        if ($this->target instanceof RequestHandlerInterface) {
141
+        if ($this->target instanceof RequestHandlerInterface){
142 142
             return $this->target;
143 143
         }
144 144
 
145
-        try {
145
+        try{
146 146
             $target = \is_string($this->target)
147 147
                 ? $this->container->get($this->target)
148 148
                 : $this->target;
149 149
 
150
-            if ($target instanceof RequestHandlerInterface) {
150
+            if ($target instanceof RequestHandlerInterface){
151 151
                 return $target;
152 152
             }
153 153
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                 $target,
156 156
                 $this->container->get(ResponseFactoryInterface::class)
157 157
             );
158
-        } catch (ContainerExceptionInterface $e) {
158
+        }catch (ContainerExceptionInterface $e){
159 159
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
160 160
         }
161 161
     }
Please login to merge, or discard this patch.
Braces   +24 added lines, -11 removed lines patch added patch discarded remove patch
@@ -66,7 +66,8 @@  discard block
 block discarded – undo
66 66
     public function withUriHandler(UriHandler $uriHandler): static
67 67
     {
68 68
         $route = parent::withUriHandler($uriHandler);
69
-        if ($this->target instanceof TargetInterface) {
69
+        if ($this->target instanceof TargetInterface)
70
+        {
70 71
             $route->uriHandler = $route->uriHandler->withConstrains(
71 72
                 $this->target->getConstrains(),
72 73
                 $this->defaults
@@ -84,7 +85,8 @@  discard block
 block discarded – undo
84 85
         $route = clone $this;
85 86
         $route->container = $container;
86 87
 
87
-        if ($route->target instanceof TargetInterface) {
88
+        if ($route->target instanceof TargetInterface)
89
+        {
88 90
             $route->target = clone $route->target;
89 91
         }
90 92
 
@@ -111,7 +113,8 @@  discard block
 block discarded – undo
111 113
      */
112 114
     public function handle(ServerRequestInterface $request): ResponseInterface
113 115
     {
114
-        if (empty($this->requestHandler)) {
116
+        if (empty($this->requestHandler))
117
+        {
115 118
             $this->requestHandler = $this->requestHandler();
116 119
         }
117 120
 
@@ -126,28 +129,36 @@  discard block
 block discarded – undo
126 129
      */
127 130
     protected function requestHandler(): RequestHandlerInterface
128 131
     {
129
-        if (!$this->hasContainer()) {
132
+        if (!$this->hasContainer())
133
+        {
130 134
             throw new RouteException('Unable to configure route pipeline without associated container');
131 135
         }
132 136
 
133
-        if ($this->target instanceof TargetInterface) {
134
-            try {
137
+        if ($this->target instanceof TargetInterface)
138
+        {
139
+            try
140
+            {
135 141
                 return $this->target->getHandler($this->container, $this->matches);
136
-            } catch (TargetException $e) {
142
+            }
143
+            catch (TargetException $e)
144
+            {
137 145
                 throw new RouteException('Invalid target resolution', $e->getCode(), $e);
138 146
             }
139 147
         }
140 148
 
141
-        if ($this->target instanceof RequestHandlerInterface) {
149
+        if ($this->target instanceof RequestHandlerInterface)
150
+        {
142 151
             return $this->target;
143 152
         }
144 153
 
145
-        try {
154
+        try
155
+        {
146 156
             $target = \is_string($this->target)
147 157
                 ? $this->container->get($this->target)
148 158
                 : $this->target;
149 159
 
150
-            if ($target instanceof RequestHandlerInterface) {
160
+            if ($target instanceof RequestHandlerInterface)
161
+            {
151 162
                 return $target;
152 163
             }
153 164
 
@@ -155,7 +166,9 @@  discard block
 block discarded – undo
155 166
                 $target,
156 167
                 $this->container->get(ResponseFactoryInterface::class)
157 168
             );
158
-        } catch (ContainerExceptionInterface $e) {
169
+        }
170
+        catch (ContainerExceptionInterface $e)
171
+        {
159 172
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
160 173
         }
161 174
     }
Please login to merge, or discard this patch.
src/Router/src/Exception/RouteNotFoundException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
         private readonly UriInterface $uri,
13 13
         int $code = 0,
14 14
         \Throwable $previous = null
15
-    ) {
16
-        parent::__construct(\sprintf('Unable to route `%s`.', (string) $uri), $code, $previous);
15
+    ){
16
+        parent::__construct(\sprintf('Unable to route `%s`.', (string)$uri), $code, $previous);
17 17
     }
18 18
 
19 19
     public function getUri(): UriInterface
Please login to merge, or discard this patch.
src/Router/src/Traits/VerbsTrait.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@
 block discarded – undo
19 19
      */
20 20
     public function withVerbs(string ...$verbs): RouteInterface
21 21
     {
22
-        foreach ($verbs as &$verb) {
22
+        foreach ($verbs as &$verb){
23 23
             $verb = \strtoupper($verb);
24
-            if (!\in_array($verb, RouteInterface::VERBS, true)) {
24
+            if (!\in_array($verb, RouteInterface::VERBS, true)){
25 25
                 throw new RouteException(\sprintf('Invalid HTTP verb `%s`', $verb));
26 26
             }
27 27
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,9 +19,11 @@
 block discarded – undo
19 19
      */
20 20
     public function withVerbs(string ...$verbs): RouteInterface
21 21
     {
22
-        foreach ($verbs as &$verb) {
22
+        foreach ($verbs as &$verb)
23
+        {
23 24
             $verb = \strtoupper($verb);
24
-            if (!\in_array($verb, RouteInterface::VERBS, true)) {
25
+            if (!\in_array($verb, RouteInterface::VERBS, true))
26
+            {
25 27
                 throw new RouteException(\sprintf('Invalid HTTP verb `%s`', $verb));
26 28
             }
27 29
 
Please login to merge, or discard this patch.
src/Router/src/Traits/PipelineTrait.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
         $route = clone $this;
43 43
 
44 44
         // array fallback
45
-        if (\count($middleware) === 1 && \is_array($middleware[0])) {
45
+        if (\count($middleware) === 1 && \is_array($middleware[0])){
46 46
             $middleware = $middleware[0];
47 47
         }
48 48
 
49 49
         /** @var MiddlewareType[] $middleware */
50
-        foreach ($middleware as $item) {
50
+        foreach ($middleware as $item){
51 51
             $route->middleware[] = $item;
52 52
         }
53 53
 
54
-        if ($route->pipeline !== null) {
54
+        if ($route->pipeline !== null){
55 55
             $route->pipeline = $route->makePipeline();
56 56
         }
57 57
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
      */
76 76
     protected function makePipeline(): Pipeline
77 77
     {
78
-        try {
78
+        try{
79 79
             return $this->container
80 80
                 ->get(PipelineFactory::class)
81 81
                 ->createWithMiddleware($this->middleware);
82
-        } catch (ContainerExceptionInterface $e) {
82
+        }catch (ContainerExceptionInterface $e){
83 83
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
84 84
         }
85 85
     }
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,16 +42,19 @@  discard block
 block discarded – undo
42 42
         $route = clone $this;
43 43
 
44 44
         // array fallback
45
-        if (\count($middleware) === 1 && \is_array($middleware[0])) {
45
+        if (\count($middleware) === 1 && \is_array($middleware[0]))
46
+        {
46 47
             $middleware = $middleware[0];
47 48
         }
48 49
 
49 50
         /** @var MiddlewareType[] $middleware */
50
-        foreach ($middleware as $item) {
51
+        foreach ($middleware as $item)
52
+        {
51 53
             $route->middleware[] = $item;
52 54
         }
53 55
 
54
-        if ($route->pipeline !== null) {
56
+        if ($route->pipeline !== null)
57
+        {
55 58
             $route->pipeline = $route->makePipeline();
56 59
         }
57 60
 
@@ -75,11 +78,14 @@  discard block
 block discarded – undo
75 78
      */
76 79
     protected function makePipeline(): Pipeline
77 80
     {
78
-        try {
81
+        try
82
+        {
79 83
             return $this->container
80 84
                 ->get(PipelineFactory::class)
81 85
                 ->createWithMiddleware($this->middleware);
82
-        } catch (ContainerExceptionInterface $e) {
86
+        }
87
+        catch (ContainerExceptionInterface $e)
88
+        {
83 89
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
84 90
         }
85 91
     }
Please login to merge, or discard this patch.
src/Router/src/Event/Routing.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,6 +10,6 @@
 block discarded – undo
10 10
 {
11 11
     public function __construct(
12 12
         public readonly ServerRequestInterface $request
13
-    ) {
13
+    ){
14 14
     }
15 15
 }
Please login to merge, or discard this patch.
src/Router/src/Event/RouteMatched.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
     public function __construct(
13 13
         public readonly ServerRequestInterface $request,
14 14
         public readonly RouteInterface $route,
15
-    ) {
15
+    ){
16 16
     }
17 17
 }
Please login to merge, or discard this patch.
src/Router/src/Autofill.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct(
10 10
         private readonly string $value
11
-    ) {
11
+    ){
12 12
     }
13 13
 
14 14
     public function __toString(): string
Please login to merge, or discard this patch.
src/Router/src/Target/Controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
         private readonly string $controller,
16 16
         int $options = 0,
17 17
         string $defaultAction = 'index'
18
-    ) {
18
+    ){
19 19
         parent::__construct(
20 20
             ['action' => null],
21 21
             ['action' => null],
Please login to merge, or discard this patch.