Commit 5e646172 authored by Paragon Initiative Enterprises's avatar Paragon Initiative Enterprises
Browse files

Fix build failures.

We have to remove 7.0 since Travis uses Composer 2 and our dependencies will not install on PHP 7.0
No related merge requests found
Showing with 21 additions and 22 deletions
+21 -22
......@@ -4,7 +4,6 @@ sudo: false
matrix:
fast_finish: true
include:
- php: "7.0"
- php: "7.1"
- php: "7.2"
- php: "7.3"
......
......@@ -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
{
......
......@@ -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) {
......
......@@ -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);
}
}
......
......@@ -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 */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment