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

Clean up unnecessary annotations

No related merge requests found
Showing with 3 additions and 23 deletions
+3 -23
...@@ -367,7 +367,6 @@ abstract class Base32 implements EncoderInterface ...@@ -367,7 +367,6 @@ abstract class Base32 implements EncoderInterface
$err |= ($c0) >> 8; $err |= ($c0) >> 8;
} }
} }
/** @var bool $check */
$check = ($err === 0); $check = ($err === 0);
if (!$check) { if (!$check) {
throw new \RangeException( throw new \RangeException(
......
...@@ -196,11 +196,10 @@ abstract class Base64 implements EncoderInterface ...@@ -196,11 +196,10 @@ abstract class Base64 implements EncoderInterface
((($c0 << 2) | ($c1 >> 4)) & 0xff) ((($c0 << 2) | ($c1 >> 4)) & 0xff)
); );
$err |= ($c0 | $c1) >> 8; $err |= ($c0 | $c1) >> 8;
} elseif ($i < $srcLen && $strictPadding) { } elseif ($strictPadding) {
$err |= 1; $err |= 1;
} }
} }
/** @var bool $check */
$check = ($err === 0); $check = ($err === 0);
if (!$check) { if (!$check) {
throw new \RangeException( throw new \RangeException(
......
...@@ -62,14 +62,14 @@ abstract class Binary ...@@ -62,14 +62,14 @@ abstract class Binary
* @staticvar boolean $exists * @staticvar boolean $exists
* @param string $str * @param string $str
* @param int $start * @param int $start
* @param int $length * @param ?int $length
* @return string * @return string
* @throws \TypeError * @throws \TypeError
*/ */
public static function safeSubstr( public static function safeSubstr(
string $str, string $str,
int $start = 0, int $start = 0,
$length = null int $length = null
): string { ): string {
if ($length === 0) { if ($length === 0) {
return ''; return '';
......
...@@ -41,15 +41,12 @@ abstract class Hex implements EncoderInterface ...@@ -41,15 +41,12 @@ abstract class Hex implements EncoderInterface
*/ */
public static function encode(string $binString): string public static function encode(string $binString): string
{ {
/** @var string $hex */
$hex = ''; $hex = '';
$len = Binary::safeStrlen($binString); $len = Binary::safeStrlen($binString);
for ($i = 0; $i < $len; ++$i) { for ($i = 0; $i < $len; ++$i) {
/** @var array<int, int> $chunk */ /** @var array<int, int> $chunk */
$chunk = \unpack('C', Binary::safeSubstr($binString, $i, 1)); $chunk = \unpack('C', Binary::safeSubstr($binString, $i, 1));
/** @var int $c */
$c = $chunk[1] & 0xf; $c = $chunk[1] & 0xf;
/** @var int $b */
$b = $chunk[1] >> 4; $b = $chunk[1] >> 4;
$hex .= pack( $hex .= pack(
...@@ -71,17 +68,13 @@ abstract class Hex implements EncoderInterface ...@@ -71,17 +68,13 @@ abstract class Hex implements EncoderInterface
*/ */
public static function encodeUpper(string $binString): string public static function encodeUpper(string $binString): string
{ {
/** @var string $hex */
$hex = ''; $hex = '';
/** @var int $len */
$len = Binary::safeStrlen($binString); $len = Binary::safeStrlen($binString);
for ($i = 0; $i < $len; ++$i) { for ($i = 0; $i < $len; ++$i) {
/** @var array<int, int> $chunk */ /** @var array<int, int> $chunk */
$chunk = \unpack('C', Binary::safeSubstr($binString, $i, 2)); $chunk = \unpack('C', Binary::safeSubstr($binString, $i, 2));
/** @var int $c */
$c = $chunk[1] & 0xf; $c = $chunk[1] & 0xf;
/** @var int $b */
$b = $chunk[1] >> 4; $b = $chunk[1] >> 4;
$hex .= pack( $hex .= pack(
...@@ -104,15 +97,10 @@ abstract class Hex implements EncoderInterface ...@@ -104,15 +97,10 @@ abstract class Hex implements EncoderInterface
*/ */
public static function decode(string $encodedString, bool $strictPadding = false): string public static function decode(string $encodedString, bool $strictPadding = false): string
{ {
/** @var int $hex_pos */
$hex_pos = 0; $hex_pos = 0;
/** @var string $bin */
$bin = ''; $bin = '';
/** @var int $c_acc */
$c_acc = 0; $c_acc = 0;
/** @var int $hex_len */
$hex_len = Binary::safeStrlen($encodedString); $hex_len = Binary::safeStrlen($encodedString);
/** @var int $state */
$state = 0; $state = 0;
if (($hex_len & 1) !== 0) { if (($hex_len & 1) !== 0) {
if ($strictPadding) { if ($strictPadding) {
...@@ -129,15 +117,10 @@ abstract class Hex implements EncoderInterface ...@@ -129,15 +117,10 @@ abstract class Hex implements EncoderInterface
$chunk = \unpack('C*', $encodedString); $chunk = \unpack('C*', $encodedString);
while ($hex_pos < $hex_len) { while ($hex_pos < $hex_len) {
++$hex_pos; ++$hex_pos;
/** @var int $c */
$c = $chunk[$hex_pos]; $c = $chunk[$hex_pos];
/** @var int $c_num */
$c_num = $c ^ 48; $c_num = $c ^ 48;
/** @var int $c_num0 */
$c_num0 = ($c_num - 10) >> 8; $c_num0 = ($c_num - 10) >> 8;
/** @var int $c_alpha */
$c_alpha = ($c & ~32) - 55; $c_alpha = ($c & ~32) - 55;
/** @var int $c_alpha0 */
$c_alpha0 = (($c_alpha - 10) ^ ($c_alpha - 16)) >> 8; $c_alpha0 = (($c_alpha - 10) ^ ($c_alpha - 16)) >> 8;
if (($c_num0 | $c_alpha0) === 0) { if (($c_num0 | $c_alpha0) === 0) {
...@@ -145,7 +128,6 @@ abstract class Hex implements EncoderInterface ...@@ -145,7 +128,6 @@ abstract class Hex implements EncoderInterface
'Expected hexadecimal character' 'Expected hexadecimal character'
); );
} }
/** @var int $c_val */
$c_val = ($c_num0 & $c_num) | ($c_alpha & $c_alpha0); $c_val = ($c_num0 & $c_num) | ($c_alpha & $c_alpha0);
if ($state === 0) { if ($state === 0) {
$c_acc = $c_val * 16; $c_acc = $c_val * 16;
......
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