Skip to content

Commit

Permalink
Fix for PHP <7.4 compatibility
Browse files Browse the repository at this point in the history
Follow up for lexik#1174
  • Loading branch information
fracsi committed Dec 6, 2023
1 parent 3df8317 commit 62b9849
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Command/EnableEncryptionConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$algorithms = $this->algorithmManagerFactory->all();
$availableKeyEncryptionAlgorithms = array_map(
static fn (Algorithm $algorithm): string => $algorithm->name(),
array_filter($algorithms, static fn (Algorithm $algorithm): bool => ($algorithm instanceof KeyEncryptionAlgorithm && $algorithm->name() !== 'dir'))
static function (Algorithm $algorithm): string {
return $algorithm->name();
},
array_filter($algorithms, static function (Algorithm $algorithm): bool {
return ($algorithm instanceof KeyEncryptionAlgorithm && $algorithm->name() !== 'dir');
})
);
$availableContentEncryptionAlgorithms = array_map(
static fn (Algorithm $algorithm): string => $algorithm->name(),
array_filter($algorithms, static fn (Algorithm $algorithm): bool => $algorithm instanceof ContentEncryptionAlgorithm)
static function (Algorithm $algorithm): string {
return $algorithm->name();
},
array_filter($algorithms, static function (Algorithm $algorithm): bool {
return $algorithm instanceof ContentEncryptionAlgorithm;
})
);

$keyEncryptionAlgorithmAlias = $io->choice('Key Encryption Algorithm', $availableKeyEncryptionAlgorithms);
Expand Down Expand Up @@ -215,7 +223,7 @@ private function checkRequirements(): void
JWEBuilder::class => 'web-token/jwt-encryption',
];
if ($this->algorithmManagerFactory === null) {
throw new \RuntimeException(sprintf('The package "web-token/jwt-bundle" is missing. Please install it for using this migration tool.', $requirement));
throw new \RuntimeException('The package "web-token/jwt-bundle" is missing. Please install it for using this migration tool.');
}
foreach (array_keys($requirements) as $requirement) {
if (!class_exists($requirement)) {
Expand Down

0 comments on commit 62b9849

Please sign in to comment.