Skip to content

Commit 7199e4c

Browse files
committed
Fully qualify the \extention_loaded('sodium') check
This allows OPcache to elide the condition at compile-time if it knows that ext/sodium is or is not available.
1 parent 5e9b582 commit 7199e4c

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/Base64.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function encode(
5353
#[\SensitiveParameter]
5454
string $binString
5555
): string {
56-
if (extension_loaded('sodium')) {
56+
if (\extension_loaded('sodium')) {
5757
$variant = match(static::class) {
5858
Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL,
5959
Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE,
@@ -85,7 +85,7 @@ public static function encodeUnpadded(
8585
#[\SensitiveParameter]
8686
string $src
8787
): string {
88-
if (extension_loaded('sodium')) {
88+
if (\extension_loaded('sodium')) {
8989
$variant = match(static::class) {
9090
Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING,
9191
Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING,
@@ -199,7 +199,7 @@ public static function decode(
199199
'Incorrect padding'
200200
);
201201
}
202-
if (extension_loaded('sodium')) {
202+
if (\extension_loaded('sodium')) {
203203
$variant = match(static::class) {
204204
Base64::class => SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING,
205205
Base64UrlSafe::class => SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING,

src/Hex.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function encode(
4848
#[\SensitiveParameter]
4949
string $binString
5050
): string {
51-
if (extension_loaded('sodium')) {
51+
if (\extension_loaded('sodium')) {
5252
try {
5353
return sodium_bin2hex($binString);
5454
} catch (SodiumException $ex) {
@@ -117,7 +117,7 @@ public static function decode(
117117
string $encodedString,
118118
bool $strictPadding = false
119119
): string {
120-
if (extension_loaded('sodium') && $strictPadding) {
120+
if (\extension_loaded('sodium') && $strictPadding) {
121121
try {
122122
return sodium_hex2bin($encodedString);
123123
} catch (SodiumException $ex) {

0 commit comments

Comments
 (0)