mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-09-28 23:29:02 +00:00
2nd round of comments
This commit is contained in:
parent
beafe2a8a1
commit
86ef8ef262
@ -14194,12 +14194,16 @@
|
|||||||
<code>self::minHelper($nums)</code>
|
<code>self::minHelper($nums)</code>
|
||||||
<code>self::randomRangeHelper($min, $max)</code>
|
<code>self::randomRangeHelper($min, $max)</code>
|
||||||
</LessSpecificReturnStatement>
|
</LessSpecificReturnStatement>
|
||||||
|
<MixedArgument occurrences="1">
|
||||||
|
<code>$digit / 2 ** (2 * $step)</code>
|
||||||
|
</MixedArgument>
|
||||||
<MixedAssignment occurrences="3">
|
<MixedAssignment occurrences="3">
|
||||||
<code>$digit</code>
|
<code>$digit</code>
|
||||||
<code>$digit</code>
|
<code>$digit</code>
|
||||||
<code>$vals[]</code>
|
<code>$vals[]</code>
|
||||||
</MixedAssignment>
|
</MixedAssignment>
|
||||||
<MixedOperand occurrences="2">
|
<MixedOperand occurrences="3">
|
||||||
|
<code>$digit</code>
|
||||||
<code>$digit</code>
|
<code>$digit</code>
|
||||||
<code>$digit</code>
|
<code>$digit</code>
|
||||||
</MixedOperand>
|
</MixedOperand>
|
||||||
@ -14398,37 +14402,21 @@
|
|||||||
<InvalidFalsableReturnType occurrences="1">
|
<InvalidFalsableReturnType occurrences="1">
|
||||||
<code>string</code>
|
<code>string</code>
|
||||||
</InvalidFalsableReturnType>
|
</InvalidFalsableReturnType>
|
||||||
<MissingParamType occurrences="11">
|
<MissingParamType occurrences="4">
|
||||||
<code>$instanceID</code>
|
|
||||||
<code>$instanceID</code>
|
<code>$instanceID</code>
|
||||||
<code>$instanceID</code>
|
<code>$instanceID</code>
|
||||||
<code>$num</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>
|
<code>$z</code>
|
||||||
</MissingParamType>
|
</MissingParamType>
|
||||||
<MixedArgument occurrences="9">
|
<MixedArgument occurrences="2">
|
||||||
<code>$num</code>
|
<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>
|
<code>$z</code>
|
||||||
</MixedArgument>
|
</MixedArgument>
|
||||||
<MixedArrayOffset occurrences="3">
|
<MixedArrayOffset occurrences="2">
|
||||||
<code>static::$modulo[$instanceID]</code>
|
|
||||||
<code>static::$reduce[$instanceID]</code>
|
<code>static::$reduce[$instanceID]</code>
|
||||||
<code>static::$reduce[$instanceID]</code>
|
<code>static::$reduce[$instanceID]</code>
|
||||||
</MixedArrayOffset>
|
</MixedArrayOffset>
|
||||||
<MixedAssignment occurrences="22">
|
<MixedAssignment occurrences="21">
|
||||||
<code>$r</code>
|
|
||||||
<code>$this->instanceID</code>
|
<code>$this->instanceID</code>
|
||||||
<code>$this->value</code>
|
<code>$this->value</code>
|
||||||
<code>$x</code>
|
<code>$x</code>
|
||||||
@ -14541,9 +14529,6 @@
|
|||||||
</UndefinedThisPropertyAssignment>
|
</UndefinedThisPropertyAssignment>
|
||||||
</file>
|
</file>
|
||||||
<file src="../phpseclib/Math/PrimeField/Integer.php">
|
<file src="../phpseclib/Math/PrimeField/Integer.php">
|
||||||
<MissingParamType occurrences="1">
|
|
||||||
<code>$instanceID</code>
|
|
||||||
</MissingParamType>
|
|
||||||
<MixedArgument occurrences="6">
|
<MixedArgument occurrences="6">
|
||||||
<code>$length</code>
|
<code>$length</code>
|
||||||
<code>$one</code>
|
<code>$one</code>
|
||||||
@ -14552,10 +14537,6 @@
|
|||||||
<code>static::$zero[static::class]</code>
|
<code>static::$zero[static::class]</code>
|
||||||
<code>static::$zero[static::class]</code>
|
<code>static::$zero[static::class]</code>
|
||||||
</MixedArgument>
|
</MixedArgument>
|
||||||
<MixedArrayOffset occurrences="2">
|
|
||||||
<code>static::$modulo[$instanceID]</code>
|
|
||||||
<code>static::$reduce[$instanceID]</code>
|
|
||||||
</MixedArrayOffset>
|
|
||||||
<MixedAssignment occurrences="1">
|
<MixedAssignment occurrences="1">
|
||||||
<code>$this->value</code>
|
<code>$this->value</code>
|
||||||
</MixedAssignment>
|
</MixedAssignment>
|
||||||
@ -14599,6 +14580,9 @@
|
|||||||
<code>false</code>
|
<code>false</code>
|
||||||
<code>false</code>
|
<code>false</code>
|
||||||
</FalsableReturnStatement>
|
</FalsableReturnStatement>
|
||||||
|
<InvalidArgument occurrences="1">
|
||||||
|
<code>[&$this, 'comparator']</code>
|
||||||
|
</InvalidArgument>
|
||||||
<InvalidFalsableReturnType occurrences="3">
|
<InvalidFalsableReturnType occurrences="3">
|
||||||
<code>array</code>
|
<code>array</code>
|
||||||
<code>array|string</code>
|
<code>array|string</code>
|
||||||
@ -14796,11 +14780,11 @@
|
|||||||
<code>$value</code>
|
<code>$value</code>
|
||||||
</MixedAssignment>
|
</MixedAssignment>
|
||||||
<MixedInferredReturnType occurrences="8">
|
<MixedInferredReturnType occurrences="8">
|
||||||
|
<code>?int</code>
|
||||||
<code>array</code>
|
<code>array</code>
|
||||||
<code>array|false</code>
|
<code>array|false</code>
|
||||||
<code>array|false</code>
|
<code>array|false</code>
|
||||||
<code>bool</code>
|
<code>bool</code>
|
||||||
<code>int</code>
|
|
||||||
<code>string</code>
|
<code>string</code>
|
||||||
<code>string</code>
|
<code>string</code>
|
||||||
<code>string|bool</code>
|
<code>string|bool</code>
|
||||||
@ -15024,12 +15008,14 @@
|
|||||||
<UnevaluatedCode occurrences="1">
|
<UnevaluatedCode occurrences="1">
|
||||||
<code>break;</code>
|
<code>break;</code>
|
||||||
</UnevaluatedCode>
|
</UnevaluatedCode>
|
||||||
|
<UnusedMethod occurrences="1">
|
||||||
|
<code>comparator</code>
|
||||||
|
</UnusedMethod>
|
||||||
<UnusedParam occurrences="1">
|
<UnusedParam occurrences="1">
|
||||||
<code>$key</code>
|
<code>$key</code>
|
||||||
</UnusedParam>
|
</UnusedParam>
|
||||||
<UnusedReturnValue occurrences="2">
|
<UnusedReturnValue occurrences="1">
|
||||||
<code>bool</code>
|
<code>bool</code>
|
||||||
<code>int</code>
|
|
||||||
</UnusedReturnValue>
|
</UnusedReturnValue>
|
||||||
<UnusedVariable occurrences="13">
|
<UnusedVariable occurrences="13">
|
||||||
<code>$attrib_bits</code>
|
<code>$attrib_bits</code>
|
||||||
|
@ -649,7 +649,7 @@ abstract class PHP extends Engine
|
|||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
for ($i = count($dividend) - 1; $i >= 0; --$i) {
|
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);
|
$result[$i] = self::safe_divide($temp, $divisor);
|
||||||
$carry = (int)($temp - $divisor * $result[$i]);
|
$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
|
* 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,
|
* 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.
|
* 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) {
|
if (static::BASE === 26) {
|
||||||
return (int)($x / $y);
|
return (int)($x / $y);
|
||||||
|
@ -82,7 +82,7 @@ class PHP32 extends PHP
|
|||||||
}
|
}
|
||||||
$step = count($vals) & 3;
|
$step = count($vals) & 3;
|
||||||
if ($step) {
|
if ($step) {
|
||||||
$digit = floor($digit / pow(2, 2 * $step));
|
$digit = floor($digit / 2 ** (2 * $step));
|
||||||
}
|
}
|
||||||
if ($step != 3) {
|
if ($step != 3) {
|
||||||
$digit &= static::MAX_DIGIT;
|
$digit &= static::MAX_DIGIT;
|
||||||
|
@ -155,7 +155,7 @@ class Integer extends Base
|
|||||||
* @return string[]
|
* @return string[]
|
||||||
* @link https://en.wikipedia.org/wiki/Polynomial_greatest_common_divisor#Euclidean_division
|
* @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
|
// in wikipedia's description of the algorithm, lc() is the leading coefficient. over a binary field that's
|
||||||
// always going to be 1.
|
// always going to be 1.
|
||||||
@ -184,7 +184,7 @@ class Integer extends Base
|
|||||||
*
|
*
|
||||||
* @link https://en.wikipedia.org/wiki/Finite_field_arithmetic#Multiplication
|
* @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")];
|
$precomputed = [ltrim($x, "\0")];
|
||||||
$x = strrev(BinaryField::base256ToBase2($x));
|
$x = strrev(BinaryField::base256ToBase2($x));
|
||||||
@ -222,7 +222,7 @@ class Integer extends Base
|
|||||||
*
|
*
|
||||||
* @link https://en.wikipedia.org/wiki/Karatsuba_algorithm
|
* @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)) {
|
if (strlen($x) == strlen($y)) {
|
||||||
$length = strlen($x);
|
$length = strlen($x);
|
||||||
@ -430,7 +430,7 @@ class Integer extends Base
|
|||||||
/**
|
/**
|
||||||
* Returns the modulo
|
* Returns the modulo
|
||||||
*/
|
*/
|
||||||
public static function getModulo($instanceID): string
|
public static function getModulo(int $instanceID): string
|
||||||
{
|
{
|
||||||
return static::$modulo[$instanceID];
|
return static::$modulo[$instanceID];
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class Integer extends Base
|
|||||||
/**
|
/**
|
||||||
* Delete the modulo for a given instance
|
* 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::$modulo[$instanceID]);
|
||||||
unset(static::$reduce[$instanceID]);
|
unset(static::$reduce[$instanceID]);
|
||||||
|
@ -951,10 +951,8 @@ class SFTP extends SSH2
|
|||||||
* Compares two rawlist entries using parameters set by setListOrder()
|
* Compares two rawlist entries using parameters set by setListOrder()
|
||||||
*
|
*
|
||||||
* Intended for use with uasort()
|
* Intended for use with uasort()
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
private function comparator(array $a, array $b)
|
private function comparator(array $a, array $b): ?int
|
||||||
{
|
{
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case $a['filename'] === '.' || $b['filename'] === '.':
|
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 $order === SORT_ASC ? $a[$sort] - $b[$sort] : $b[$sort] - $a[$sort];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user