Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2018-03-29 11:25:42 +00:00 committed by StyleCI Bot
parent cf974a2d0a
commit a5246e782d
6 changed files with 29 additions and 9 deletions

View File

@ -192,6 +192,7 @@ class CustomHTTPProxy implements \danog\MadelineProto\Proxy
{ {
$this->options = $extra; $this->options = $extra;
} }
public function getResource() public function getResource()
{ {
return $this->sock->getResource(); return $this->sock->getResource();

View File

@ -185,6 +185,7 @@ class HttpProxy implements \danog\MadelineProto\Proxy
public function getProxyHeaders() public function getProxyHeaders()
{ {
} }
public function getResource() public function getResource()
{ {
return $this->sock->getResource(); return $this->sock->getResource();

View File

@ -97,14 +97,21 @@ If not, see <http://www.gnu.org/licenses/>.
} }
$res = stream_select($actual_read, $actual_write, $actual_except, $tv_sec, $tv_usec); $res = stream_select($actual_read, $actual_write, $actual_except, $tv_sec, $tv_usec);
foreach ($read as $key => $resource) { foreach ($read as $key => $resource) {
if (!isset($actual_read[$key])) unset($read[$key]); if (!isset($actual_read[$key])) {
unset($read[$key]);
}
} }
foreach ($write as $key => $resource) { foreach ($write as $key => $resource) {
if (!isset($actual_write[$key])) unset($write[$key]); if (!isset($actual_write[$key])) {
unset($write[$key]);
}
} }
foreach ($except as $key => $resource) { foreach ($except as $key => $resource) {
if (!isset($actual_except[$key])) unset($except[$key]); if (!isset($actual_except[$key])) {
unset($except[$key]);
}
} }
return $res; return $res;
} }
@ -147,6 +154,7 @@ If not, see <http://www.gnu.org/licenses/>.
{ {
return ''; return '';
} }
public function getResource() public function getResource()
{ {
return $this->sock; return $this->sock;
@ -233,18 +241,24 @@ if (!extension_loaded('pthreads')) {
} }
$res = socket_select($actual_read, $actual_write, $actual_except, $tv_sec, $tv_usec); $res = socket_select($actual_read, $actual_write, $actual_except, $tv_sec, $tv_usec);
foreach ($read as $key => $resource) { foreach ($read as $key => $resource) {
if (!isset($actual_read[$key])) unset($read[$key]); if (!isset($actual_read[$key])) {
unset($read[$key]);
}
} }
foreach ($write as $key => $resource) { foreach ($write as $key => $resource) {
if (!isset($actual_write[$key])) unset($write[$key]); if (!isset($actual_write[$key])) {
unset($write[$key]);
}
} }
foreach ($except as $key => $resource) { foreach ($except as $key => $resource) {
if (!isset($actual_except[$key])) unset($except[$key]); if (!isset($actual_except[$key])) {
unset($except[$key]);
}
} }
return $res; return $res;
} }
public function read(int $length, int $flags = 0) public function read(int $length, int $flags = 0)
{ {
return socket_read($this->sock, $length, $flags); return socket_read($this->sock, $length, $flags);
@ -288,6 +302,7 @@ if (!extension_loaded('pthreads')) {
{ {
return ''; return '';
} }
public function getResource() public function getResource()
{ {
return $this->sock; return $this->sock;

View File

@ -413,6 +413,7 @@ class Connection
return ['protocol' => $protocol, 'code' => $code, 'description' => $description, 'body' => $read, 'headers' => $headers]; return ['protocol' => $protocol, 'code' => $code, 'description' => $description, 'body' => $read, 'headers' => $headers];
} }
public function getSocket() public function getSocket()
{ {
return $this->sock; return $this->sock;

View File

@ -144,15 +144,17 @@ class DataCenter
return $all ? array_keys((array) $this->dclist[$test][$ipv6]) : array_keys((array) $this->sockets); return $all ? array_keys((array) $this->dclist[$test][$ipv6]) : array_keys((array) $this->sockets);
} }
public function select() public function select()
{ {
$read = []; $read = [];
$write = []; $write = [];
$except = []; $except = [];
foreach ($this->sockets as $dc_id => $socket) { foreach ($this->sockets as $dc_id => $socket) {
$read [$dc_id] = $socket->getSocket(); $read[$dc_id] = $socket->getSocket();
} }
\Socket::select($read, $write, $except, 0); \Socket::select($read, $write, $except, 0);
return array_keys($read); return array_keys($read);
} }
} }

View File

@ -227,7 +227,7 @@ if (!extension_loaded('php-libtgvoip') && false) {
private function init_all() private function init_all()
{ {
foreach ($this->datacenter->sockets as $dc_id => $socket) { foreach ($this->datacenter->sockets as $dc_id => $socket) {
if ($socket->auth_key === NULL) { if ($socket->auth_key === null) {
$socket->auth_key = ['id' => $this->configuration['auth_key_id'], 'auth_key' => $this->configuration['auth_key']]; $socket->auth_key = ['id' => $this->configuration['auth_key_id'], 'auth_key' => $this->configuration['auth_key']];
} }
} }