diff --git a/docs b/docs index 83cd0b56..d119b3d8 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 83cd0b565ea0bf2f73747cb6a41f2ce3cc99280e +Subproject commit d119b3d80dbc435330a671038e8e5d0f329df4cc diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index 0919250c..c2fbc039 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -285,4 +285,59 @@ class API extends InternalDoc } } } + /** + * Get attribute. + * + * @param string $name Attribute nam + * + * @internal + * + * @return mixed + */ + public function &__get(string $name) + { + if ($name === 'logger') { + if (isset($this->API)) { + return $this->API->logger; + } + return Logger::$default; + } + return $this->storage[$name]; + } + /** + * Set an attribute. + * + * @param string $name Name + * @param mixed $value Value + * + * @internal + * + * @return mixed + */ + public function __set(string $name, $value) + { + return $this->storage[$name] = $value; + } + /** + * Whether an attribute exists. + * + * @param string $name Attribute name + * + * @return boolean + */ + public function __isset(string $name): bool + { + return isset($this->storage[$name]); + } + /** + * Unset attribute. + * + * @param string $name Attribute name + * + * @return void + */ + public function __unset(string $name): void + { + unset($this->storage[$name]); + } } diff --git a/src/danog/MadelineProto/APIWrapper.php b/src/danog/MadelineProto/APIWrapper.php index 774d9dc7..c8093d27 100644 --- a/src/danog/MadelineProto/APIWrapper.php +++ b/src/danog/MadelineProto/APIWrapper.php @@ -127,7 +127,7 @@ final class APIWrapper */ public static function __sleep(): array { - return ['API', 'webApiTemplate', 'gettingApiId', 'myTelegramOrgWrapper', 'storage', 'lua', 'async']; + return ['API', 'webApiTemplate', 'gettingApiId', 'myTelegramOrgWrapper', 'storage', 'lua']; //, 'async']; } /** diff --git a/src/danog/MadelineProto/AbstractAPIFactory.php b/src/danog/MadelineProto/AbstractAPIFactory.php index 44c07315..b0f5270c 100644 --- a/src/danog/MadelineProto/AbstractAPIFactory.php +++ b/src/danog/MadelineProto/AbstractAPIFactory.php @@ -230,59 +230,4 @@ abstract class AbstractAPIFactory extends AsyncConstruct $cache[$class] = $finalMethods; return self::getInternalMethodList($value); } - /** - * Get attribute. - * - * @param string $name Attribute nam - * - * @internal - * - * @return mixed - */ - public function &__get(string $name) - { - if ($name === 'logger') { - if (isset($this->API)) { - return $this->API->logger; - } - return Logger::$default; - } - return $this->storage[$name]; - } - /** - * Set an attribute. - * - * @param string $name Name - * @param mixed $value Value - * - * @internal - * - * @return mixed - */ - public function __set(string $name, $value) - { - return $this->storage[$name] = $value; - } - /** - * Whether an attribute exists. - * - * @param string $name Attribute name - * - * @return boolean - */ - public function __isset(string $name): bool - { - return isset($this->storage[$name]); - } - /** - * Unset attribute. - * - * @param string $name Attribute name - * - * @return void - */ - public function __unset(string $name): void - { - unset($this->storage[$name]); - } } diff --git a/tools/phar.php b/tools/phar.php index 8bb1c72a..60c9f733 100644 --- a/tools/phar.php +++ b/tools/phar.php @@ -37,7 +37,7 @@ function ___install_madeline() if (\file_exists($file)) { $contents = \file_get_contents($file); - if (\strpos($contents, 'new \danog\MadelineProto\Server') && \in_array($contents, [\file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/2270bd9a94d168a5e6731ffd7e61821ea244beff/mtproxyd'), \file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/7cabb718ec3ccb79e3c8e3d34f5bccbe3f63b0fd/mtproxyd')]) && ($mtproxyd = \file_get_contents('https://phar.madelineproto.xyz/mtproxyd?v=new'))) { + if (\strpos($contents, 'new \danog\MadelineProto\Server') && \in_array($contents, [@\file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/2270bd9a94d168a5e6731ffd7e61821ea244beff/mtproxyd'), @\file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/7cabb718ec3ccb79e3c8e3d34f5bccbe3f63b0fd/mtproxyd')]) && ($mtproxyd = @\file_get_contents('https://phar.madelineproto.xyz/mtproxyd?v=new'))) { \file_put_contents($file, $mtproxyd); return; @@ -116,15 +116,31 @@ function ___install_madeline() ]; } + if (defined('HHVM_VERSION')) { + $phpVersion = 'HHVM ' . HHVM_VERSION; + } else { + $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION; + } $opts = ['http' => [ 'method' => 'POST', - 'header' => ['Content-Type: application/json'], + 'header' => [ + 'Content-Type: application/json', + sprintf( + 'User-Agent: Composer/%s (%s; %s; %s; %s%s)', + 'MadelineProto', + function_exists('php_uname') ? @php_uname('s') : 'Unknown', + function_exists('php_uname') ? @php_uname('r') : 'Unknown', + $phpVersion, + 'streams', + getenv('CI') ? '; CI' : '' + ) + ], 'content' => \json_encode($postData), 'timeout' => 6, ], ]; - @\file_get_contents("https://packagist.org/downloads/", false, \stream_context_create($opts)); + //@\file_get_contents("https://packagist.org/downloads/", false, \stream_context_create($opts)); } } }