Passed
Pull Request — master (#1183)
by Abdul Malik
25:31 queued 15:01
created
src/Snapshots/src/FileSnapshot.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
         private readonly Verbosity $verbosity,
20 20
         private readonly ExceptionRendererInterface $renderer,
21 21
         private readonly FilesInterface $files
22
-    ) {
22
+    ){
23 23
     }
24 24
 
25 25
     public function create(\Throwable $e): SnapshotInterface
@@ -51,16 +51,16 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $finder = new Finder();
53 53
         $finder->in($this->directory)->sort(
54
-            static fn (SplFileInfo $a, SplFileInfo $b): int|float => $b->getMTime() - $a->getMTime()
54
+            static fn (SplFileInfo $a, SplFileInfo $b): int | float => $b->getMTime() - $a->getMTime()
55 55
         );
56 56
 
57 57
         $count = 0;
58
-        foreach ($finder as $file) {
58
+        foreach ($finder as $file){
59 59
             $count++;
60
-            if ($count > $this->maxFiles) {
61
-                try {
60
+            if ($count > $this->maxFiles){
61
+                try{
62 62
                     $this->files->delete($file->getRealPath());
63
-                } catch (FilesException) {
63
+                }catch (FilesException){
64 64
                     // ignore
65 65
                 }
66 66
             }
Please login to merge, or discard this patch.
src/Router/tests/ControllerTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
         $this->getContainer()->removeBinding(CoreInterface::class);
79 79
 
80 80
         $core = $target->getHandler($this->getContainer(), []);
81
-        $handler = (fn(CoreHandler $core): \Spiral\Interceptors\HandlerInterface|\Spiral\Core\CoreInterface => $core->core)->call($core, $core);
81
+        $handler = (fn(CoreHandler $core): \Spiral\Interceptors\HandlerInterface | \Spiral\Core\CoreInterface => $core->core)->call($core, $core);
82 82
 
83 83
         self::assertInstanceOf(AutowireHandler::class, $handler);
84 84
     }
Please login to merge, or discard this patch.
src/Broadcasting/src/Driver/AbstractBroadcast.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      */
17 17
     protected function formatTopics(array $topics): array
18 18
     {
19
-        return \array_map(fn (string|\Stringable $topic): string => (string) $topic, $topics);
19
+        return \array_map(fn (string | \Stringable $topic): string => (string)$topic, $topics);
20 20
     }
21 21
 
22 22
     /**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * @param iterable<T>|T $entries
25 25
      * @return array<T>
26 26
      */
27
-    protected function toArray(iterable|string|\Stringable $entries): array
27
+    protected function toArray(iterable | string | \Stringable $entries): array
28 28
     {
29 29
         return match (true) {
30 30
             \is_array($entries) => $entries,
Please login to merge, or discard this patch.
src/Queue/tests/Interceptor/Push/CoreTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
             $queue = m::mock(QueueInterface::class)
25 25
         );
26 26
 
27
-        if (!\is_array($payload)) {
27
+        if (!\is_array($payload)){
28 28
             $this->markTestIncomplete('QueueInterface does not support non-array payloads');
29 29
             return;
30 30
         }
31 31
 
32 32
         $queue->shouldReceive('push')->once()
33
-            ->withArgs(fn(string $name, mixed $p = [], ?OptionsInterface $options = null): bool => $name === 'foo'
33
+            ->withArgs(fn(string $name, mixed $p = [], ?OptionsInterface $options = null) : bool => $name === 'foo'
34 34
                 && $payload === $p
35 35
                 && $options instanceof Options,
36 36
             );
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             $queue = m::mock(QueueInterface::class)
50 50
         );
51 51
 
52
-        if (!\is_array($payload)) {
52
+        if (!\is_array($payload)){
53 53
             $this->markTestIncomplete('QueueInterface does not support non-array payloads');
54 54
             return;
55 55
         }
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
         $tracer->shouldReceive('trace')->once()->andReturnUsing(fn($name, $callback) => $callback());
81 81
 
82 82
         $queue->shouldReceive('push')->once()
83
-            ->withArgs(fn(string $name, array $payload = [], ?OptionsInterface $options = null): bool => $name === 'foo'
83
+            ->withArgs(fn(string $name, array $payload = [], ?OptionsInterface $options = null) : bool => $name === 'foo'
84 84
                 && $payload === ['baz' => 'baf']
85 85
                 && $options->getHeader('foo') === ['bar']);
86 86
 
87
-        ContainerScope::runScope($container, function() use($core): void {
87
+        ContainerScope::runScope($container, function () use($core): void {
88 88
             $core->callAction('foo', 'bar', [
89 89
                 'id' => 'job-id',
90 90
                 'payload' => ['baz' => 'baf'],
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         $tracer->shouldNotReceive('getContext');
104 104
 
105 105
         $queue->shouldReceive('push')->once()
106
-            ->withArgs(fn(string $name, array $payload = [], ?OptionsInterface $options = null): bool => $name === 'foo'
106
+            ->withArgs(fn(string $name, array $payload = [], ?OptionsInterface $options = null) : bool => $name === 'foo'
107 107
                 && $payload === ['baz' => 'baf']
108 108
                 && $options !== null);
109 109
 
Please login to merge, or discard this patch.
src/Http/tests/PipelineTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     public function testMiddlewareProcessingEventShouldBeDispatched(): void
62 62
     {
63
-        $middleware = new class implements MiddlewareInterface {
63
+        $middleware = new class implements MiddlewareInterface{
64 64
             public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
65 65
             {
66 66
                 return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
         $this->container->getBinder('http')
90 90
             ->bind(ServerRequestInterface::class, static fn(CurrentRequest $cr): ?\Psr\Http\Message\ServerRequestInterface => $cr->get());
91 91
 
92
-        $middleware = new class implements MiddlewareInterface {
92
+        $middleware = new class implements MiddlewareInterface{
93 93
             public function process(
94 94
                 ServerRequestInterface $request,
95 95
                 RequestHandlerInterface $handler,
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,8 @@  discard block
 block discarded – undo
60 60
 
61 61
     public function testMiddlewareProcessingEventShouldBeDispatched(): void
62 62
     {
63
-        $middleware = new class implements MiddlewareInterface {
63
+        $middleware = new class implements MiddlewareInterface
64
+        {
64 65
             public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
65 66
             {
66 67
                 return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200);
@@ -89,7 +90,8 @@  discard block
 block discarded – undo
89 90
         $this->container->getBinder('http')
90 91
             ->bind(ServerRequestInterface::class, static fn(CurrentRequest $cr): ?\Psr\Http\Message\ServerRequestInterface => $cr->get());
91 92
 
92
-        $middleware = new class implements MiddlewareInterface {
93
+        $middleware = new class implements MiddlewareInterface
94
+        {
93 95
             public function process(
94 96
                 ServerRequestInterface $request,
95 97
                 RequestHandlerInterface $handler,
Please login to merge, or discard this patch.
src/Hmvc/src/AbstractCore.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     public function __construct(
30 30
         /** @internal */
31 31
         #[Proxy] protected ContainerInterface $container
32
-    ) {
32
+    ){
33 33
         // TODO: can we simplify this?
34 34
         // resolver is usually the container itself
35 35
         /** @psalm-suppress MixedAssignment */
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
             ? $container
38 38
             : $container
39 39
                 ->get(InvokerInterface::class)
40
-                ->invoke(static fn (#[Proxy] ResolverInterface $resolver): \Spiral\Core\ResolverInterface => $resolver);
40
+                ->invoke(static fn (#[Proxy] ResolverInterface $resolver) : \Spiral\Core\ResolverInterface => $resolver);
41 41
     }
42 42
 
43 43
     /**
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 
66 66
     protected function resolveArguments(\ReflectionMethod $method, array $parameters): array
67 67
     {
68
-        foreach ($method->getParameters() as $parameter) {
68
+        foreach ($method->getParameters() as $parameter){
69 69
             $name = $parameter->getName();
70 70
             if (
71 71
                 \array_key_exists($name, $parameters) &&
72 72
                 $parameters[$name] === null &&
73 73
                 $parameter->isDefaultValueAvailable()
74
-            ) {
74
+            ){
75 75
                 /** @psalm-suppress MixedAssignment */
76 76
                 $parameters[$name] = $parameter->getDefaultValue();
77 77
             }
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
      */
87 87
     private function invoke(?object $object, string $class, \ReflectionMethod $method, array $arguments): mixed
88 88
     {
89
-        try {
89
+        try{
90 90
             $args = $this->resolveArguments($method, $arguments);
91
-        } catch (ArgumentResolvingException | InvalidArgumentException $e) {
91
+        }catch (ArgumentResolvingException | InvalidArgumentException $e){
92 92
             throw new ControllerException(
93 93
                 \sprintf(
94 94
                     'Missing/invalid parameter %s of `%s`->`%s`',
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
                 ControllerException::BAD_ARGUMENT,
100 100
                 $e,
101 101
             );
102
-        } catch (ContainerExceptionInterface $e) {
102
+        }catch (ContainerExceptionInterface $e){
103 103
             throw new ControllerException(
104 104
                 $e->getMessage(),
105 105
                 ControllerException::ERROR,
Please login to merge, or discard this patch.
src/Cookies/src/Middleware/CookiesMiddleware.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public function __construct(
26 26
         private readonly CookiesConfig $config,
27 27
         private readonly EncryptionInterface $encryption
28
-    ) {
28
+    ){
29 29
     }
30 30
 
31 31
     public function process(Request $request, RequestHandlerInterface $handler): Response
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $cookies = $request->getCookieParams();
52 52
 
53
-        foreach ($cookies as $name => $cookie) {
54
-            if (!$this->isProtected($name)) {
53
+        foreach ($cookies as $name => $cookie){
54
+            if (!$this->isProtected($name)){
55 55
                 continue;
56 56
             }
57 57
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     protected function isProtected(string $cookie): bool
68 68
     {
69
-        if (\in_array($cookie, $this->config->getExcludedCookies(), true)) {
69
+        if (\in_array($cookie, $this->config->getExcludedCookies(), true)){
70 70
             //Excluded
71 71
             return false;
72 72
         }
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
      */
82 82
     protected function packCookies(Response $response, CookieQueue $queue): Response
83 83
     {
84
-        if (empty($queue->getScheduled())) {
84
+        if (empty($queue->getScheduled())){
85 85
             return $response;
86 86
         }
87 87
 
88 88
         $cookies = $response->getHeader('Set-Cookie');
89 89
 
90
-        foreach ($queue->getScheduled() as $cookie) {
91
-            if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())) {
90
+        foreach ($queue->getScheduled() as $cookie){
91
+            if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())){
92 92
                 $cookies[] = $cookie->createHeader();
93 93
                 continue;
94 94
             }
@@ -99,28 +99,28 @@  discard block
 block discarded – undo
99 99
         return $response->withHeader('Set-Cookie', $cookies);
100 100
     }
101 101
 
102
-    private function decodeCookie(array|string $cookie): mixed
102
+    private function decodeCookie(array | string $cookie): mixed
103 103
     {
104
-        try {
105
-            if (\is_array($cookie)) {
106
-                return \array_map(fn (array|string $cookie): mixed => $this->decodeCookie($cookie), $cookie);
104
+        try{
105
+            if (\is_array($cookie)){
106
+                return \array_map(fn (array | string $cookie): mixed => $this->decodeCookie($cookie), $cookie);
107 107
             }
108
-        } catch (DecryptException) {
108
+        }catch (DecryptException){
109 109
             return null;
110 110
         }
111 111
 
112
-        switch ($this->config->getProtectionMethod()) {
112
+        switch ($this->config->getProtectionMethod()){
113 113
             case CookiesConfig::COOKIE_ENCRYPT:
114
-                try {
114
+                try{
115 115
                     return $this->encryption->getEncrypter()->decrypt($cookie);
116
-                } catch (DecryptException) {
116
+                }catch (DecryptException){
117 117
                 }
118 118
                 return null;
119 119
             case CookiesConfig::COOKIE_HMAC:
120 120
                 $hmac = \substr($cookie, -1 * CookiesConfig::MAC_LENGTH);
121 121
                 $value = \substr($cookie, 0, \strlen($cookie) - \strlen($hmac));
122 122
 
123
-                if (\hash_equals($this->hmacSign($value), $hmac)) {
123
+                if (\hash_equals($this->hmacSign($value), $hmac)){
124 124
                     return $value;
125 125
                 }
126 126
         }
@@ -143,13 +143,13 @@  discard block
 block discarded – undo
143 143
     private function encodeCookie(Cookie $cookie): Cookie
144 144
     {
145 145
         $value = $cookie->getValue() ?? '';
146
-        if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT) {
146
+        if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT){
147 147
             $encryptor = $this->encryption->getEncrypter();
148 148
 
149 149
             return $cookie->withValue($encryptor->encrypt($value));
150 150
         }
151 151
 
152 152
         //VALUE.HMAC
153
-        return $cookie->withValue($value . $this->hmacSign($value));
153
+        return $cookie->withValue($value.$this->hmacSign($value));
154 154
     }
155 155
 }
Please login to merge, or discard this patch.
Braces   +30 added lines, -14 removed lines patch added patch discarded remove patch
@@ -50,8 +50,10 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $cookies = $request->getCookieParams();
52 52
 
53
-        foreach ($cookies as $name => $cookie) {
54
-            if (!$this->isProtected($name)) {
53
+        foreach ($cookies as $name => $cookie)
54
+        {
55
+            if (!$this->isProtected($name))
56
+            {
55 57
                 continue;
56 58
             }
57 59
 
@@ -66,7 +68,8 @@  discard block
 block discarded – undo
66 68
      */
67 69
     protected function isProtected(string $cookie): bool
68 70
     {
69
-        if (\in_array($cookie, $this->config->getExcludedCookies(), true)) {
71
+        if (\in_array($cookie, $this->config->getExcludedCookies(), true))
72
+        {
70 73
             //Excluded
71 74
             return false;
72 75
         }
@@ -81,14 +84,17 @@  discard block
 block discarded – undo
81 84
      */
82 85
     protected function packCookies(Response $response, CookieQueue $queue): Response
83 86
     {
84
-        if (empty($queue->getScheduled())) {
87
+        if (empty($queue->getScheduled()))
88
+        {
85 89
             return $response;
86 90
         }
87 91
 
88 92
         $cookies = $response->getHeader('Set-Cookie');
89 93
 
90
-        foreach ($queue->getScheduled() as $cookie) {
91
-            if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName())) {
94
+        foreach ($queue->getScheduled() as $cookie)
95
+        {
96
+            if (empty($cookie->getValue()) || !$this->isProtected($cookie->getName()))
97
+            {
92 98
                 $cookies[] = $cookie->createHeader();
93 99
                 continue;
94 100
             }
@@ -101,26 +107,35 @@  discard block
 block discarded – undo
101 107
 
102 108
     private function decodeCookie(array|string $cookie): mixed
103 109
     {
104
-        try {
105
-            if (\is_array($cookie)) {
110
+        try
111
+        {
112
+            if (\is_array($cookie))
113
+            {
106 114
                 return \array_map(fn (array|string $cookie): mixed => $this->decodeCookie($cookie), $cookie);
107 115
             }
108
-        } catch (DecryptException) {
116
+        }
117
+        catch (DecryptException)
118
+        {
109 119
             return null;
110 120
         }
111 121
 
112
-        switch ($this->config->getProtectionMethod()) {
122
+        switch ($this->config->getProtectionMethod())
123
+        {
113 124
             case CookiesConfig::COOKIE_ENCRYPT:
114
-                try {
125
+                try
126
+                {
115 127
                     return $this->encryption->getEncrypter()->decrypt($cookie);
116
-                } catch (DecryptException) {
128
+                }
129
+                catch (DecryptException)
130
+                {
117 131
                 }
118 132
                 return null;
119 133
             case CookiesConfig::COOKIE_HMAC:
120 134
                 $hmac = \substr($cookie, -1 * CookiesConfig::MAC_LENGTH);
121 135
                 $value = \substr($cookie, 0, \strlen($cookie) - \strlen($hmac));
122 136
 
123
-                if (\hash_equals($this->hmacSign($value), $hmac)) {
137
+                if (\hash_equals($this->hmacSign($value), $hmac))
138
+                {
124 139
                     return $value;
125 140
                 }
126 141
         }
@@ -143,7 +158,8 @@  discard block
 block discarded – undo
143 158
     private function encodeCookie(Cookie $cookie): Cookie
144 159
     {
145 160
         $value = $cookie->getValue() ?? '';
146
-        if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT) {
161
+        if ($this->config->getProtectionMethod() === CookiesConfig::COOKIE_ENCRYPT)
162
+        {
147 163
             $encryptor = $this->encryption->getEncrypter();
148 164
 
149 165
             return $cookie->withValue($encryptor->encrypt($value));
Please login to merge, or discard this patch.
src/Reactor/src/FileDeclaration.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
         return self::fromElement((new Factory())->fromCode(\file_get_contents($reflection->getFileName())));
54 54
     }
55 55
 
56
-    public function addNamespace(string|PhpNamespace $namespace): PhpNamespace
56
+    public function addNamespace(string | PhpNamespace $namespace): PhpNamespace
57 57
     {
58
-        if ($namespace instanceof PhpNamespace) {
58
+        if ($namespace instanceof PhpNamespace){
59 59
             $this->element->addNamespace($namespace->getElement());
60 60
 
61 61
             return $namespace;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     public function getElements(): Elements
111 111
     {
112 112
         return new Elements(\array_map(
113
-            static fn (ClassLike $element): \Spiral\Reactor\ClassDeclaration|\Spiral\Reactor\InterfaceDeclaration|\Spiral\Reactor\TraitDeclaration|\Spiral\Reactor\EnumDeclaration => match (true) {
113
+            static fn (ClassLike $element): \Spiral\Reactor\ClassDeclaration | \Spiral\Reactor\InterfaceDeclaration | \Spiral\Reactor\TraitDeclaration | \Spiral\Reactor\EnumDeclaration => match (true) {
114 114
                 $element instanceof ClassType => ClassDeclaration::fromElement($element),
115 115
                 $element instanceof InterfaceType => InterfaceDeclaration::fromElement($element),
116 116
                 $element instanceof TraitType => TraitDeclaration::fromElement($element),
Please login to merge, or discard this patch.
src/Reactor/src/Partial/PhpNamespace.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
     public function getElements(): Elements
95 95
     {
96 96
         return new Elements(\array_map(
97
-            static fn (ClassLike $element): \Spiral\Reactor\ClassDeclaration|\Spiral\Reactor\InterfaceDeclaration|\Spiral\Reactor\TraitDeclaration|\Spiral\Reactor\EnumDeclaration => match (true) {
97
+            static fn (ClassLike $element): \Spiral\Reactor\ClassDeclaration | \Spiral\Reactor\InterfaceDeclaration | \Spiral\Reactor\TraitDeclaration | \Spiral\Reactor\EnumDeclaration => match (true) {
98 98
                 $element instanceof ClassType => ClassDeclaration::fromElement($element),
99 99
                 $element instanceof InterfaceType => InterfaceDeclaration::fromElement($element),
100 100
                 $element instanceof TraitType => TraitDeclaration::fromElement($element),
Please login to merge, or discard this patch.