@@ -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 |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | string $filename, |
| 26 | 26 | string $destination, |
| 27 | 27 | string $mergeMode = self::FOLLOW, |
| 28 | - int $mode = FilesInterface::READONLY |
|
| 28 | + int $mode = FilesInterface::readonly |
|
| 29 | 29 | ): void; |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | string $directory, |
| 38 | 38 | string $destination, |
| 39 | 39 | string $mergeMode = self::REPLACE, |
| 40 | - int $mode = FilesInterface::READONLY |
|
| 40 | + int $mode = FilesInterface::readonly |
|
| 41 | 41 | ): void; |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -45,5 +45,5 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @throws PublishException |
| 47 | 47 | */ |
| 48 | - public function ensureDirectory(string $directory, int $mode = FilesInterface::READONLY): void; |
|
| 48 | + public function ensureDirectory(string $directory, int $mode = FilesInterface::readonly): void; |
|
| 49 | 49 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly FilesInterface $files |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function publish( |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | string $mergeMode = self::FOLLOW, |
| 25 | 25 | int $mode = FilesInterface::READONLY |
| 26 | 26 | ): void { |
| 27 | - if (!$this->files->isFile($filename)) { |
|
| 27 | + if (!$this->files->isFile($filename)){ |
|
| 28 | 28 | throw new PublishException(\sprintf("Given '%s' is not valid file", $filename)); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if ($this->files->exists($destination)) { |
|
| 32 | - if ($this->files->md5($destination) === $this->files->md5($filename)) { |
|
| 31 | + if ($this->files->exists($destination)){ |
|
| 32 | + if ($this->files->md5($destination) === $this->files->md5($filename)){ |
|
| 33 | 33 | //Nothing to do |
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if ($mergeMode === self::FOLLOW) { |
|
| 37 | + if ($mergeMode === self::FOLLOW){ |
|
| 38 | 38 | return; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | string $mergeMode = self::REPLACE, |
| 54 | 54 | int $mode = FilesInterface::READONLY |
| 55 | 55 | ): void { |
| 56 | - if (!$this->files->isDirectory($directory)) { |
|
| 56 | + if (!$this->files->isDirectory($directory)){ |
|
| 57 | 57 | throw new PublishException(\sprintf("Given '%s' is not valid directory", $directory)); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $finder = new Finder(); |
| 61 | 61 | $finder->files()->in($directory); |
| 62 | 62 | |
| 63 | - foreach ($finder->getIterator() as $file) { |
|
| 63 | + foreach ($finder->getIterator() as $file){ |
|
| 64 | 64 | $this->publish( |
| 65 | 65 | (string)$file, |
| 66 | - $destination . '/' . $file->getRelativePathname(), |
|
| 66 | + $destination.'/'.$file->getRelativePathname(), |
|
| 67 | 67 | $mergeMode, |
| 68 | 68 | $mode |
| 69 | 69 | ); |
@@ -24,17 +24,21 @@ discard block |
||
| 24 | 24 | string $mergeMode = self::FOLLOW, |
| 25 | 25 | int $mode = FilesInterface::READONLY |
| 26 | 26 | ): void { |
| 27 | - if (!$this->files->isFile($filename)) { |
|
| 27 | + if (!$this->files->isFile($filename)) |
|
| 28 | + { |
|
| 28 | 29 | throw new PublishException(\sprintf("Given '%s' is not valid file", $filename)); |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - if ($this->files->exists($destination)) { |
|
| 32 | - if ($this->files->md5($destination) === $this->files->md5($filename)) { |
|
| 32 | + if ($this->files->exists($destination)) |
|
| 33 | + { |
|
| 34 | + if ($this->files->md5($destination) === $this->files->md5($filename)) |
|
| 35 | + { |
|
| 33 | 36 | //Nothing to do |
| 34 | 37 | return; |
| 35 | 38 | } |
| 36 | 39 | |
| 37 | - if ($mergeMode === self::FOLLOW) { |
|
| 40 | + if ($mergeMode === self::FOLLOW) |
|
| 41 | + { |
|
| 38 | 42 | return; |
| 39 | 43 | } |
| 40 | 44 | } |
@@ -53,14 +57,16 @@ discard block |
||
| 53 | 57 | string $mergeMode = self::REPLACE, |
| 54 | 58 | int $mode = FilesInterface::READONLY |
| 55 | 59 | ): void { |
| 56 | - if (!$this->files->isDirectory($directory)) { |
|
| 60 | + if (!$this->files->isDirectory($directory)) |
|
| 61 | + { |
|
| 57 | 62 | throw new PublishException(\sprintf("Given '%s' is not valid directory", $directory)); |
| 58 | 63 | } |
| 59 | 64 | |
| 60 | 65 | $finder = new Finder(); |
| 61 | 66 | $finder->files()->in($directory); |
| 62 | 67 | |
| 63 | - foreach ($finder->getIterator() as $file) { |
|
| 68 | + foreach ($finder->getIterator() as $file) |
|
| 69 | + { |
|
| 64 | 70 | $this->publish( |
| 65 | 71 | (string)$file, |
| 66 | 72 | $destination . '/' . $file->getRelativePathname(), |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | string $filename, |
| 23 | 23 | string $destination, |
| 24 | 24 | string $mergeMode = self::FOLLOW, |
| 25 | - int $mode = FilesInterface::READONLY |
|
| 25 | + int $mode = FilesInterface::readonly |
|
| 26 | 26 | ): void { |
| 27 | 27 | if (!$this->files->isFile($filename)) { |
| 28 | 28 | throw new PublishException(\sprintf("Given '%s' is not valid file", $filename)); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | string $directory, |
| 52 | 52 | string $destination, |
| 53 | 53 | string $mergeMode = self::REPLACE, |
| 54 | - int $mode = FilesInterface::READONLY |
|
| 54 | + int $mode = FilesInterface::readonly |
|
| 55 | 55 | ): void { |
| 56 | 56 | if (!$this->files->isDirectory($directory)) { |
| 57 | 57 | throw new PublishException(\sprintf("Given '%s' is not valid directory", $directory)); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function ensureDirectory(string $directory, int $mode = FilesInterface::READONLY): void |
|
| 73 | + public function ensureDirectory(string $directory, int $mode = FilesInterface::readonly): void |
|
| 74 | 74 | { |
| 75 | 75 | $this->files->ensureDirectory($directory, $mode); |
| 76 | 76 | } |
@@ -49,13 +49,18 @@ |
||
| 49 | 49 | /** @var Console $console */ |
| 50 | 50 | $console = $this->container->get(Console::class); |
| 51 | 51 | |
| 52 | - try { |
|
| 52 | + try |
|
| 53 | + { |
|
| 53 | 54 | return $console->start($input ?? new ArgvInput(), $output); |
| 54 | - } catch (Throwable $e) { |
|
| 55 | + } |
|
| 56 | + catch (Throwable $e) |
|
| 57 | + { |
|
| 55 | 58 | $this->handleException($e, $output); |
| 56 | 59 | |
| 57 | 60 | return 255; |
| 58 | - } finally { |
|
| 61 | + } |
|
| 62 | + finally |
|
| 63 | + { |
|
| 59 | 64 | $listener->disable(); |
| 60 | 65 | $this->finalizer->finalize(false); |
| 61 | 66 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | private readonly FinalizerInterface $finalizer, |
| 30 | 30 | private readonly ContainerInterface $container, |
| 31 | 31 | private readonly ExceptionHandlerInterface $errorHandler, |
| 32 | - ) { |
|
| 32 | + ){ |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public static function canServe(EnvironmentInterface $env): bool |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | /** @var Console $console */ |
| 52 | 52 | $console = $this->container->get(Console::class); |
| 53 | 53 | |
| 54 | - try { |
|
| 54 | + try{ |
|
| 55 | 55 | return $console->start($input ?? new ArgvInput(), $output); |
| 56 | - } catch (Throwable $e) { |
|
| 56 | + }catch (Throwable $e){ |
|
| 57 | 57 | $this->handleException($e, $output); |
| 58 | 58 | |
| 59 | 59 | return 255; |
| 60 | - } finally { |
|
| 60 | + }finally{ |
|
| 61 | 61 | $listener->disable(); |
| 62 | 62 | $this->finalizer->finalize(false); |
| 63 | 63 | } |
@@ -24,11 +24,13 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | public function confirmToProceed(string $message = 'Application in production.'): bool |
| 26 | 26 | { |
| 27 | - if (!$this->appEnv->isProduction()) { |
|
| 27 | + if (!$this->appEnv->isProduction()) |
|
| 28 | + { |
|
| 28 | 29 | return true; |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - if ($this->hasOption('force') && $this->option('force')) { |
|
| 32 | + if ($this->hasOption('force') && $this->option('force')) |
|
| 33 | + { |
|
| 32 | 34 | return true; |
| 33 | 35 | } |
| 34 | 36 | |
@@ -36,7 +38,8 @@ discard block |
||
| 36 | 38 | |
| 37 | 39 | $confirmed = $this->confirm('Do you really wish to run command?'); |
| 38 | 40 | |
| 39 | - if (!$confirmed) { |
|
| 41 | + if (!$confirmed) |
|
| 42 | + { |
|
| 40 | 43 | $this->comment('Command Canceled!'); |
| 41 | 44 | |
| 42 | 45 | return false; |
@@ -21,18 +21,18 @@ discard block |
||
| 21 | 21 | private readonly AppEnvironment $appEnv, |
| 22 | 22 | InputInterface $input, |
| 23 | 23 | OutputInterface $output, |
| 24 | - ) { |
|
| 24 | + ){ |
|
| 25 | 25 | $this->input = $input; |
| 26 | 26 | $this->output = $output instanceof SymfonyStyle ? $output : new SymfonyStyle($input, $output); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function confirmToProceed(string $message = 'Application in production.'): bool |
| 30 | 30 | { |
| 31 | - if (!$this->appEnv->isProduction()) { |
|
| 31 | + if (!$this->appEnv->isProduction()){ |
|
| 32 | 32 | return true; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if ($this->hasOption('force') && $this->option('force')) { |
|
| 35 | + if ($this->hasOption('force') && $this->option('force')){ |
|
| 36 | 36 | return true; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $confirmed = $this->confirm('Do you really wish to run command?'); |
| 42 | 42 | |
| 43 | - if (!$confirmed) { |
|
| 43 | + if (!$confirmed){ |
|
| 44 | 44 | $this->comment('Command Canceled!'); |
| 45 | 45 | |
| 46 | 46 | return false; |