2nd round of comments

This commit is contained in:
Jack Worman 2022-06-23 19:44:04 -05:00
parent beafe2a8a1
commit 86ef8ef262
32 changed files with 127 additions and 144 deletions

View File

@ -14194,12 +14194,16 @@
<code>self::minHelper($nums)</code>
<code>self::randomRangeHelper($min, $max)</code>
</LessSpecificReturnStatement>
<MixedArgument occurrences="1">
<code>$digit / 2 ** (2 * $step)</code>
</MixedArgument>
<MixedAssignment occurrences="3">
<code>$digit</code>
<code>$digit</code>
<code>$vals[]</code>
</MixedAssignment>
<MixedOperand occurrences="2">
<MixedOperand occurrences="3">
<code>$digit</code>
<code>$digit</code>
<code>$digit</code>
</MixedOperand>
@ -14398,37 +14402,21 @@
<InvalidFalsableReturnType occurrences="1">
<code>string</code>
</InvalidFalsableReturnType>
<MissingParamType occurrences="11">
<code>$instanceID</code>
<MissingParamType occurrences="4">
<code>$instanceID</code>
<code>$instanceID</code>
<code>$num</code>
<code>$x</code>
<code>$x</code>
<code>$x</code>
<code>$y</code>
<code>$y</code>
<code>$y</code>
<code>$z</code>
</MissingParamType>
<MixedArgument occurrences="9">
<MixedArgument occurrences="2">
<code>$num</code>
<code>$r</code>
<code>$r</code>
<code>$x</code>
<code>$x</code>
<code>$y</code>
<code>$y</code>
<code>$y</code>
<code>$z</code>
</MixedArgument>
<MixedArrayOffset occurrences="3">
<code>static::$modulo[$instanceID]</code>
<MixedArrayOffset occurrences="2">
<code>static::$reduce[$instanceID]</code>
<code>static::$reduce[$instanceID]</code>
</MixedArrayOffset>
<MixedAssignment occurrences="22">
<code>$r</code>
<MixedAssignment occurrences="21">
<code>$this-&gt;instanceID</code>
<code>$this-&gt;value</code>
<code>$x</code>
@ -14541,9 +14529,6 @@
</UndefinedThisPropertyAssignment>
</file>
<file src="../phpseclib/Math/PrimeField/Integer.php">
<MissingParamType occurrences="1">
<code>$instanceID</code>
</MissingParamType>
<MixedArgument occurrences="6">
<code>$length</code>
<code>$one</code>
@ -14552,10 +14537,6 @@
<code>static::$zero[static::class]</code>
<code>static::$zero[static::class]</code>
</MixedArgument>
<MixedArrayOffset occurrences="2">
<code>static::$modulo[$instanceID]</code>
<code>static::$reduce[$instanceID]</code>
</MixedArrayOffset>
<MixedAssignment occurrences="1">
<code>$this-&gt;value</code>
</MixedAssignment>
@ -14599,6 +14580,9 @@
<code>false</code>
<code>false</code>
</FalsableReturnStatement>
<InvalidArgument occurrences="1">
<code>[&amp;$this, 'comparator']</code>
</InvalidArgument>
<InvalidFalsableReturnType occurrences="3">
<code>array</code>
<code>array|string</code>
@ -14796,11 +14780,11 @@
<code>$value</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="8">
<code>?int</code>
<code>array</code>
<code>array|false</code>
<code>array|false</code>
<code>bool</code>
<code>int</code>
<code>string</code>
<code>string</code>
<code>string|bool</code>
@ -15024,12 +15008,14 @@
<UnevaluatedCode occurrences="1">
<code>break;</code>
</UnevaluatedCode>
<UnusedMethod occurrences="1">
<code>comparator</code>
</UnusedMethod>
<UnusedParam occurrences="1">
<code>$key</code>
</UnusedParam>
<UnusedReturnValue occurrences="2">
<UnusedReturnValue occurrences="1">
<code>bool</code>
<code>int</code>
</UnusedReturnValue>
<UnusedVariable occurrences="13">
<code>$attrib_bits</code>

View File

@ -649,7 +649,7 @@ abstract class PHP extends Engine
$result = [];
for ($i = count($dividend) - 1; $i >= 0; --$i) {
$temp = static::BASE_FULL * $carry + $dividend[$i];
$temp = static::BASE_FULL * $carry + (int) $dividend[$i];
$result[$i] = self::safe_divide($temp, $divisor);
$carry = (int)($temp - $divisor * $result[$i]);
}
@ -664,10 +664,8 @@ abstract class PHP extends Engine
* if the dividend is not evenly divisible by the divisor. Since a float64 doesn't
* have the precision of int64 this is a problem so, when int64 is being used,
* we'll guarantee that the dividend is divisible by first subtracting the remainder.
*
* @return int
*/
private static function safe_divide(int $x, int $y)
private static function safe_divide(int $x, int $y): int
{
if (static::BASE === 26) {
return (int)($x / $y);

View File

@ -82,7 +82,7 @@ class PHP32 extends PHP
}
$step = count($vals) & 3;
if ($step) {
$digit = floor($digit / pow(2, 2 * $step));
$digit = floor($digit / 2 ** (2 * $step));
}
if ($step != 3) {
$digit &= static::MAX_DIGIT;

View File

@ -155,7 +155,7 @@ class Integer extends Base
* @return string[]
* @link https://en.wikipedia.org/wiki/Polynomial_greatest_common_divisor#Euclidean_division
*/
private static function polynomialDivide($x, $y): array
private static function polynomialDivide(string $x, string $y): array
{
// in wikipedia's description of the algorithm, lc() is the leading coefficient. over a binary field that's
// always going to be 1.
@ -184,7 +184,7 @@ class Integer extends Base
*
* @link https://en.wikipedia.org/wiki/Finite_field_arithmetic#Multiplication
*/
private static function regularPolynomialMultiply($x, $y): string
private static function regularPolynomialMultiply(string $x, string $y): string
{
$precomputed = [ltrim($x, "\0")];
$x = strrev(BinaryField::base256ToBase2($x));
@ -222,7 +222,7 @@ class Integer extends Base
*
* @link https://en.wikipedia.org/wiki/Karatsuba_algorithm
*/
private static function polynomialMultiply($x, $y): string
private static function polynomialMultiply(string $x, string $y): string
{
if (strlen($x) == strlen($y)) {
$length = strlen($x);
@ -430,7 +430,7 @@ class Integer extends Base
/**
* Returns the modulo
*/
public static function getModulo($instanceID): string
public static function getModulo(int $instanceID): string
{
return static::$modulo[$instanceID];
}

View File

@ -94,7 +94,7 @@ class Integer extends Base
/**
* Delete the modulo for a given instance
*/
public static function cleanupCache($instanceID): void
public static function cleanupCache(int $instanceID): void
{
unset(static::$modulo[$instanceID]);
unset(static::$reduce[$instanceID]);

View File

@ -951,10 +951,8 @@ class SFTP extends SSH2
* Compares two rawlist entries using parameters set by setListOrder()
*
* Intended for use with uasort()
*
* @return int
*/
private function comparator(array $a, array $b)
private function comparator(array $a, array $b): ?int
{
switch (true) {
case $a['filename'] === '.' || $b['filename'] === '.':
@ -1006,6 +1004,7 @@ class SFTP extends SSH2
return $order === SORT_ASC ? $a[$sort] - $b[$sort] : $b[$sort] - $a[$sort];
}
}
return null;
}
/**