From 62ee1a57476d58758f2ceee5a5497eee4ffed793 Mon Sep 17 00:00:00 2001 From: Sokolovskyy Roman Date: Thu, 21 Dec 2017 10:14:53 +0100 Subject: [PATCH] Multiline phpdoc for extract to one liner --- phpseclib/File/ASN1.php | 4 +- phpseclib/Math/BigInteger/Engines/BCMath.php | 4 +- phpseclib/Math/BigInteger/Engines/PHP32.php | 4 +- phpseclib/Math/BigInteger/Engines/PHP64.php | 3 +- phpseclib/Net/SCP.php | 5 +- phpseclib/Net/SFTP.php | 115 +++++++------------ phpseclib/Net/SSH1.php | 9 +- phpseclib/Net/SSH2.php | 83 +++++-------- 8 files changed, 78 insertions(+), 149 deletions(-) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 7145bf59..0d2d05fd 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -292,9 +292,7 @@ abstract class ASN1 $current+= ['headerlength' => $length + 2]; $start+= $length; extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4))); - /** - * @var integer $length - */ + /** @var integer $length */ } else { $current+= ['headerlength' => 2]; } diff --git a/phpseclib/Math/BigInteger/Engines/BCMath.php b/phpseclib/Math/BigInteger/Engines/BCMath.php index 18c9cc5f..dd34f717 100644 --- a/phpseclib/Math/BigInteger/Engines/BCMath.php +++ b/phpseclib/Math/BigInteger/Engines/BCMath.php @@ -341,9 +341,7 @@ class BCMath extends Engine public function gcd(BCMath $n) { extract($this->extendedGCD($n)); - /** - * @var BCMath $gcd - */ + /** @var BCMath $gcd */ return $gcd; } diff --git a/phpseclib/Math/BigInteger/Engines/PHP32.php b/phpseclib/Math/BigInteger/Engines/PHP32.php index ee8d8b2e..8fa7414b 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP32.php +++ b/phpseclib/Math/BigInteger/Engines/PHP32.php @@ -192,9 +192,7 @@ class PHP32 extends PHP */ public function gcd(PHP32 $n) { - $gcd = $this->extendedGCD($n)['gcd']; - - return $gcd; + return $this->extendedGCD($n)['gcd']; } /** diff --git a/phpseclib/Math/BigInteger/Engines/PHP64.php b/phpseclib/Math/BigInteger/Engines/PHP64.php index 7fba8042..ae2bea99 100644 --- a/phpseclib/Math/BigInteger/Engines/PHP64.php +++ b/phpseclib/Math/BigInteger/Engines/PHP64.php @@ -192,8 +192,7 @@ class PHP64 extends PHP */ public function gcd(PHP64 $n) { - $gcd=$this->extendedGCD($n)['gcd']; - return $gcd; + return $this->extendedGCD($n)['gcd']; } /** diff --git a/phpseclib/Net/SCP.php b/phpseclib/Net/SCP.php index e57f3001..2d7f8166 100644 --- a/phpseclib/Net/SCP.php +++ b/phpseclib/Net/SCP.php @@ -307,9 +307,8 @@ class SCP return false; } extract(unpack('Nlength', $response[SSH1::RESPONSE_DATA])); - /** - * @var integer $length - */ + /** @var integer $length */ + return Strings::shift($response[SSH1::RESPONSE_DATA], $length); case NET_SSH1_SMSG_STDERR_DATA: break; diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 2bc3225f..c96ac220 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -494,26 +494,22 @@ class SFTP extends SSH2 return false; } extract(unpack('Nversion', Strings::shift($response, 4))); - /** - * @var integer $version - */ + /** @var integer $version */ + $this->version = $version; while (!empty($response)) { if (strlen($response) < 4) { return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $key = Strings::shift($response, $length); if (strlen($response) < 4) { return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ $value = Strings::shift($response, $length); $this->extensions[$key] = $value; @@ -648,18 +644,14 @@ class SFTP extends SSH2 return; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ } $error = $this->status_codes[$status]; if ($this->version > 2 || strlen($response) < 4) { extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ $this->sftp_errors[] = $error . ': ' . Strings::shift($response, $length); } else { @@ -705,9 +697,7 @@ class SFTP extends SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ return Strings::shift($response, $length); case NET_SFTP_STATUS: @@ -948,27 +938,21 @@ class SFTP extends SSH2 return false; } extract(unpack('Ncount', Strings::shift($response, 4))); - /** - * @var integer $count - */ + /** @var integer $count */ for ($i = 0; $i < $count; $i++) { if (strlen($response) < 4) { return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ $shortname = Strings::shift($response, $length); if (strlen($response) < 4) { return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ $longname = Strings::shift($response, $length); $attributes = $this->parseAttributes($response); @@ -999,9 +983,7 @@ class SFTP extends SSH2 return false; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ if ($status != NET_SFTP_STATUS_EOF) { $this->logError($response, $status); @@ -1604,9 +1586,8 @@ class SFTP extends SSH2 return false; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ + if ($status != NET_SFTP_STATUS_OK) { $this->logError($response, $status); return false; @@ -1723,9 +1704,7 @@ class SFTP extends SSH2 return false; } extract(unpack('Ncount', Strings::shift($response, 4))); - /** - * @var integer $count - */ + /** @var integer $count */ // the file isn't a symlink if (!$count) { return false; @@ -1735,9 +1714,7 @@ class SFTP extends SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ return Strings::shift($response, $length); } @@ -1777,9 +1754,8 @@ class SFTP extends SSH2 return false; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ + if ($status != NET_SFTP_STATUS_OK) { $this->logError($response, $status); return false; @@ -1849,9 +1825,8 @@ class SFTP extends SSH2 return false; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ + if ($status != NET_SFTP_STATUS_OK) { $this->logError($response, $status); return false; @@ -1893,9 +1868,8 @@ class SFTP extends SSH2 return false; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ + if ($status != NET_SFTP_STATUS_OK) { // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED? $this->logError($response, $status); @@ -2134,9 +2108,8 @@ class SFTP extends SSH2 return false; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ + if ($status != NET_SFTP_STATUS_OK) { $this->logError($response, $status); break; @@ -2172,9 +2145,8 @@ class SFTP extends SSH2 return false; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ + if ($status != NET_SFTP_STATUS_OK) { $this->logError($response, $status); return false; @@ -2380,9 +2352,8 @@ class SFTP extends SSH2 return false; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ + if ($status != NET_SFTP_STATUS_OK) { $this->logError($response, $status); if (!$recursive) { @@ -2813,9 +2784,8 @@ class SFTP extends SSH2 return false; } extract(unpack('Nstatus', Strings::shift($response, 4))); - /** - * @var integer $status - */ + /** @var integer $status */ + if ($status != NET_SFTP_STATUS_OK) { $this->logError($response, $status); return false; @@ -2847,9 +2817,8 @@ class SFTP extends SSH2 return []; } extract(unpack('Nflags', Strings::shift($response, 4))); - /** - * @var integer $flags - */ + /** @var integer $flags */ + // SFTPv4+ have a type field (a byte) that follows the above flag field foreach ($this->attributes as $key => $value) { switch ($flags & $key) { @@ -2896,18 +2865,16 @@ class SFTP extends SSH2 return $attr; } extract(unpack('Ncount', Strings::shift($response, 4))); - /** - * @var integer $count - */ + /** @var integer $count */ + for ($i = 0; $i < $count; $i++) { if (strlen($response) < 4) { //user_error('Malformed file attributes'); return $attr; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $key = Strings::shift($response, $length); if (strlen($response) < 4) { @@ -2915,9 +2882,8 @@ class SFTP extends SSH2 return $attr; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $attr[$key] = Strings::shift($response, $length); } } @@ -3074,9 +3040,8 @@ class SFTP extends SSH2 return false; } extract(unpack('Nlength', Strings::shift($this->packet_buffer, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $tempLength = $length; $tempLength-= strlen($this->packet_buffer); diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index 4272ffb5..0dce1262 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -614,9 +614,7 @@ class SSH1 return false; } extract(unpack('Nsupported_ciphers_mask', Strings::shift($response[self::RESPONSE_DATA], 4))); - /** - * @var integer $supported_ciphers_mask - */ + /** @var integer $supported_ciphers_mask */ foreach ($this->supported_ciphers as $mask => $name) { if (($supported_ciphers_mask & (1 << $mask)) == 0) { @@ -629,9 +627,8 @@ class SSH1 return false; } extract(unpack('Nsupported_authentications_mask', Strings::shift($response[self::RESPONSE_DATA], 4))); - /** - * @var integer $supported_authentications_mask - */ + /** @var integer $supported_authentications_mask */ + foreach ($this->supported_authentications as $mask => $name) { if (($supported_authentications_mask & (1 << $mask)) == 0) { unset($this->supported_authentications[$mask]); diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index e3a2155c..b9111b14 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2304,9 +2304,8 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $this->errors[] = 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ: ' . utf8_decode(Strings::shift($response, $length)); return $this->disconnect_helper(NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER); @@ -2317,18 +2316,15 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ $auth_methods = explode(',', Strings::shift($response, $length)); if (!strlen($response)) { return false; } extract(unpack('Cpartial_success', Strings::shift($response, 1))); - /** - * @var integer $partial_success - */ + /** @var integer $partial_success */ + $partial_success = $partial_success != 0; if (!$partial_success && in_array('keyboard-interactive', $auth_methods)) { @@ -2411,27 +2407,21 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ Strings::shift($response, $length); // name; may be empty if (strlen($response) < 4) { return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ Strings::shift($response, $length); // instruction; may be empty if (strlen($response) < 4) { return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ Strings::shift($response, $length); // language tag; may be empty if (strlen($response) < 4) { @@ -2439,6 +2429,7 @@ class SSH2 } extract(unpack('Nnum_prompts', Strings::shift($response, 4))); /** @var integer $num_prompts */ + for ($i = 0; $i < count($responses); $i++) { if (is_array($responses[$i])) { foreach ($responses[$i] as $key => $value) { @@ -2455,9 +2446,7 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ // prompt - ie. "Password: "; must not be empty $prompt = Strings::shift($response, $length); @@ -2615,9 +2604,7 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ $this->errors[] = 'SSH_MSG_USERAUTH_FAILURE: ' . Strings::shift($response, $length); @@ -3378,9 +3365,7 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($payload, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ $this->errors[] = 'SSH_MSG_DEBUG: ' . utf8_decode(Strings::shift($payload, $length)); $payload = $this->get_binary_packet($skip_channel_filter); @@ -3404,9 +3389,8 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($payload, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $this->banner_message = utf8_decode(Strings::shift($payload, $length)); $payload = $this->get_binary_packet(); } @@ -3430,9 +3414,8 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($payload, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $this->errors[] = 'SSH_MSG_GLOBAL_REQUEST: ' . Strings::shift($payload, $length); if (!$this->send_binary_packet(pack('C', NET_SSH2_MSG_REQUEST_FAILURE))) { @@ -3447,15 +3430,15 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($payload, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $data = Strings::shift($payload, $length); if (strlen($payload) < 4) { return false; } extract(unpack('Nserver_channel', Strings::shift($payload, 4))); /** @var integer $server_channel */ + switch ($data) { case 'auth-agent': case 'auth-agent@openssh.com': @@ -3671,9 +3654,7 @@ class SSH2 } if ($type == NET_SSH2_MSG_CHANNEL_OPEN) { extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ } else { extract(unpack('Nchannel', Strings::shift($response, 4))); /** @var integer $channel */ @@ -3791,9 +3772,7 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ $data = Strings::shift($response, $length); @@ -3818,9 +3797,8 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $value = Strings::shift($response, $length); switch ($value) { case 'exit-signal': @@ -3829,18 +3807,16 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + $this->errors[] = 'SSH_MSG_CHANNEL_REQUEST (exit-signal): ' . Strings::shift($response, $length); if (strlen($response) < 4) { return false; } Strings::shift($response, 1); extract(unpack('Nlength', Strings::shift($response, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + if ($length) { $this->errors[count($this->errors)].= "\r\n" . Strings::shift($response, $length); } @@ -4475,9 +4451,8 @@ class SSH2 return false; } extract(unpack('Nlength', Strings::shift($server_public_host_key, 4))); - /** - * @var integer $length - */ + /** @var integer $length */ + Strings::shift($server_public_host_key, $length); if ($this->signature_validated) {