3rd round of comments

This commit is contained in:
Jack Worman 2022-07-03 07:33:45 -05:00
parent 86ef8ef262
commit 8a2b94fb24
4 changed files with 54 additions and 74 deletions

View File

@ -7624,12 +7624,6 @@
<MixedReturnStatement occurrences="1"> <MixedReturnStatement occurrences="1">
<code>$key</code> <code>$key</code>
</MixedReturnStatement> </MixedReturnStatement>
<PossiblyInvalidArgument occurrences="1">
<code>$key</code>
</PossiblyInvalidArgument>
<PossiblyInvalidCast occurrences="1">
<code>$key</code>
</PossiblyInvalidCast>
<PossiblyUnusedMethod occurrences="2"> <PossiblyUnusedMethod occurrences="2">
<code>loadParameters</code> <code>loadParameters</code>
<code>loadPublicKey</code> <code>loadPublicKey</code>
@ -10720,7 +10714,7 @@
</UnusedClass> </UnusedClass>
</file> </file>
<file src="../phpseclib/File/X509.php"> <file src="../phpseclib/File/X509.php">
<DocblockTypeContradiction occurrences="12"> <DocblockTypeContradiction occurrences="13">
<code>!is_array($this-&gt;currentCert)</code> <code>!is_array($this-&gt;currentCert)</code>
<code>!is_array($this-&gt;currentCert)</code> <code>!is_array($this-&gt;currentCert)</code>
<code>!is_array($this-&gt;currentCert)</code> <code>!is_array($this-&gt;currentCert)</code>
@ -10733,6 +10727,7 @@
<code>!isset($this-&gt;currentCert)</code> <code>!isset($this-&gt;currentCert)</code>
<code>!isset($this-&gt;currentCert)</code> <code>!isset($this-&gt;currentCert)</code>
<code>!isset($this-&gt;currentCert)</code> <code>!isset($this-&gt;currentCert)</code>
<code>$cert === false</code>
</DocblockTypeContradiction> </DocblockTypeContradiction>
<FalsableReturnStatement occurrences="10"> <FalsableReturnStatement occurrences="10">
<code>false</code> <code>false</code>
@ -10748,9 +10743,8 @@
<ImplicitToStringCast occurrences="1"> <ImplicitToStringCast occurrences="1">
<code>new BigInteger($serial, $base)</code> <code>new BigInteger($serial, $base)</code>
</ImplicitToStringCast> </ImplicitToStringCast>
<InvalidArgument occurrences="2"> <InvalidArgument occurrences="1">
<code>$j</code> <code>$j</code>
<code>$value</code>
</InvalidArgument> </InvalidArgument>
<InvalidFalsableReturnType occurrences="7"> <InvalidFalsableReturnType occurrences="7">
<code>string</code> <code>string</code>
@ -11317,7 +11311,10 @@
<code>false</code> <code>false</code>
<code>false</code> <code>false</code>
</PossiblyFalsePropertyAssignmentValue> </PossiblyFalsePropertyAssignmentValue>
<PossiblyInvalidArgument occurrences="6"> <PossiblyInvalidArgument occurrences="9">
<code>$cert</code>
<code>$cert</code>
<code>$cert</code>
<code>$crl</code> <code>$crl</code>
<code>$csr</code> <code>$csr</code>
<code>$date</code> <code>$date</code>
@ -11332,11 +11329,12 @@
<code>$results[$i + 1]</code> <code>$results[$i + 1]</code>
<code>$results[$i]</code> <code>$results[$i]</code>
</PossiblyInvalidArrayAccess> </PossiblyInvalidArrayAccess>
<PossiblyInvalidCast occurrences="4"> <PossiblyInvalidCast occurrences="5">
<code>$cert</code>
<code>$cert</code>
<code>$date</code> <code>$date</code>
<code>$date</code> <code>$date</code>
<code>$dn</code> <code>$dn</code>
<code>$value</code>
</PossiblyInvalidCast> </PossiblyInvalidCast>
<PossiblyInvalidMethodCall occurrences="3"> <PossiblyInvalidMethodCall occurrences="3">
<code>__toString</code> <code>__toString</code>
@ -11346,8 +11344,7 @@
<PossiblyInvalidOperand occurrences="1"> <PossiblyInvalidOperand occurrences="1">
<code>$key-&gt;getCurve()</code> <code>$key-&gt;getCurve()</code>
</PossiblyInvalidOperand> </PossiblyInvalidOperand>
<PossiblyInvalidPropertyAssignmentValue occurrences="2"> <PossiblyInvalidPropertyAssignmentValue occurrences="1">
<code>$cert</code>
<code>$csr</code> <code>$csr</code>
</PossiblyInvalidPropertyAssignmentValue> </PossiblyInvalidPropertyAssignmentValue>
<PossiblyNullArgument occurrences="17"> <PossiblyNullArgument occurrences="17">
@ -11492,8 +11489,7 @@
<code>signCRL</code> <code>signCRL</code>
<code>unrevoke</code> <code>unrevoke</code>
</PossiblyUnusedMethod> </PossiblyUnusedMethod>
<PossiblyUnusedReturnValue occurrences="6"> <PossiblyUnusedReturnValue occurrences="5">
<code>\phpseclib3\File\X509</code>
<code>bool</code> <code>bool</code>
<code>bool</code> <code>bool</code>
<code>bool</code> <code>bool</code>
@ -11579,12 +11575,11 @@
<code>$root</code> <code>$root</code>
<code>$spkac</code> <code>$spkac</code>
</ReferenceConstraintViolation> </ReferenceConstraintViolation>
<TypeDoesNotContainType occurrences="23"> <TypeDoesNotContainType occurrences="21">
<code>!is_array($cert)</code> <code>!is_array($cert)</code>
<code>!is_array($crl)</code> <code>!is_array($crl)</code>
<code>!is_array($csr)</code> <code>!is_array($csr)</code>
<code>!is_array($spkac)</code> <code>!is_array($spkac)</code>
<code>$cert === false</code>
<code>$crl === false</code> <code>$crl === false</code>
<code>$csr === false</code> <code>$csr === false</code>
<code>$spkac === false</code> <code>$spkac === false</code>
@ -11597,7 +11592,6 @@
<code>'sha256'</code> <code>'sha256'</code>
<code>'sha384'</code> <code>'sha384'</code>
<code>'sha384'</code> <code>'sha384'</code>
<code>is_array($cert)</code>
<code>is_array($crl)</code> <code>is_array($crl)</code>
<code>is_array($csr)</code> <code>is_array($csr)</code>
<code>is_array($root)</code> <code>is_array($root)</code>
@ -14987,9 +14981,11 @@
<PossiblyUnusedReturnValue occurrences="1"> <PossiblyUnusedReturnValue occurrences="1">
<code>bool</code> <code>bool</code>
</PossiblyUnusedReturnValue> </PossiblyUnusedReturnValue>
<PropertyNotSetInConstructor occurrences="2"> <PropertyNotSetInConstructor occurrences="4">
<code>$defaultVersion</code> <code>$defaultVersion</code>
<code>$version</code> <code>$version</code>
<code>SFTP</code>
<code>SFTP</code>
</PropertyNotSetInConstructor> </PropertyNotSetInConstructor>
<RedundantCastGivenDocblockType occurrences="1"> <RedundantCastGivenDocblockType occurrences="1">
<code>(int) $ver</code> <code>(int) $ver</code>
@ -15263,28 +15259,32 @@
<InvalidNullableReturnType occurrences="1"> <InvalidNullableReturnType occurrences="1">
<code>bool|SSH2</code> <code>bool|SSH2</code>
</InvalidNullableReturnType> </InvalidNullableReturnType>
<InvalidPropertyAssignmentValue occurrences="5">
<code>$this-&gt;curTimeout -= $elapsed</code>
<code>$this-&gt;curTimeout -= $elapsed</code>
<code>$this-&gt;curTimeout -= $elapsed</code>
<code>$this-&gt;curTimeout -= $elapsed</code>
<code>$this-&gt;curTimeout -= $elapsed</code>
</InvalidPropertyAssignmentValue>
<InvalidReturnType occurrences="2"> <InvalidReturnType occurrences="2">
<code>array{Hash, int}|null</code> <code>array{Hash, int}|null</code>
<code>string</code> <code>string</code>
</InvalidReturnType> </InvalidReturnType>
<MissingParamType occurrences="4"> <MissingParamType occurrences="3">
<code>$algorithm</code> <code>$algorithm</code>
<code>$host</code> <code>$host</code>
<code>$password</code> <code>$password</code>
<code>$timeout</code>
</MissingParamType> </MissingParamType>
<MissingPropertyType occurrences="5"> <MissingPropertyType occurrences="3">
<code>$curTimeout</code>
<code>$keepAlive</code> <code>$keepAlive</code>
<code>$quiet_mode</code> <code>$quiet_mode</code>
<code>$realtime_log_wrap</code> <code>$realtime_log_wrap</code>
<code>$timeout</code>
</MissingPropertyType> </MissingPropertyType>
<MissingReturnType occurrences="2"> <MissingReturnType occurrences="2">
<code>connect</code> <code>connect</code>
<code>get_channel_packet</code> <code>get_channel_packet</code>
</MissingReturnType> </MissingReturnType>
<MixedArgument occurrences="116"> <MixedArgument occurrences="113">
<code>$a['comp']</code> <code>$a['comp']</code>
<code>$a['crypt']</code> <code>$a['crypt']</code>
<code>$a['mac']</code> <code>$a['mac']</code>
@ -15369,9 +15369,6 @@
<code>$this-&gt;channel_buffers[$client_channel]</code> <code>$this-&gt;channel_buffers[$client_channel]</code>
<code>$this-&gt;compression_algorithms_client_to_server</code> <code>$this-&gt;compression_algorithms_client_to_server</code>
<code>$this-&gt;compression_algorithms_server_to_client</code> <code>$this-&gt;compression_algorithms_server_to_client</code>
<code>$this-&gt;curTimeout</code>
<code>$this-&gt;curTimeout</code>
<code>$this-&gt;curTimeout == 0 ? 100000 : $this-&gt;curTimeout</code>
<code>$this-&gt;encryption_algorithms_client_to_server</code> <code>$this-&gt;encryption_algorithms_client_to_server</code>
<code>$this-&gt;encryption_algorithms_server_to_client</code> <code>$this-&gt;encryption_algorithms_server_to_client</code>
<code>$this-&gt;keepAlive</code> <code>$this-&gt;keepAlive</code>
@ -15531,7 +15528,7 @@
<code>sign</code> <code>sign</code>
<code>withHash</code> <code>withHash</code>
</MixedMethodCall> </MixedMethodCall>
<MixedOperand occurrences="36"> <MixedOperand occurrences="29">
<code>$curveName</code> <code>$curveName</code>
<code>$data</code> <code>$data</code>
<code>$data</code> <code>$data</code>
@ -15554,13 +15551,6 @@
<code>$temp</code> <code>$temp</code>
<code>$temp</code> <code>$temp</code>
<code>$temp</code> <code>$temp</code>
<code>$this-&gt;curTimeout</code>
<code>$this-&gt;curTimeout</code>
<code>$this-&gt;curTimeout</code>
<code>$this-&gt;curTimeout</code>
<code>$this-&gt;curTimeout</code>
<code>$this-&gt;curTimeout</code>
<code>$this-&gt;curTimeout</code>
<code>$this-&gt;errors[count($this-&gt;errors) - 1]</code> <code>$this-&gt;errors[count($this-&gt;errors) - 1]</code>
<code>$this-&gt;window_size_client_to_server[$channel]</code> <code>$this-&gt;window_size_client_to_server[$channel]</code>
<code>$this-&gt;window_size_client_to_server[$client_channel]</code> <code>$this-&gt;window_size_client_to_server[$client_channel]</code>
@ -15675,9 +15665,11 @@
<code>false</code> <code>false</code>
<code>inflate_init(ZLIB_ENCODING_RAW, ['window' =&gt; $cinfo + 8])</code> <code>inflate_init(ZLIB_ENCODING_RAW, ['window' =&gt; $cinfo + 8])</code>
</PossiblyFalsePropertyAssignmentValue> </PossiblyFalsePropertyAssignmentValue>
<PossiblyInvalidArgument occurrences="16"> <PossiblyInvalidArgument occurrences="18">
<code>$args</code> <code>$args</code>
<code>$engine</code> <code>$engine</code>
<code>$password</code>
<code>$password</code>
<code>$response</code> <code>$response</code>
<code>$response</code> <code>$response</code>
<code>$response</code> <code>$response</code>
@ -15785,8 +15777,9 @@
<PossiblyUnusedReturnValue occurrences="1"> <PossiblyUnusedReturnValue occurrences="1">
<code>($callback is callable ? bool : string|bool)</code> <code>($callback is callable ? bool : string|bool)</code>
</PossiblyUnusedReturnValue> </PossiblyUnusedReturnValue>
<PropertyNotSetInConstructor occurrences="17"> <PropertyNotSetInConstructor occurrences="19">
<code>$agent</code> <code>$agent</code>
<code>$curTimeout</code>
<code>$decompress_context</code> <code>$decompress_context</code>
<code>$exit_status</code> <code>$exit_status</code>
<code>$hmac_check_etm</code> <code>$hmac_check_etm</code>
@ -15803,7 +15796,11 @@
<code>$realtime_log_size</code> <code>$realtime_log_size</code>
<code>$server_public_host_key</code> <code>$server_public_host_key</code>
<code>$stdErrorLog</code> <code>$stdErrorLog</code>
<code>$timeout</code>
</PropertyNotSetInConstructor> </PropertyNotSetInConstructor>
<RedundantCondition occurrences="1">
<code>is_array($responses[$i])</code>
</RedundantCondition>
<RedundantConditionGivenDocblockType occurrences="5"> <RedundantConditionGivenDocblockType occurrences="5">
<code>$this-&gt;session_id !== false</code> <code>$this-&gt;session_id !== false</code>
<code>Strings::is_stringable($arg)</code> <code>Strings::is_stringable($arg)</code>
@ -15880,27 +15877,21 @@
<MissingParamType occurrences="1"> <MissingParamType occurrences="1">
<code>$address</code> <code>$address</code>
</MissingParamType> </MissingParamType>
<MixedArgument occurrences="10"> <MixedArgument occurrences="6">
<code>$agent_reply_bytes</code> <code>$agent_reply_bytes</code>
<code>$agent_reply_data</code>
<code>$key</code> <code>$key</code>
<code>$key_blob</code> <code>$key_blob</code>
<code>$key_blob</code> <code>$key_blob</code>
<code>$length</code> <code>$length</code>
<code>$packet</code>
<code>$temp</code> <code>$temp</code>
<code>$this-&gt;readBytes(4)</code>
<code>$this-&gt;readBytes(4)</code>
</MixedArgument> </MixedArgument>
<MixedAssignment occurrences="10"> <MixedAssignment occurrences="8">
<code>$address</code> <code>$address</code>
<code>$address</code> <code>$address</code>
<code>$agent_data_bytes</code> <code>$agent_data_bytes</code>
<code>$agent_reply_bytes</code> <code>$agent_reply_bytes</code>
<code>$agent_reply_data</code> <code>$agent_reply_data</code>
<code>$agent_reply_data</code>
<code>$length</code> <code>$length</code>
<code>$packet</code>
<code>$temp</code> <code>$temp</code>
<code>$this-&gt;expected_bytes</code> <code>$this-&gt;expected_bytes</code>
</MixedAssignment> </MixedAssignment>
@ -15941,15 +15932,12 @@
</UnusedVariable> </UnusedVariable>
</file> </file>
<file src="../phpseclib/System/SSH/Agent/Identity.php"> <file src="../phpseclib/System/SSH/Agent/Identity.php">
<MixedArgument occurrences="4"> <MixedArgument occurrences="2">
<code>$length</code> <code>$length</code>
<code>$packet</code>
<code>$signature_blob</code> <code>$signature_blob</code>
<code>$this-&gt;readBytes(4)</code>
</MixedArgument> </MixedArgument>
<MixedAssignment occurrences="2"> <MixedAssignment occurrences="1">
<code>$length</code> <code>$length</code>
<code>$packet</code>
</MixedAssignment> </MixedAssignment>
<MixedInferredReturnType occurrences="1"> <MixedInferredReturnType occurrences="1">
<code>string</code> <code>string</code>
@ -15981,15 +15969,6 @@
<code>$type</code> <code>$type</code>
</UnusedVariable> </UnusedVariable>
</file> </file>
<file src="../phpseclib/System/SSH/Common/Traits/ReadBytes.php">
<MissingReturnType occurrences="1">
<code>readBytes</code>
</MissingReturnType>
<PossiblyFalseArgument occurrences="2">
<code>$temp</code>
<code>$temp</code>
</PossiblyFalseArgument>
</file>
<file src="../phpseclib/bootstrap.php"> <file src="../phpseclib/bootstrap.php">
<InvalidOperand occurrences="1"> <InvalidOperand occurrences="1">
<code>ini_get('mbstring.func_overload')</code> <code>ini_get('mbstring.func_overload')</code>

