Passed
Pull Request — master (#1196)
by Abdul Malik
11:01
created
src/Config/src/Loader/JsonLoader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
         $content = \file_get_contents($filename);
14 14
         $data = \json_decode($content, true);
15 15
 
16
-        if (\is_null($data)) {
16
+        if (\is_null($data)){
17 17
             throw new LoaderException(\json_last_error_msg(), \json_last_error());
18 18
         }
19 19
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,8 @@
 block discarded – undo
13 13
         $content = \file_get_contents($filename);
14 14
         $data = \json_decode($content, true);
15 15
 
16
-        if (\is_null($data)) {
16
+        if (\is_null($data))
17
+        {
17 18
             throw new LoaderException(\json_last_error_msg(), \json_last_error());
18 19
         }
19 20
 
Please login to merge, or discard this patch.
src/Config/src/Loader/PhpLoader.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@
 block discarded – undo
15 15
 {
16 16
     public function __construct(
17 17
         private readonly ContainerInterface $container
18
-    ) {
18
+    ){
19 19
     }
20 20
 
21 21
     public function loadFile(string $section, string $filename): array
22 22
     {
23
-        try {
23
+        try{
24 24
             return ContainerScope::runScope($this->container, static fn () => require $filename);
25
-        } catch (\Throwable $e) {
26
-            throw new LoaderException($e->getMessage(), (int) $e->getCode(), $e);
25
+        }catch (\Throwable $e){
26
+            throw new LoaderException($e->getMessage(), (int)$e->getCode(), $e);
27 27
         }
28 28
     }
29 29
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,9 +20,12 @@
 block discarded – undo
20 20
 
21 21
     public function loadFile(string $section, string $filename): array
22 22
     {
23
-        try {
23
+        try
24
+        {
24 25
             return ContainerScope::runScope($this->container, static fn () => require $filename);
25
-        } catch (\Throwable $e) {
26
+        }
27
+        catch (\Throwable $e)
28
+        {
26 29
             throw new LoaderException($e->getMessage(), (int) $e->getCode(), $e);
27 30
         }
28 31
     }
Please login to merge, or discard this patch.
src/Config/src/Patch/Delete.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,26 +18,26 @@
 block discarded – undo
18 18
         string $position,
19 19
         private readonly ?string $key,
20 20
         private mixed $value = null
21
-    ) {
21
+    ){
22 22
         $this->position = $position === '.' ? '' : $position;
23 23
     }
24 24
 
25 25
     public function patch(array $config): array
26 26
     {
27
-        try {
27
+        try{
28 28
             $target = &$this->dotGet($config, $this->position);
29 29
 
30
-            if ($this->key !== null) {
30
+            if ($this->key !== null){
31 31
                 unset($target[$this->key]);
32
-            } else {
33
-                foreach ($target as $key => $value) {
34
-                    if ($value === $this->value) {
32
+            }else{
33
+                foreach ($target as $key => $value){
34
+                    if ($value === $this->value){
35 35
                         unset($target[$key]);
36 36
                         break;
37 37
                     }
38 38
                 }
39 39
             }
40
-        } catch (DotNotFoundException) {
40
+        }catch (DotNotFoundException){
41 41
             // doing nothing when section not found
42 42
         }
43 43
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,20 +24,28 @@
 block discarded – undo
24 24
 
25 25
     public function patch(array $config): array
26 26
     {
27
-        try {
27
+        try
28
+        {
28 29
             $target = &$this->dotGet($config, $this->position);
29 30
 
30
-            if ($this->key !== null) {
31
+            if ($this->key !== null)
32
+            {
31 33
                 unset($target[$this->key]);
32
-            } else {
33
-                foreach ($target as $key => $value) {
34
-                    if ($value === $this->value) {
34
+            }
35
+            else
36
+            {
37
+                foreach ($target as $key => $value)
38
+                {
39
+                    if ($value === $this->value)
40
+                    {
35 41
                         unset($target[$key]);
36 42
                         break;
37 43
                     }
38 44
                 }
39 45
             }
40
-        } catch (DotNotFoundException) {
46
+        }
47
+        catch (DotNotFoundException)
48
+        {
41 49
             // doing nothing when section not found
42 50
         }
43 51
 
Please login to merge, or discard this patch.
src/Config/src/Patch/Traits/DotTrait.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
     private function &dotGet(array &$data, string $name): mixed
15 15
     {
16 16
         //Generating path relative to a given name and prefix
17
-        $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name;
18
-        if (empty($path)) {
17
+        $path = (!empty($this->prefix) ? $this->prefix.'.' : '').$name;
18
+        if (empty($path)){
19 19
             return $data;
20 20
         }
21 21
 
22 22
         $path = \explode('.', \rtrim($path, '.'));
23
-        foreach ($path as $step) {
24
-            if (!\is_array($data) || !\array_key_exists($step, $data)) {
23
+        foreach ($path as $step){
24
+            if (!\is_array($data) || !\array_key_exists($step, $data)){
25 25
                 throw new DotNotFoundException(\sprintf("Unable to find config element '%s'.", $name));
26 26
             }
27 27
             $data = &$data[$step];
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,13 +15,16 @@
 block discarded – undo
15 15
     {
16 16
         //Generating path relative to a given name and prefix
17 17
         $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name;
18
-        if (empty($path)) {
18
+        if (empty($path))
19
+        {
19 20
             return $data;
20 21
         }
21 22
 
22 23
         $path = \explode('.', \rtrim($path, '.'));
23
-        foreach ($path as $step) {
24
-            if (!\is_array($data) || !\array_key_exists($step, $data)) {
24
+        foreach ($path as $step)
25
+        {
26
+            if (!\is_array($data) || !\array_key_exists($step, $data))
27
+            {
25 28
                 throw new DotNotFoundException(\sprintf("Unable to find config element '%s'.", $name));
26 29
             }
27 30
             $data = &$data[$step];
Please login to merge, or discard this patch.
src/Config/src/Patch/Append.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,21 +19,21 @@
 block discarded – undo
19 19
         string $position,
20 20
         private ?string $key,
21 21
         private mixed $value
22
-    ) {
22
+    ){
23 23
         $this->position = $position === '.' ? '' : $position;
24 24
     }
25 25
 
26 26
     public function patch(array $config): array
27 27
     {
28
-        try {
28
+        try{
29 29
             $target = &$this->dotGet($config, $this->position);
30 30
 
31
-            if ($this->key !== null) {
31
+            if ($this->key !== null){
32 32
                 $target[$this->key] = $this->value;
33
-            } else {
33
+            }else{
34 34
                 $target[] = $this->value;
35 35
             }
36
-        } catch (DotNotFoundException $e) {
36
+        }catch (DotNotFoundException $e){
37 37
             throw new PatchException($e->getMessage(), $e->getCode(), $e);
38 38
         }
39 39
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,15 +25,21 @@
 block discarded – undo
25 25
 
26 26
     public function patch(array $config): array
27 27
     {
28
-        try {
28
+        try
29
+        {
29 30
             $target = &$this->dotGet($config, $this->position);
30 31
 
31
-            if ($this->key !== null) {
32
+            if ($this->key !== null)
33
+            {
32 34
                 $target[$this->key] = $this->value;
33
-            } else {
35
+            }
36
+            else
37
+            {
34 38
                 $target[] = $this->value;
35 39
             }
36
-        } catch (DotNotFoundException $e) {
40
+        }
41
+        catch (DotNotFoundException $e)
42
+        {
37 43
             throw new PatchException($e->getMessage(), $e->getCode(), $e);
38 44
         }
39 45
 
Please login to merge, or discard this patch.
src/Router/tests/Fixtures/file.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 use Spiral\Router\Loader\Configurator\RoutingConfigurator;
4 4
 
5
-return function (RoutingConfigurator $routes) {
5
+return function (RoutingConfigurator $routes){
6 6
     $routes->add('index', '/')->callable(static fn () => null);
7 7
     $routes->add('posts', '/posts')->callable(static fn () => null);
8 8
     $routes->add('post', '/post/<id>')->callable(static fn () => null);
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,8 @@
 block discarded – undo
2 2
 
3 3
 use Spiral\Router\Loader\Configurator\RoutingConfigurator;
4 4
 
5
-return function (RoutingConfigurator $routes) {
5
+return function (RoutingConfigurator $routes)
6
+{
6 7
     $routes->add('index', '/')->callable(static fn () => null);
7 8
     $routes->add('posts', '/posts')->callable(static fn () => null);
8 9
     $routes->add('post', '/post/<id>')->callable(static fn () => null);
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
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
         $response = new Response($code);
34 34
         $response = $response->withStatus($code, $reasonPhrase);
35 35
 
36
-        foreach ($this->config->getBaseHeaders() as $header => $value) {
36
+        foreach ($this->config->getBaseHeaders() as $header => $value){
37 37
             $response = $response->withAddedHeader($header, $value);
38 38
         }
39 39
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@
 block discarded – undo
33 33
         $response = new Response($code);
34 34
         $response = $response->withStatus($code, $reasonPhrase);
35 35
 
36
-        foreach ($this->config->getBaseHeaders() as $header => $value) {
36
+        foreach ($this->config->getBaseHeaders() as $header => $value)
37
+        {
37 38
             $response = $response->withAddedHeader($header, $value);
38 39
         }
39 40
 
Please login to merge, or discard this patch.
src/Router/src/Loader/Configurator/RoutingConfigurator.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,12 +21,14 @@
 block discarded – undo
21 21
     {
22 22
         $imported = $this->loader->load($resource, $type) ?: [];
23 23
 
24
-        if (!\is_array($imported)) {
24
+        if (!\is_array($imported))
25
+        {
25 26
             return new ImportConfigurator($this->collection, $imported);
26 27
         }
27 28
 
28 29
         $mergedCollection = new RouteCollection();
29
-        foreach ($imported as $subCollection) {
30
+        foreach ($imported as $subCollection)
31
+        {
30 32
             $mergedCollection->addCollection($subCollection);
31 33
         }
32 34
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@
 block discarded – undo
14 14
     public function __construct(
15 15
         private readonly RouteCollection $collection,
16 16
         private readonly LoaderInterface $loader
17
-    ) {
17
+    ){
18 18
     }
19 19
 
20
-    public function import(string|array $resource, ?string $type = null): ImportConfigurator
20
+    public function import(string | array $resource, ?string $type = null): ImportConfigurator
21 21
     {
22 22
         $imported = $this->loader->load($resource, $type) ?: [];
23 23
 
24
-        if (!\is_array($imported)) {
24
+        if (!\is_array($imported)){
25 25
             return new ImportConfigurator($this->collection, $imported);
26 26
         }
27 27
 
28 28
         $mergedCollection = new RouteCollection();
29
-        foreach ($imported as $subCollection) {
29
+        foreach ($imported as $subCollection){
30 30
             $mergedCollection->addCollection($subCollection);
31 31
         }
32 32
 
Please login to merge, or discard this patch.
src/Router/src/PipelineFactory.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     public function __construct(
18 18
         private readonly ContainerInterface $container,
19 19
         private readonly FactoryInterface $factory
20
-    ) {
20
+    ){
21 21
     }
22 22
 
23 23
     /**
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
      */
27 27
     public function createWithMiddleware(array $middleware): Pipeline
28 28
     {
29
-        if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline) {
29
+        if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline){
30 30
             return $middleware[0];
31 31
         }
32 32
 
33 33
         $pipeline = $this->factory->make(Pipeline::class);
34 34
         \assert($pipeline instanceof Pipeline);
35 35
 
36
-        foreach ($middleware as $item) {
37
-            if ($item instanceof MiddlewareInterface) {
36
+        foreach ($middleware as $item){
37
+            if ($item instanceof MiddlewareInterface){
38 38
                 $pipeline->pushMiddleware($item);
39
-            } elseif (\is_string($item)) {
39
+            } elseif (\is_string($item)){
40 40
                 $item = $this->container->get($item);
41 41
                 \assert($item instanceof MiddlewareInterface);
42 42
 
43 43
                 $pipeline->pushMiddleware($item);
44
-            } elseif ($item instanceof Autowire) {
44
+            } elseif ($item instanceof Autowire){
45 45
                 $item = $item->resolve($this->factory);
46 46
                 \assert($item instanceof MiddlewareInterface);
47 47
 
48 48
                 $pipeline->pushMiddleware($item);
49
-            } else {
49
+            }else{
50 50
                 $name = get_debug_type($item);
51 51
                 throw new RouteException(\sprintf('Invalid middleware `%s`', $name));
52 52
             }
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,27 +26,36 @@
 block discarded – undo
26 26
      */
27 27
     public function createWithMiddleware(array $middleware): Pipeline
28 28
     {
29
-        if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline) {
29
+        if (\count($middleware) === 1 && $middleware[0] instanceof Pipeline)
30
+        {
30 31
             return $middleware[0];
31 32
         }
32 33
 
33 34
         $pipeline = $this->factory->make(Pipeline::class);
34 35
         \assert($pipeline instanceof Pipeline);
35 36
 
36
-        foreach ($middleware as $item) {
37
-            if ($item instanceof MiddlewareInterface) {
37
+        foreach ($middleware as $item)
38
+        {
39
+            if ($item instanceof MiddlewareInterface)
40
+            {
38 41
                 $pipeline->pushMiddleware($item);
39
-            } elseif (\is_string($item)) {
42
+            }
43
+            elseif (\is_string($item))
44
+            {
40 45
                 $item = $this->container->get($item);
41 46
                 \assert($item instanceof MiddlewareInterface);
42 47
 
43 48
                 $pipeline->pushMiddleware($item);
44
-            } elseif ($item instanceof Autowire) {
49
+            }
50
+            elseif ($item instanceof Autowire)
51
+            {
45 52
                 $item = $item->resolve($this->factory);
46 53
                 \assert($item instanceof MiddlewareInterface);
47 54
 
48 55
                 $pipeline->pushMiddleware($item);
49
-            } else {
56
+            }
57
+            else
58
+            {
50 59
                 $name = get_debug_type($item);
51 60
                 throw new RouteException(\sprintf('Invalid middleware `%s`', $name));
52 61
             }
Please login to merge, or discard this patch.