From e58e99a37a71eb843508e788b33d02131624cdc9 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 20 Feb 2018 11:25:25 +0000 Subject: [PATCH] Apply fixes from StyleCI --- makephar.php | 13 +++++++------ src/danog/MadelineProto/API.php | 1 + src/danog/MadelineProto/Connection.php | 4 +++- src/danog/MadelineProto/Serialization.php | 5 ++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/makephar.php b/makephar.php index 63f3f735..07c93d60 100755 --- a/makephar.php +++ b/makephar.php @@ -12,17 +12,18 @@ If not, see . */ require 'vendor/autoload.php'; -use \Spatie\Php7to5\DirectoryConverter; +use Spatie\Php7to5\DirectoryConverter; -function rimraf($dir) { +function rimraf($dir) +{ if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { - if ($object != "." && $object != "..") { - if (is_dir($dir."/".$object)) { - rimraf($dir."/".$object); + if ($object != '.' && $object != '..') { + if (is_dir($dir.'/'.$object)) { + rimraf($dir.'/'.$object); } else { - unlink($dir."/".$object); + unlink($dir.'/'.$object); } } } diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index ae1d0c86..e1b1e753 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -34,6 +34,7 @@ class API extends APIFactory $realpaths['lockfile'] = fopen($realpaths['lockfile'], 'r'); \danog\MadelineProto\Logger::log(['Waiting for shared lock of serialization lockfile...']); flock($realpaths['lockfile'], LOCK_SH); + try { $unserialized = file_get_contents($realpaths['file']); } finally { diff --git a/src/danog/MadelineProto/Connection.php b/src/danog/MadelineProto/Connection.php index f904e0b0..dedea6f6 100644 --- a/src/danog/MadelineProto/Connection.php +++ b/src/danog/MadelineProto/Connection.php @@ -161,7 +161,9 @@ class Connection if ($this->parsed['host'][0] === '[') { $this->parsed['host'] = substr($this->parsed['host'], 1, -1); } - if ($this->protocol === 'https' && $proxy === '\Socket') $proxy = '\FSocket'; + if ($this->protocol === 'https' && $proxy === '\Socket') { + $proxy = '\FSocket'; + } $this->sock = new $proxy($ipv6 ? \AF_INET6 : \AF_INET, \SOCK_STREAM, $this->protocol === 'https' ? PHP_INT_MAX : getprotobyname('tcp')); if ($has_proxy && $this->extra !== []) { $this->sock->setExtra($this->extra); diff --git a/src/danog/MadelineProto/Serialization.php b/src/danog/MadelineProto/Serialization.php index 069492d6..5affb851 100644 --- a/src/danog/MadelineProto/Serialization.php +++ b/src/danog/MadelineProto/Serialization.php @@ -31,10 +31,12 @@ class Serialization } } - public static function realpaths($file) { + public static function realpaths($file) + { if ($file[0] !== '/') { $file = getcwd().'/'.$file; } + return ['file' => $file, 'lockfile' => $file.'.lock', 'tempfile' => $file.'.temp.session']; } @@ -95,6 +97,7 @@ class Serialization \danog\MadelineProto\Logger::log(['Waiting for shared lock of serialization lockfile...']); flock($realpaths['lockfile'], LOCK_SH); + try { $unserialized = file_get_contents($realpaths['file']); } finally {