diff --git a/.travis.yml b/.travis.yml index 54e24a4..34ea37d 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 18c0ac9..7784baf 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 b806909..4739e48 100644 --- a/src/Base64.php +++ b/src/Base64.php @@ -116,26 +116,26 @@ protected static function doEncode(string $src, bool $pad = true): string * * 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 @@ public static function decode(string $src, bool $strictPadding = false): string '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 @@ public static function decode(string $src, bool $strictPadding = false): string // Main loop (no padding): for ($i = 0; $i + 4 <= $srcLen; $i += 4) { /** @var array $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 @@ public static function decode(string $src, bool $strictPadding = false): string // The last chunk, which may have padding: if ($i < $srcLen) { /** @var array $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 38c3ec8..38dbc4e 100644 --- a/src/Binary.php +++ b/src/Binary.php @@ -48,7 +48,7 @@ public static function safeStrlen(string $str): int 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 7bf60b7..b1b05a0 100644 --- a/src/Hex.php +++ b/src/Hex.php @@ -97,12 +97,12 @@ public static function encodeUpper(string $binString): string * 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 @@ public static function decode(string $hexString, bool $strictPadding = false): s /** @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 @@ public static function decode(string $hexString, bool $strictPadding = false): s 'Expected an even number of hexadecimal characters' ); } else { - $hexString = '0' . $hexString; + $encodedString = '0' . $encodedString; ++$hex_len; } } /** @var array $chunk */ - $chunk = \unpack('C*', $hexString); + $chunk = \unpack('C*', $encodedString); while ($hex_pos < $hex_len) { ++$hex_pos; /** @var int $c */