@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | public function __construct( |
| 12 | 12 | private readonly string $id, |
| 13 | 13 | private readonly array $payload, |
| 14 | - private readonly ?\DateTimeInterface $expiresAt = null |
|
| 15 | - ) { |
|
| 14 | + private readonly ? \DateTimeInterface $expiresAt = null |
|
| 15 | + ){ |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function getID(): string |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | public static function unpack(array $data): Token |
| 51 | 51 | { |
| 52 | 52 | $expiresAt = null; |
| 53 | - if ($data['expiresAt'] !== null) { |
|
| 53 | + if ($data['expiresAt'] !== null){ |
|
| 54 | 54 | $expiresAt = (new \DateTimeImmutable())->setTimestamp($data['expiresAt']); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -50,7 +50,8 @@ |
||
| 50 | 50 | public static function unpack(array $data): Token |
| 51 | 51 | { |
| 52 | 52 | $expiresAt = null; |
| 53 | - if ($data['expiresAt'] !== null) { |
|
| 53 | + if ($data['expiresAt'] !== null) |
|
| 54 | + { |
|
| 54 | 55 | $expiresAt = (new \DateTimeImmutable())->setTimestamp($data['expiresAt']); |
| 55 | 56 | } |
| 56 | 57 | |
@@ -19,28 +19,28 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function __construct( |
| 21 | 21 | private readonly SessionScope $session |
| 22 | - ) { |
|
| 22 | + ){ |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function load(string $id): ?TokenInterface |
| 26 | 26 | { |
| 27 | - try { |
|
| 27 | + try{ |
|
| 28 | 28 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
| 29 | - if ($tokenData === null) { |
|
| 29 | + if ($tokenData === null){ |
|
| 30 | 30 | return null; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | $token = Token::unpack($tokenData); |
| 34 | - } catch (\Throwable $e) { |
|
| 35 | - throw new TokenStorageException('Unable to load session token', (int) $e->getCode(), $e); |
|
| 34 | + }catch (\Throwable $e){ |
|
| 35 | + throw new TokenStorageException('Unable to load session token', (int)$e->getCode(), $e); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if (!\hash_equals($token->getID(), $id)) { |
|
| 38 | + if (!\hash_equals($token->getID(), $id)){ |
|
| 39 | 39 | return null; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $expiresAt = $token->getExpiresAt(); |
| 43 | - if ($expiresAt !== null && $expiresAt < new \DateTimeImmutable()) { |
|
| 43 | + if ($expiresAt !== null && $expiresAt < new \DateTimeImmutable()){ |
|
| 44 | 44 | $this->delete($token); |
| 45 | 45 | return null; |
| 46 | 46 | } |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
| 52 | 52 | { |
| 53 | - try { |
|
| 53 | + try{ |
|
| 54 | 54 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
| 55 | 55 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
| 56 | 56 | |
| 57 | 57 | return $token; |
| 58 | - } catch (\Throwable $e) { |
|
| 59 | - throw new TokenStorageException('Unable to create session token', (int) $e->getCode(), $e); |
|
| 58 | + }catch (\Throwable $e){ |
|
| 59 | + throw new TokenStorageException('Unable to create session token', (int)$e->getCode(), $e); |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
@@ -24,23 +24,29 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function load(string $id): ?TokenInterface |
| 26 | 26 | { |
| 27 | - try { |
|
| 27 | + try |
|
| 28 | + { |
|
| 28 | 29 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
| 29 | - if ($tokenData === null) { |
|
| 30 | + if ($tokenData === null) |
|
| 31 | + { |
|
| 30 | 32 | return null; |
| 31 | 33 | } |
| 32 | 34 | |
| 33 | 35 | $token = Token::unpack($tokenData); |
| 34 | - } catch (\Throwable $e) { |
|
| 36 | + } |
|
| 37 | + catch (\Throwable $e) |
|
| 38 | + { |
|
| 35 | 39 | throw new TokenStorageException('Unable to load session token', (int) $e->getCode(), $e); |
| 36 | 40 | } |
| 37 | 41 | |
| 38 | - if (!\hash_equals($token->getID(), $id)) { |
|
| 42 | + if (!\hash_equals($token->getID(), $id)) |
|
| 43 | + { |
|
| 39 | 44 | return null; |
| 40 | 45 | } |
| 41 | 46 | |
| 42 | 47 | $expiresAt = $token->getExpiresAt(); |
| 43 | - if ($expiresAt !== null && $expiresAt < new \DateTimeImmutable()) { |
|
| 48 | + if ($expiresAt !== null && $expiresAt < new \DateTimeImmutable()) |
|
| 49 | + { |
|
| 44 | 50 | $this->delete($token); |
| 45 | 51 | return null; |
| 46 | 52 | } |
@@ -50,12 +56,15 @@ discard block |
||
| 50 | 56 | |
| 51 | 57 | public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface |
| 52 | 58 | { |
| 53 | - try { |
|
| 59 | + try |
|
| 60 | + { |
|
| 54 | 61 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
| 55 | 62 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
| 56 | 63 | |
| 57 | 64 | return $token; |
| 58 | - } catch (\Throwable $e) { |
|
| 65 | + } |
|
| 66 | + catch (\Throwable $e) |
|
| 67 | + { |
|
| 59 | 68 | throw new TokenStorageException('Unable to create session token', (int) $e->getCode(), $e); |
| 60 | 69 | } |
| 61 | 70 | } |
@@ -68,9 +68,12 @@ |
||
| 68 | 68 | |
| 69 | 69 | private function getAuthContext(): AuthContextInterface |
| 70 | 70 | { |
| 71 | - try { |
|
| 71 | + try |
|
| 72 | + { |
|
| 72 | 73 | return $this->container->get(AuthContextInterface::class); |
| 73 | - } catch (NotFoundExceptionInterface $e) { |
|
| 74 | + } |
|
| 75 | + catch (NotFoundExceptionInterface $e) |
|
| 76 | + { |
|
| 74 | 77 | throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); |
| 75 | 78 | } |
| 76 | 79 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | public function __construct( |
| 19 | 19 | #[Proxy] private readonly ContainerInterface $container |
| 20 | - ) { |
|
| 20 | + ){ |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | private function getAuthContext(): AuthContextInterface |
| 72 | 72 | { |
| 73 | - try { |
|
| 73 | + try{ |
|
| 74 | 74 | return $this->container->get(AuthContextInterface::class); |
| 75 | - } catch (NotFoundExceptionInterface $e) { |
|
| 75 | + }catch (NotFoundExceptionInterface $e){ |
|
| 76 | 76 | throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | private ReaderInterface $reader, |
| 22 | 22 | private ContainerInterface $container, |
| 23 | 23 | private ?EventDispatcherInterface $dispatcher = null |
| 24 | - ) { |
|
| 24 | + ){ |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed |
| 31 | 31 | { |
| 32 | 32 | $annotation = $this->readAnnotation($controller, $action); |
| 33 | - if ($core instanceof InterceptorPipeline && $annotation->skipNext) { |
|
| 33 | + if ($core instanceof InterceptorPipeline && $annotation->skipNext){ |
|
| 34 | 34 | $this->removeNextInterceptorsFromOriginalPipeline($core); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $pipeline = $this->getCachedPipeline($controller, $action, $annotation); |
| 38 | - if (!empty($pipeline)) { |
|
| 39 | - if ($core instanceof InterceptorPipeline) { |
|
| 38 | + if (!empty($pipeline)){ |
|
| 39 | + if ($core instanceof InterceptorPipeline){ |
|
| 40 | 40 | $this->injectInterceptorsIntoOriginalPipeline($core, $pipeline); |
| 41 | - } else { |
|
| 41 | + }else{ |
|
| 42 | 42 | $core = new InterceptableCore($core, $this->dispatcher); |
| 43 | - foreach ($pipeline as $interceptor) { |
|
| 43 | + foreach ($pipeline as $interceptor){ |
|
| 44 | 44 | $core->addInterceptor($interceptor); |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | private function readAnnotation(string $controller, string $action): Pipeline |
| 53 | 53 | { |
| 54 | - try { |
|
| 54 | + try{ |
|
| 55 | 55 | $method = new \ReflectionMethod($controller, $action); |
| 56 | - } catch (\ReflectionException) { |
|
| 56 | + }catch (\ReflectionException){ |
|
| 57 | 57 | return new Pipeline(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 70 | 70 | $newInterceptors = []; |
| 71 | - foreach ($oldInterceptors as $interceptor) { |
|
| 71 | + foreach ($oldInterceptors as $interceptor){ |
|
| 72 | 72 | $newInterceptors[] = $interceptor; |
| 73 | - if ($interceptor instanceof self) { |
|
| 73 | + if ($interceptor instanceof self){ |
|
| 74 | 74 | break; |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if (\count($newInterceptors) !== \count($oldInterceptors)) { |
|
| 78 | + if (\count($newInterceptors) !== \count($oldInterceptors)){ |
|
| 79 | 79 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 88 | 88 | $newInterceptors = []; |
| 89 | - foreach ($oldInterceptors as $interceptor) { |
|
| 89 | + foreach ($oldInterceptors as $interceptor){ |
|
| 90 | 90 | $newInterceptors[] = $interceptor; |
| 91 | - if ($interceptor instanceof self) { |
|
| 92 | - foreach ($interceptors as $newInterceptor) { |
|
| 91 | + if ($interceptor instanceof self){ |
|
| 92 | + foreach ($interceptors as $newInterceptor){ |
|
| 93 | 93 | $newInterceptors[] = $newInterceptor; |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if (\count($newInterceptors) !== \count($oldInterceptors)) { |
|
| 98 | + if (\count($newInterceptors) !== \count($oldInterceptors)){ |
|
| 99 | 99 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | private function getCachedPipeline(string $controller, string $action, Pipeline $annotation): array |
| 104 | 104 | { |
| 105 | 105 | $key = "{$controller}:{$action}"; |
| 106 | - if (!\array_key_exists($key, $this->cache)) { |
|
| 106 | + if (!\array_key_exists($key, $this->cache)){ |
|
| 107 | 107 | $this->cache[$key] = $this->extractAnnotationPipeline($annotation); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | private function extractAnnotationPipeline(Pipeline $annotation): array |
| 114 | 114 | { |
| 115 | 115 | $interceptors = []; |
| 116 | - foreach ($annotation->pipeline as $interceptor) { |
|
| 117 | - try { |
|
| 116 | + foreach ($annotation->pipeline as $interceptor){ |
|
| 117 | + try{ |
|
| 118 | 118 | $interceptors[] = $this->container->get($interceptor); |
| 119 | - } catch (\Throwable) { |
|
| 119 | + }catch (\Throwable){ |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -30,17 +30,23 @@ discard block |
||
| 30 | 30 | public function process(string $controller, string $action, array $parameters, CoreInterface $core): mixed |
| 31 | 31 | { |
| 32 | 32 | $annotation = $this->readAnnotation($controller, $action); |
| 33 | - if ($core instanceof InterceptorPipeline && $annotation->skipNext) { |
|
| 33 | + if ($core instanceof InterceptorPipeline && $annotation->skipNext) |
|
| 34 | + { |
|
| 34 | 35 | $this->removeNextInterceptorsFromOriginalPipeline($core); |
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | $pipeline = $this->getCachedPipeline($controller, $action, $annotation); |
| 38 | - if (!empty($pipeline)) { |
|
| 39 | - if ($core instanceof InterceptorPipeline) { |
|
| 39 | + if (!empty($pipeline)) |
|
| 40 | + { |
|
| 41 | + if ($core instanceof InterceptorPipeline) |
|
| 42 | + { |
|
| 40 | 43 | $this->injectInterceptorsIntoOriginalPipeline($core, $pipeline); |
| 41 | - } else { |
|
| 44 | + } |
|
| 45 | + else |
|
| 46 | + { |
|
| 42 | 47 | $core = new InterceptableCore($core, $this->dispatcher); |
| 43 | - foreach ($pipeline as $interceptor) { |
|
| 48 | + foreach ($pipeline as $interceptor) |
|
| 49 | + { |
|
| 44 | 50 | $core->addInterceptor($interceptor); |
| 45 | 51 | } |
| 46 | 52 | } |
@@ -51,9 +57,12 @@ discard block |
||
| 51 | 57 | |
| 52 | 58 | private function readAnnotation(string $controller, string $action): Pipeline |
| 53 | 59 | { |
| 54 | - try { |
|
| 60 | + try |
|
| 61 | + { |
|
| 55 | 62 | $method = new \ReflectionMethod($controller, $action); |
| 56 | - } catch (\ReflectionException) { |
|
| 63 | + } |
|
| 64 | + catch (\ReflectionException) |
|
| 65 | + { |
|
| 57 | 66 | return new Pipeline(); |
| 58 | 67 | } |
| 59 | 68 | |
@@ -68,14 +77,17 @@ discard block |
||
| 68 | 77 | |
| 69 | 78 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 70 | 79 | $newInterceptors = []; |
| 71 | - foreach ($oldInterceptors as $interceptor) { |
|
| 80 | + foreach ($oldInterceptors as $interceptor) |
|
| 81 | + { |
|
| 72 | 82 | $newInterceptors[] = $interceptor; |
| 73 | - if ($interceptor instanceof self) { |
|
| 83 | + if ($interceptor instanceof self) |
|
| 84 | + { |
|
| 74 | 85 | break; |
| 75 | 86 | } |
| 76 | 87 | } |
| 77 | 88 | |
| 78 | - if (\count($newInterceptors) !== \count($oldInterceptors)) { |
|
| 89 | + if (\count($newInterceptors) !== \count($oldInterceptors)) |
|
| 90 | + { |
|
| 79 | 91 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 80 | 92 | } |
| 81 | 93 | } |
@@ -86,16 +98,20 @@ discard block |
||
| 86 | 98 | |
| 87 | 99 | $oldInterceptors = $pipelineReflection->getValue($pipeline); |
| 88 | 100 | $newInterceptors = []; |
| 89 | - foreach ($oldInterceptors as $interceptor) { |
|
| 101 | + foreach ($oldInterceptors as $interceptor) |
|
| 102 | + { |
|
| 90 | 103 | $newInterceptors[] = $interceptor; |
| 91 | - if ($interceptor instanceof self) { |
|
| 92 | - foreach ($interceptors as $newInterceptor) { |
|
| 104 | + if ($interceptor instanceof self) |
|
| 105 | + { |
|
| 106 | + foreach ($interceptors as $newInterceptor) |
|
| 107 | + { |
|
| 93 | 108 | $newInterceptors[] = $newInterceptor; |
| 94 | 109 | } |
| 95 | 110 | } |
| 96 | 111 | } |
| 97 | 112 | |
| 98 | - if (\count($newInterceptors) !== \count($oldInterceptors)) { |
|
| 113 | + if (\count($newInterceptors) !== \count($oldInterceptors)) |
|
| 114 | + { |
|
| 99 | 115 | $pipelineReflection->setValue($pipeline, $newInterceptors); |
| 100 | 116 | } |
| 101 | 117 | } |
@@ -103,7 +119,8 @@ discard block |
||
| 103 | 119 | private function getCachedPipeline(string $controller, string $action, Pipeline $annotation): array |
| 104 | 120 | { |
| 105 | 121 | $key = "{$controller}:{$action}"; |
| 106 | - if (!\array_key_exists($key, $this->cache)) { |
|
| 122 | + if (!\array_key_exists($key, $this->cache)) |
|
| 123 | + { |
|
| 107 | 124 | $this->cache[$key] = $this->extractAnnotationPipeline($annotation); |
| 108 | 125 | } |
| 109 | 126 | |
@@ -113,10 +130,14 @@ discard block |
||
| 113 | 130 | private function extractAnnotationPipeline(Pipeline $annotation): array |
| 114 | 131 | { |
| 115 | 132 | $interceptors = []; |
| 116 | - foreach ($annotation->pipeline as $interceptor) { |
|
| 117 | - try { |
|
| 133 | + foreach ($annotation->pipeline as $interceptor) |
|
| 134 | + { |
|
| 135 | + try |
|
| 136 | + { |
|
| 118 | 137 | $interceptors[] = $this->container->get($interceptor); |
| 119 | - } catch (\Throwable) { |
|
| 138 | + } |
|
| 139 | + catch (\Throwable) |
|
| 140 | + { |
|
| 120 | 141 | } |
| 121 | 142 | } |
| 122 | 143 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | public function __construct( |
| 26 | 26 | private readonly ReaderInterface $reader, |
| 27 | 27 | private readonly ?string $namespace = null |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public function getPermission(string $controller, string $action): Permission |
| 35 | 35 | { |
| 36 | 36 | $key = \sprintf('%s:%s', $controller, $action); |
| 37 | - if (!\array_key_exists($key, $this->cache)) { |
|
| 37 | + if (!\array_key_exists($key, $this->cache)){ |
|
| 38 | 38 | $this->cache[$key] = $this->generatePermission($controller, $action); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -43,20 +43,20 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | private function generatePermission(string $controller, string $action): Permission |
| 45 | 45 | { |
| 46 | - try { |
|
| 46 | + try{ |
|
| 47 | 47 | $method = new \ReflectionMethod($controller, $action); |
| 48 | - } catch (\ReflectionException) { |
|
| 48 | + }catch (\ReflectionException){ |
|
| 49 | 49 | return Permission::failed(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $guarded = $this->reader->firstFunctionMetadata($method, Guarded::class); |
| 53 | - if (!$guarded instanceof Guarded) { |
|
| 53 | + if (!$guarded instanceof Guarded){ |
|
| 54 | 54 | return Permission::failed(); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $namespace = $this->reader->firstClassMetadata($method->getDeclaringClass(), GuardNamespace::class); |
| 58 | 58 | |
| 59 | - if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)) { |
|
| 59 | + if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)){ |
|
| 60 | 60 | return Permission::ok( |
| 61 | 61 | $this->makePermission($guarded, $method, $namespace), |
| 62 | 62 | $this->mapFailureException($guarded), |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | private function makePermission(Guarded $guarded, \ReflectionMethod $method, ?GuardNamespace $ns): string |
| 80 | 80 | { |
| 81 | 81 | $permission = []; |
| 82 | - if ($this->namespace) { |
|
| 82 | + if ($this->namespace){ |
|
| 83 | 83 | $permission[] = $this->namespace; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ($ns !== null && $ns->namespace) { |
|
| 86 | + if ($ns !== null && $ns->namespace){ |
|
| 87 | 87 | $permission[] = $ns->namespace; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -34,7 +34,8 @@ discard block |
||
| 34 | 34 | public function getPermission(string $controller, string $action): Permission |
| 35 | 35 | { |
| 36 | 36 | $key = \sprintf('%s:%s', $controller, $action); |
| 37 | - if (!\array_key_exists($key, $this->cache)) { |
|
| 37 | + if (!\array_key_exists($key, $this->cache)) |
|
| 38 | + { |
|
| 38 | 39 | $this->cache[$key] = $this->generatePermission($controller, $action); |
| 39 | 40 | } |
| 40 | 41 | |
@@ -43,20 +44,25 @@ discard block |
||
| 43 | 44 | |
| 44 | 45 | private function generatePermission(string $controller, string $action): Permission |
| 45 | 46 | { |
| 46 | - try { |
|
| 47 | + try |
|
| 48 | + { |
|
| 47 | 49 | $method = new \ReflectionMethod($controller, $action); |
| 48 | - } catch (\ReflectionException) { |
|
| 50 | + } |
|
| 51 | + catch (\ReflectionException) |
|
| 52 | + { |
|
| 49 | 53 | return Permission::failed(); |
| 50 | 54 | } |
| 51 | 55 | |
| 52 | 56 | $guarded = $this->reader->firstFunctionMetadata($method, Guarded::class); |
| 53 | - if (!$guarded instanceof Guarded) { |
|
| 57 | + if (!$guarded instanceof Guarded) |
|
| 58 | + { |
|
| 54 | 59 | return Permission::failed(); |
| 55 | 60 | } |
| 56 | 61 | |
| 57 | 62 | $namespace = $this->reader->firstClassMetadata($method->getDeclaringClass(), GuardNamespace::class); |
| 58 | 63 | |
| 59 | - if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)) { |
|
| 64 | + if ($guarded->permission || ($namespace instanceof GuardNamespace && $namespace->namespace)) |
|
| 65 | + { |
|
| 60 | 66 | return Permission::ok( |
| 61 | 67 | $this->makePermission($guarded, $method, $namespace), |
| 62 | 68 | $this->mapFailureException($guarded), |
@@ -79,11 +85,13 @@ discard block |
||
| 79 | 85 | private function makePermission(Guarded $guarded, \ReflectionMethod $method, ?GuardNamespace $ns): string |
| 80 | 86 | { |
| 81 | 87 | $permission = []; |
| 82 | - if ($this->namespace) { |
|
| 88 | + if ($this->namespace) |
|
| 89 | + { |
|
| 83 | 90 | $permission[] = $this->namespace; |
| 84 | 91 | } |
| 85 | 92 | |
| 86 | - if ($ns !== null && $ns->namespace) { |
|
| 93 | + if ($ns !== null && $ns->namespace) |
|
| 94 | + { |
|
| 87 | 95 | $permission[] = $ns->namespace; |
| 88 | 96 | } |
| 89 | 97 | |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public function __construct( |
| 27 | 27 | public readonly string $namespace |
| 28 | - ) { |
|
| 28 | + ){ |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -24,6 +24,6 @@ |
||
| 24 | 24 | public function __construct( |
| 25 | 25 | public readonly array $pipeline = [], |
| 26 | 26 | public readonly bool $skipNext = false |
| 27 | - ) { |
|
| 27 | + ){ |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -30,6 +30,6 @@ |
||
| 30 | 30 | /** @Enum({"notFound","unauthorized","forbidden","badAction","error"}) */ |
| 31 | 31 | public readonly string $else = 'forbidden', |
| 32 | 32 | public readonly ?string $errorMessage = null |
| 33 | - ) { |
|
| 33 | + ){ |
|
| 34 | 34 | } |
| 35 | 35 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function __construct( |
| 10 | 10 | private readonly FileSnapshot $fileSnapshot |
| 11 | - ) { |
|
| 11 | + ){ |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | public function register(\Throwable $e): SnapshotInterface |