diff --git a/.travis.yml b/.travis.yml index 54e24a4d0e6cfa8b0312937bc48a1aed8dcfc2b1..34ea37d61e5b0c75b0012257c9602a2195d09fa5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ sudo: false matrix: fast_finish: true include: - - php: "7.0" - php: "7.1" - php: "7.2" - php: "7.3" diff --git a/src/Base32.php b/src/Base32.php index 18c0ac9062870954b34c786ca9b3c4273fb06a09..7784bafbf5e7d5db9a60618616d57f05c5bd1cd5 100644 --- a/src/Base32.php +++ b/src/Base32.php @@ -36,21 +36,21 @@ abstract class Base32 implements EncoderInterface /** * Decode a Base32-encoded string into raw binary * - * @param string $src + * @param string $encodedString + * @param bool $strictPadding * @return string - * @throws \TypeError */ - public static function decode(string $src, bool $strictPadding = false): string + public static function decode(string $encodedString, bool $strictPadding = false): string { - return static::doDecode($src, false, $strictPadding); + return static::doDecode($encodedString, false, $strictPadding); } /** * Decode an uppercase Base32-encoded string into raw binary * * @param string $src + * @param bool $strictPadding * @return string - * @throws \TypeError */ public static function decodeUpper(string $src, bool $strictPadding = false): string { diff --git a/src/Base64.php b/src/Base64.php index b806909f208e294ffdec867445cc9dc8e7acdc83..4739e4895dde6ee816a280335a2466e996f6e9ef 100644 --- a/src/Base64.php +++ b/src/Base64.php @@ -116,26 +116,26 @@ abstract class Base64 implements EncoderInterface * * Base64 character set "./[A-Z][a-z][0-9]" * - * @param string $src + * @param string $encodedString * @param bool $strictPadding * @return string * @throws \RangeException * @throws \TypeError * @psalm-suppress RedundantCondition */ - public static function decode(string $src, bool $strictPadding = false): string + public static function decode(string $encodedString, bool $strictPadding = false): string { // Remove padding - $srcLen = Binary::safeStrlen($src); + $srcLen = Binary::safeStrlen($encodedString); if ($srcLen === 0) { return ''; } if ($strictPadding) { if (($srcLen & 3) === 0) { - if ($src[$srcLen - 1] === '=') { + if ($encodedString[$srcLen - 1] === '=') { $srcLen--; - if ($src[$srcLen - 1] === '=') { + if ($encodedString[$srcLen - 1] === '=') { $srcLen--; } } @@ -145,14 +145,14 @@ abstract class Base64 implements EncoderInterface 'Incorrect padding' ); } - if ($src[$srcLen - 1] === '=') { + if ($encodedString[$srcLen - 1] === '=') { throw new \RangeException( 'Incorrect padding' ); } } else { - $src = \rtrim($src, '='); - $srcLen = Binary::safeStrlen($src); + $encodedString = \rtrim($encodedString, '='); + $srcLen = Binary::safeStrlen($encodedString); } $err = 0; @@ -160,7 +160,7 @@ abstract class Base64 implements EncoderInterface // Main loop (no padding): for ($i = 0; $i + 4 <= $srcLen; $i += 4) { /** @var array<int, int> $chunk */ - $chunk = \unpack('C*', Binary::safeSubstr($src, $i, 4)); + $chunk = \unpack('C*', Binary::safeSubstr($encodedString, $i, 4)); $c0 = static::decode6Bits($chunk[1]); $c1 = static::decode6Bits($chunk[2]); $c2 = static::decode6Bits($chunk[3]); @@ -177,7 +177,7 @@ abstract class Base64 implements EncoderInterface // The last chunk, which may have padding: if ($i < $srcLen) { /** @var array<int, int> $chunk */ - $chunk = \unpack('C*', Binary::safeSubstr($src, $i, $srcLen - $i)); + $chunk = \unpack('C*', Binary::safeSubstr($encodedString, $i, $srcLen - $i)); $c0 = static::decode6Bits($chunk[1]); if ($i + 2 < $srcLen) { diff --git a/src/Binary.php b/src/Binary.php index 38c3ec89a813942be26a25f286d2f79c6ee6f729..38dbc4e66076ec94fe5995884b437aea6faa7ea9 100644 --- a/src/Binary.php +++ b/src/Binary.php @@ -48,7 +48,7 @@ abstract class Binary if (\function_exists('mb_strlen')) { return (int) \mb_strlen($str, '8bit'); } else { - return (int) \strlen($str); + return \strlen($str); } } diff --git a/src/Hex.php b/src/Hex.php index 7bf60b7345ea6c4b62524b183278fd729f664ea7..b1b05a098e675ee3c0be615d50c4bb49fea0bfa1 100644 --- a/src/Hex.php +++ b/src/Hex.php @@ -97,12 +97,12 @@ abstract class Hex implements EncoderInterface * Convert a hexadecimal string into a binary string without cache-timing * leaks * - * @param string $hexString + * @param string $encodedString * @param bool $strictPadding * @return string (raw binary) * @throws \RangeException */ - public static function decode(string $hexString, bool $strictPadding = false): string + public static function decode(string $encodedString, bool $strictPadding = false): string { /** @var int $hex_pos */ $hex_pos = 0; @@ -111,7 +111,7 @@ abstract class Hex implements EncoderInterface /** @var int $c_acc */ $c_acc = 0; /** @var int $hex_len */ - $hex_len = Binary::safeStrlen($hexString); + $hex_len = Binary::safeStrlen($encodedString); /** @var int $state */ $state = 0; if (($hex_len & 1) !== 0) { @@ -120,13 +120,13 @@ abstract class Hex implements EncoderInterface 'Expected an even number of hexadecimal characters' ); } else { - $hexString = '0' . $hexString; + $encodedString = '0' . $encodedString; ++$hex_len; } } /** @var array<int, int> $chunk */ - $chunk = \unpack('C*', $hexString); + $chunk = \unpack('C*', $encodedString); while ($hex_pos < $hex_len) { ++$hex_pos; /** @var int $c */