View File

@ -279,11 +279,6 @@ class X509
*/ */
private $domains = null; private $domains = null;
/**
* Default Constructor.
*
* @return \phpseclib3\File\X509
*/
public function __construct() public function __construct()
{ {
// Explicitly Tagged Module, 1988 Syntax // Explicitly Tagged Module, 1988 Syntax
@ -430,8 +425,10 @@ class X509
* Load X.509 certificate * Load X.509 certificate
* *
* Returns an associative array describing the X.509 cert or a false if the cert failed to load * Returns an associative array describing the X.509 cert or a false if the cert failed to load
*
* @param string|array $cert
*/ */
public function loadX509(string $cert, int $mode = self::FORMAT_AUTO_DETECT) public function loadX509($cert, int $mode = self::FORMAT_AUTO_DETECT)
{ {
if (is_array($cert) && isset($cert['tbsCertificate'])) { if (is_array($cert) && isset($cert['tbsCertificate'])) {
unset($this->currentCert); unset($this->currentCert);

View File

@ -706,14 +706,16 @@ class SSH2
/** /**
* Timeout * Timeout
* *
* @see self::setTimeout() * @see SSH2::setTimeout()
* @var int
*/ */
protected $timeout; protected $timeout;
/** /**
* Current Timeout * Current Timeout
* *
* @see self::get_channel_packet() * @see SSH2::get_channel_packet()
* @var int
*/ */
protected $curTimeout; protected $curTimeout;
@ -2253,10 +2255,9 @@ class SSH2
/** /**
* Handle the keyboard-interactive requests / responses. * Handle the keyboard-interactive requests / responses.
* *
* @param string|array ...$responses
* @throws \RuntimeException on connection error * @throws \RuntimeException on connection error
*/ */
private function keyboard_interactive_process(...$responses): bool private function keyboard_interactive_process(array ...$responses): bool
{ {
if (strlen($this->last_interactive_response)) { if (strlen($this->last_interactive_response)) {
$response = $this->last_interactive_response; $response = $this->last_interactive_response;
@ -2498,7 +2499,7 @@ class SSH2
* $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. * $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout.
* Setting $timeout to false or 0 will mean there is no timeout. * Setting $timeout to false or 0 will mean there is no timeout.
*/ */
public function setTimeout($timeout): void public function setTimeout(int $timeout): void
{ {
$this->timeout = $this->curTimeout = $timeout; $this->timeout = $this->curTimeout = $timeout;
} }

View File

@ -27,10 +27,13 @@ trait ReadBytes
* *
* @throws \RuntimeException on connection errors * @throws \RuntimeException on connection errors
*/ */
public function readBytes(int $length) public function readBytes(int $length): string
{ {
$temp = fread($this->fsock, $length); $temp = fread($this->fsock, $length);
if (strlen($temp) != $length) { if ($temp === false) {
throw new \RuntimeException('\fread() failed.');
}
if (strlen($temp) !== $length) {
throw new \RuntimeException("Expected $length bytes; got " . strlen($temp)); throw new \RuntimeException("Expected $length bytes; got " . strlen($temp));
} }
return $temp; return $temp;