mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-09-07 22:29:02 +00:00
CS adjustment
This commit is contained in:
parent
dc15f18bc6
commit
44d5ca2ab5
@ -724,8 +724,6 @@ class SSH2
|
||||
|
||||
/**
|
||||
* Time of last read/write network activity
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private float|null $last_packet = null;
|
||||
|
||||
@ -1483,7 +1481,7 @@ class SSH2
|
||||
$this->updateLogHistory('UNKNOWN (34)', 'SSH_MSG_KEXDH_GEX_REQUEST');
|
||||
|
||||
$response = $this->get_binary_packet_or_close(MessageTypeExtra::KEXDH_GEX_GROUP);
|
||||
list($type, $primeBytes, $gBytes) = Strings::unpackSSH2('Css', $response);
|
||||
[$type, $primeBytes, $gBytes] = Strings::unpackSSH2('Css', $response);
|
||||
$this->updateLogHistory('UNKNOWN (31)', 'SSH_MSG_KEXDH_GEX_GROUP');
|
||||
|
||||
$prime = new BigInteger($primeBytes, -256);
|
||||
@ -3653,8 +3651,6 @@ class SSH2
|
||||
* on other channels is buffered. The respective negative value of a channel is
|
||||
* also supported for the case that the caller is awaiting adjustment of the data
|
||||
* window, and where data received on that respective channel is also buffered.
|
||||
* @param bool $skip_extended
|
||||
* @return mixed
|
||||
* @throws RuntimeException on connection error
|
||||
*/
|
||||
protected function get_channel_packet(int $client_channel, bool $skip_extended = false)
|
||||
@ -4143,8 +4139,9 @@ class SSH2
|
||||
*/
|
||||
protected function send_channel_packet(int $client_channel, string $data): void
|
||||
{
|
||||
if (isset($this->channel_buffers_write[$client_channel])
|
||||
&& strpos($data, $this->channel_buffers_write[$client_channel]) === 0
|
||||
if (
|
||||
isset($this->channel_buffers_write[$client_channel])
|
||||
&& str_starts_with($data, $this->channel_buffers_write[$client_channel])
|
||||
) {
|
||||
// if buffer holds identical initial data content, resume send from the unmatched data portion
|
||||
$data = substr($data, strlen($this->channel_buffers_write[$client_channel]));
|
||||
|
@ -571,7 +571,7 @@ class SSH2Test extends PhpseclibFunctionalTestCase
|
||||
$this->assertSame(0, $ssh->getOpenChannelCount());
|
||||
}
|
||||
|
||||
public function testKeepAlive()
|
||||
public function testKeepAlive(): void
|
||||
{
|
||||
$ssh = $this->getSSH2();
|
||||
$username = $this->getEnv('SSH_USERNAME');
|
||||
|
@ -99,9 +99,9 @@ abstract class PhpseclibTestCase extends TestCase
|
||||
return $prop->getValue($obj);
|
||||
}
|
||||
|
||||
protected static function setVar($obj, $var, $value)
|
||||
protected static function setVar($obj, $var, $value): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(get_class($obj));
|
||||
$reflection = new \ReflectionClass($obj::class);
|
||||
// private variables are not inherited, climb hierarchy until located
|
||||
while (true) {
|
||||
try {
|
||||
|
@ -223,7 +223,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
/**
|
||||
* @requires PHPUnit < 10
|
||||
*/
|
||||
public function testGetStreamTimeout()
|
||||
public function testGetStreamTimeout(): void
|
||||
{
|
||||
// no curTimeout, no keepAlive
|
||||
$ssh = $this->createSSHMock();
|
||||
@ -238,7 +238,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
$ssh = $this->createSSHMock();
|
||||
$ssh->setKeepAlive(2);
|
||||
self::setVar($ssh, 'last_packet', microtime(true));
|
||||
list($sec, $usec) = self::callFunc($ssh, 'get_stream_timeout');
|
||||
[$sec, $usec] = self::callFunc($ssh, 'get_stream_timeout');
|
||||
$this->assertGreaterThanOrEqual(1, $sec);
|
||||
$this->assertLessThanOrEqual(2, $sec);
|
||||
|
||||
@ -254,7 +254,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
$ssh->setTimeout(5);
|
||||
$ssh->setKeepAlive(2);
|
||||
self::setVar($ssh, 'last_packet', microtime(true));
|
||||
list($sec, $usec) = self::callFunc($ssh, 'get_stream_timeout');
|
||||
[$sec, $usec] = self::callFunc($ssh, 'get_stream_timeout');
|
||||
$this->assertGreaterThanOrEqual(1, $sec);
|
||||
$this->assertLessThanOrEqual(2, $sec);
|
||||
|
||||
@ -273,7 +273,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
/**
|
||||
* @requires PHPUnit < 10
|
||||
*/
|
||||
public function testSendChannelPacketNoBufferedData()
|
||||
public function testSendChannelPacketNoBufferedData(): void
|
||||
{
|
||||
$ssh = $this->getMockBuilder('phpseclib3\Net\SSH2')
|
||||
->disableOriginalConstructor()
|
||||
@ -282,7 +282,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
$ssh->expects($this->once())
|
||||
->method('get_channel_packet')
|
||||
->with(-1)
|
||||
->willReturnCallback(function () use ($ssh) {
|
||||
->willReturnCallback(function () use ($ssh): void {
|
||||
self::setVar($ssh, 'window_size_client_to_server', [1 => 0x7FFFFFFF]);
|
||||
});
|
||||
$ssh->expects($this->once())
|
||||
@ -300,7 +300,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
/**
|
||||
* @requires PHPUnit < 10
|
||||
*/
|
||||
public function testSendChannelPacketBufferedData()
|
||||
public function testSendChannelPacketBufferedData(): void
|
||||
{
|
||||
$ssh = $this->getMockBuilder('phpseclib3\Net\SSH2')
|
||||
->disableOriginalConstructor()
|
||||
@ -309,7 +309,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
$ssh->expects($this->once())
|
||||
->method('get_channel_packet')
|
||||
->with(-1)
|
||||
->willReturnCallback(function () use ($ssh) {
|
||||
->willReturnCallback(function () use ($ssh): void {
|
||||
self::setVar($ssh, 'window_size_client_to_server', [1 => 0x7FFFFFFF]);
|
||||
});
|
||||
$ssh->expects($this->once())
|
||||
@ -328,7 +328,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
/**
|
||||
* @requires PHPUnit < 10
|
||||
*/
|
||||
public function testSendChannelPacketTimeout()
|
||||
public function testSendChannelPacketTimeout(): void
|
||||
{
|
||||
$this->expectException(TimeoutException::class);
|
||||
$this->expectExceptionMessage('Timed out waiting for server');
|
||||
@ -340,7 +340,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
$ssh->expects($this->once())
|
||||
->method('get_channel_packet')
|
||||
->with(-1)
|
||||
->willReturnCallback(function () use ($ssh) {
|
||||
->willReturnCallback(function () use ($ssh): void {
|
||||
self::setVar($ssh, 'is_timeout', true);
|
||||
});
|
||||
$ssh->expects($this->once())
|
||||
@ -358,7 +358,7 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
/**
|
||||
* @requires PHPUnit < 10
|
||||
*/
|
||||
public function testSendChannelPacketNoWindowAdjustment()
|
||||
public function testSendChannelPacketNoWindowAdjustment(): void
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Data window was not adjusted');
|
||||
@ -380,9 +380,6 @@ class SSH2UnitTest extends PhpseclibTestCase
|
||||
self::callFunc($ssh, 'send_channel_packet', [1, 'hello world']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \phpseclib3\Net\SSH2
|
||||
*/
|
||||
protected function createSSHMock(): SSH2
|
||||
{
|
||||
return $this->getMockBuilder('phpseclib3\Net\SSH2')
|
||||
|
Loading…
Reference in New Issue
Block a user