Passed
Push — master ( e4bd8f...4069ad )
by Anton
02:47
created
src/Security/GuardScope.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         PermissionsInterface $permissions,
42 42
         ContainerInterface $actorScope,
43 43
         array $roles = []
44
-    ) {
44
+    ){
45 45
         $this->roles = $roles;
46 46
         $this->container = $actorScope;
47 47
         $this->permissions = $permissions;
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
     public function allows(string $permission, array $context = []): bool
56 56
     {
57 57
         $allows = false;
58
-        foreach ($this->getRoles() as $role) {
59
-            if (!$this->permissions->hasRole($role)) {
58
+        foreach ($this->getRoles() as $role){
59
+            if (!$this->permissions->hasRole($role)){
60 60
                 continue;
61 61
             }
62 62
 
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function getActor(): ActorInterface
105 105
     {
106
-        if (!is_null($this->actor)) {
106
+        if (!is_null($this->actor)){
107 107
             return $this->actor;
108 108
         }
109 109
 
110
-        try {
110
+        try{
111 111
             return $this->container->get(ActorInterface::class);
112
-        } catch (NotFoundExceptionInterface $e) {
112
+        }catch (NotFoundExceptionInterface $e){
113 113
             throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e);
114 114
         }
115 115
     }
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,8 +55,10 @@  discard block
 block discarded – undo
55 55
     public function allows(string $permission, array $context = []): bool
56 56
     {
57 57
         $allows = false;
58
-        foreach ($this->getRoles() as $role) {
59
-            if (!$this->permissions->hasRole($role)) {
58
+        foreach ($this->getRoles() as $role)
59
+        {
60
+            if (!$this->permissions->hasRole($role))
61
+            {
60 62
                 continue;
61 63
             }
62 64
 
@@ -103,13 +105,17 @@  discard block
 block discarded – undo
103 105
      */
104 106
     public function getActor(): ActorInterface
105 107
     {
106
-        if (!is_null($this->actor)) {
108
+        if (!is_null($this->actor))
109
+        {
107 110
             return $this->actor;
108 111
         }
109 112
 
110
-        try {
113
+        try
114
+        {
111 115
             return $this->container->get(ActorInterface::class);
112
-        } catch (NotFoundExceptionInterface $e) {
116
+        }
117
+        catch (NotFoundExceptionInterface $e)
118
+        {
113 119
             throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e);
114 120
         }
115 121
     }
Please login to merge, or discard this patch.
src/Bootloader/Auth/AuthBootloader.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function getActor(TokenInterface $token): ?object
53 53
     {
54
-        foreach ($this->getProviders() as $provider) {
55
-            if (!$provider instanceof ActorProviderInterface) {
54
+        foreach ($this->getProviders() as $provider){
55
+            if (!$provider instanceof ActorProviderInterface){
56 56
                 throw new AuthException(sprintf(
57 57
                     'Expected `ActorProviderInterface`, got `%s`',
58 58
                     get_class($provider)
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             }
61 61
 
62 62
             $actor = $provider->getActor($token);
63
-            if ($actor !== null) {
63
+            if ($actor !== null){
64 64
                 return $actor;
65 65
             }
66 66
         }
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
      */
84 84
     private function getProviders(): \Generator
85 85
     {
86
-        foreach ($this->actorProvider as $provider) {
87
-            if ($provider instanceof Autowire) {
86
+        foreach ($this->actorProvider as $provider){
87
+            if ($provider instanceof Autowire){
88 88
                 yield $provider->resolve($this->factory);
89 89
                 continue;
90 90
             }
91 91
 
92
-            if (is_object($provider)) {
92
+            if (is_object($provider)){
93 93
                 yield $provider;
94 94
                 continue;
95 95
             }
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,8 +51,10 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function getActor(TokenInterface $token): ?object
53 53
     {
54
-        foreach ($this->getProviders() as $provider) {
55
-            if (!$provider instanceof ActorProviderInterface) {
54
+        foreach ($this->getProviders() as $provider)
55
+        {
56
+            if (!$provider instanceof ActorProviderInterface)
57
+            {
56 58
                 throw new AuthException(sprintf(
57 59
                     'Expected `ActorProviderInterface`, got `%s`',
58 60
                     get_class($provider)
@@ -60,7 +62,8 @@  discard block
 block discarded – undo
60 62
             }
61 63
 
62 64
             $actor = $provider->getActor($token);
63
-            if ($actor !== null) {
65
+            if ($actor !== null)
66
+            {
64 67
                 return $actor;
65 68
             }
66 69
         }
@@ -83,13 +86,16 @@  discard block
 block discarded – undo
83 86
      */
84 87
     private function getProviders(): \Generator
85 88
     {
86
-        foreach ($this->actorProvider as $provider) {
87
-            if ($provider instanceof Autowire) {
89
+        foreach ($this->actorProvider as $provider)
90
+        {
91
+            if ($provider instanceof Autowire)
92
+            {
88 93
                 yield $provider->resolve($this->factory);
89 94
                 continue;
90 95
             }
91 96
 
92
-            if (is_object($provider)) {
97
+            if (is_object($provider))
98
+            {
93 99
                 yield $provider;
94 100
                 continue;
95 101
             }
Please login to merge, or discard this patch.
src/Bootloader/Auth/HttpAuthBootloader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,8 +87,8 @@
 block discarded – undo
87 87
         $registry = new TransportRegistry();
88 88
         $registry->setDefaultTransport($config->getDefaultTransport());
89 89
 
90
-        foreach ($config->getTransports() as $name => $transport) {
91
-            if ($transport instanceof Autowire) {
90
+        foreach ($config->getTransports() as $name => $transport){
91
+            if ($transport instanceof Autowire){
92 92
                 $transport = $transport->resolve($factory);
93 93
             }
94 94
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,8 +87,10 @@
 block discarded – undo
87 87
         $registry = new TransportRegistry();
88 88
         $registry->setDefaultTransport($config->getDefaultTransport());
89 89
 
90
-        foreach ($config->getTransports() as $name => $transport) {
91
-            if ($transport instanceof Autowire) {
90
+        foreach ($config->getTransports() as $name => $transport)
91
+        {
92
+            if ($transport instanceof Autowire)
93
+            {
92 94
                 $transport = $transport->resolve($factory);
93 95
             }
94 96
 
Please login to merge, or discard this patch.
src/Bootloader/Auth/SecurityActorBootloader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
     private function actor(AuthContextInterface $context): ActorInterface
39 39
     {
40 40
         $actor = $context->getActor();
41
-        if ($actor instanceof ActorInterface) {
41
+        if ($actor instanceof ActorInterface){
42 42
             return $actor;
43 43
         }
44 44
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@
 block discarded – undo
38 38
     private function actor(AuthContextInterface $context): ActorInterface
39 39
     {
40 40
         $actor = $context->getActor();
41
-        if ($actor instanceof ActorInterface) {
41
+        if ($actor instanceof ActorInterface)
42
+        {
42 43
             return $actor;
43 44
         }
44 45
 
Please login to merge, or discard this patch.
src/Auth/Config/AuthConfig.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
     public function getTransports(): array
42 42
     {
43 43
         $transports = [];
44
-        foreach ($this->config['transports'] as $name => $transport) {
45
-            if (is_object($transport) && !$transport instanceof Autowire) {
44
+        foreach ($this->config['transports'] as $name => $transport){
45
+            if (is_object($transport) && !$transport instanceof Autowire){
46 46
                 $transports[$name] = $transport;
47 47
                 continue;
48 48
             }
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
      */
62 62
     private function wire($item): Autowire
63 63
     {
64
-        if ($item instanceof Autowire) {
64
+        if ($item instanceof Autowire){
65 65
             return $item;
66 66
         }
67 67
 
68
-        if (is_string($item)) {
68
+        if (is_string($item)){
69 69
             return new Autowire($item);
70 70
         }
71 71
 
72
-        if (is_array($item) && isset($item['class'])) {
72
+        if (is_array($item) && isset($item['class'])){
73 73
             return new Autowire($item['class'], $item['options'] ?? []);
74 74
         }
75 75
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,8 +41,10 @@  discard block
 block discarded – undo
41 41
     public function getTransports(): array
42 42
     {
43 43
         $transports = [];
44
-        foreach ($this->config['transports'] as $name => $transport) {
45
-            if (is_object($transport) && !$transport instanceof Autowire) {
44
+        foreach ($this->config['transports'] as $name => $transport)
45
+        {
46
+            if (is_object($transport) && !$transport instanceof Autowire)
47
+            {
46 48
                 $transports[$name] = $transport;
47 49
                 continue;
48 50
             }
@@ -61,15 +63,18 @@  discard block
 block discarded – undo
61 63
      */
62 64
     private function wire($item): Autowire
63 65
     {
64
-        if ($item instanceof Autowire) {
66
+        if ($item instanceof Autowire)
67
+        {
65 68
             return $item;
66 69
         }
67 70
 
68
-        if (is_string($item)) {
71
+        if (is_string($item))
72
+        {
69 73
             return new Autowire($item);
70 74
         }
71 75
 
72
-        if (is_array($item) && isset($item['class'])) {
76
+        if (is_array($item) && isset($item['class']))
77
+        {
73 78
             return new Autowire($item['class'], $item['options'] ?? []);
74 79
         }
75 80
 
Please login to merge, or discard this patch.
src/Auth/Session/Token.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
     public static function unpack(array $data): Token
101 101
     {
102 102
         $expiresAt = null;
103
-        if ($data['expiresAt'] != null) {
103
+        if ($data['expiresAt'] != null){
104 104
             $expiresAt = (new \DateTimeImmutable())->setTimestamp($data['expiresAt']);
105 105
         }
106 106
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,8 @@
 block discarded – undo
100 100
     public static function unpack(array $data): Token
101 101
     {
102 102
         $expiresAt = null;
103
-        if ($data['expiresAt'] != null) {
103
+        if ($data['expiresAt'] != null)
104
+        {
104 105
             $expiresAt = (new \DateTimeImmutable())->setTimestamp($data['expiresAt']);
105 106
         }
106 107
 
Please login to merge, or discard this patch.
src/Session/Middleware/SessionMiddleware.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         CookiesConfig $cookiesConfig,
61 61
         SessionFactory $factory,
62 62
         ScopeInterface $scope
63
-    ) {
63
+    ){
64 64
         $this->config = $config;
65 65
         $this->httpConfig = $httpConfig;
66 66
         $this->cookiesConfig = $cookiesConfig;
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
             $this->fetchID($request)
80 80
         );
81 81
 
82
-        try {
82
+        try{
83 83
             $response = $this->scope->runScope(
84 84
                 [SessionInterface::class => $session],
85 85
                 function () use ($handler, $request, $session) {
86 86
                     return $handler->handle($request->withAttribute(static::ATTRIBUTE, $session));
87 87
                 }
88 88
             );
89
-        } catch (\Throwable $e) {
89
+        }catch (\Throwable $e){
90 90
             $session->abort();
91 91
             throw $e;
92 92
         }
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
         Request $request,
106 106
         Response $response
107 107
     ): Response {
108
-        if (!$session->isStarted()) {
108
+        if (!$session->isStarted()){
109 109
             return $response;
110 110
         }
111 111
 
112 112
         $session->commit();
113 113
 
114 114
         //SID changed
115
-        if ($this->fetchID($request) != $session->getID()) {
115
+        if ($this->fetchID($request) != $session->getID()){
116 116
             return $this->withCookie($request, $response, $session->getID());
117 117
         }
118 118
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     protected function fetchID(Request $request): ?string
130 130
     {
131 131
         $cookies = $request->getCookieParams();
132
-        if (empty($cookies[$this->config->getCookie()])) {
132
+        if (empty($cookies[$this->config->getCookie()])){
133 133
             return null;
134 134
         }
135 135
 
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
     protected function clientSignature(Request $request): string
163 163
     {
164 164
         $signature = '';
165
-        foreach (static::SIGNATURE_HEADERS as $header) {
166
-            $signature .= $request->getHeaderLine($header) . ';';
165
+        foreach (static::SIGNATURE_HEADERS as $header){
166
+            $signature .= $request->getHeaderLine($header).';';
167 167
         }
168 168
 
169 169
         return hash('sha256', $signature);
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -79,14 +79,18 @@  discard block
 block discarded – undo
79 79
             $this->fetchID($request)
80 80
         );
81 81
 
82
-        try {
82
+        try
83
+        {
83 84
             $response = $this->scope->runScope(
84 85
                 [SessionInterface::class => $session],
85
-                function () use ($handler, $request, $session) {
86
+                function () use ($handler, $request, $session)
87
+                {
86 88
                     return $handler->handle($request->withAttribute(static::ATTRIBUTE, $session));
87 89
                 }
88 90
             );
89
-        } catch (\Throwable $e) {
91
+        }
92
+        catch (\Throwable $e)
93
+        {
90 94
             $session->abort();
91 95
             throw $e;
92 96
         }
@@ -105,14 +109,16 @@  discard block
 block discarded – undo
105 109
         Request $request,
106 110
         Response $response
107 111
     ): Response {
108
-        if (!$session->isStarted()) {
112
+        if (!$session->isStarted())
113
+        {
109 114
             return $response;
110 115
         }
111 116
 
112 117
         $session->commit();
113 118
 
114 119
         //SID changed
115
-        if ($this->fetchID($request) != $session->getID()) {
120
+        if ($this->fetchID($request) != $session->getID())
121
+        {
116 122
             return $this->withCookie($request, $response, $session->getID());
117 123
         }
118 124
 
@@ -129,7 +135,8 @@  discard block
 block discarded – undo
129 135
     protected function fetchID(Request $request): ?string
130 136
     {
131 137
         $cookies = $request->getCookieParams();
132
-        if (empty($cookies[$this->config->getCookie()])) {
138
+        if (empty($cookies[$this->config->getCookie()]))
139
+        {
133 140
             return null;
134 141
         }
135 142
 
@@ -162,7 +169,8 @@  discard block
 block discarded – undo
162 169
     protected function clientSignature(Request $request): string
163 170
     {
164 171
         $signature = '';
165
-        foreach (static::SIGNATURE_HEADERS as $header) {
172
+        foreach (static::SIGNATURE_HEADERS as $header)
173
+        {
166 174
             $signature .= $request->getHeaderLine($header) . ';';
167 175
         }
168 176
 
Please login to merge, or discard this patch.
tests/app/src/Bootloader/AppBootloader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
             new Route('/auth/<action>', new Controller(AuthController::class))
50 50
         );
51 51
 
52
-        $views->addDirectory('custom', __DIR__ . '/../../views/custom/');
52
+        $views->addDirectory('custom', __DIR__.'/../../views/custom/');
53 53
         $views->addEngine(TestEngine::class);
54 54
 
55 55
         $validation->addAlias('aliased', 'notEmpty');
Please login to merge, or discard this patch.
tests/app/src/Bootloader/AuthBootloader.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 {
22 22
     public function boot(EnvironmentInterface $env, BootloadManager $bootloadManager): void
23 23
     {
24
-        if ($env->get('CYCLE_AUTH')) {
24
+        if ($env->get('CYCLE_AUTH')){
25 25
             $bootloadManager->bootload([CycleTokensBootloader::class]);
26 26
             return;
27 27
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@
 block discarded – undo
21 21
 {
22 22
     public function boot(EnvironmentInterface $env, BootloadManager $bootloadManager): void
23 23
     {
24
-        if ($env->get('CYCLE_AUTH')) {
24
+        if ($env->get('CYCLE_AUTH'))
25
+        {
25 26
             $bootloadManager->bootload([CycleTokensBootloader::class]);
26 27
             return;
27 28
         }
Please login to merge, or discard this patch.