From 5e64617271ab21308ad8910ec87c9a461e0bdbf5 Mon Sep 17 00:00:00 2001
From: Paragon Initiative Enterprises <security@paragonie.com>
Date: Sun, 6 Dec 2020 10:13:35 -0500
Subject: [PATCH] Fix build failures.

We have to remove 7.0 since Travis uses Composer 2 and our dependencies will not install on PHP 7.0
---
 .travis.yml    |  1 -
 src/Base32.php | 10 +++++-----
 src/Base64.php | 20 ++++++++++----------
 src/Binary.php |  2 +-
 src/Hex.php    | 10 +++++-----
 5 files changed, 21 insertions(+), 22 deletions(-)

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 @@ 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 38c3ec8..38dbc4e 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 7bf60b7..b1b05a0 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 */
-- 
GitLab