Skip to content

Commit

Permalink
Fix for PHP <7.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fracsi authored and chalasr committed Dec 8, 2023
1 parent 3df8317 commit 6d985be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 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
2 changes: 1 addition & 1 deletion Security/Http/Cookie/JWTCookieProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function createCookie(string $jwt, ?string $name = null, $expiresAt = nul
$httpOnly ?: $this->defaultHttpOnly,
false,
$sameSite ?: $this->defaultSameSite,
$partitioned ?: $this->defaultPartitioned,
$partitioned ?: $this->defaultPartitioned
);
}
}

0 comments on commit 6d985be

Please sign in to comment.