Misc fixes

This commit is contained in:
Daniil Gentili 2020-06-20 13:03:15 +02:00
parent 838cf11ff6
commit 58e0985d33
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
5 changed files with 76 additions and 60 deletions

2
docs

@ -1 +1 @@
Subproject commit 83cd0b565ea0bf2f73747cb6a41f2ce3cc99280e
Subproject commit d119b3d80dbc435330a671038e8e5d0f329df4cc

View File

@ -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]);
}
}

View File

@ -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'];
}
/**

View File

@ -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]);
}
}

View File

@ -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));
}
}
}