This commit is contained in:
Daniil Gentili 2020-02-26 11:47:30 +01:00
parent f22263ed78
commit 753e6575ac
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
10 changed files with 52 additions and 39 deletions

View File

@ -138,7 +138,7 @@ class API extends InternalDoc
$this->storage = $this->API->storage ?? $this->storage; $this->storage = $this->API->storage ?? $this->storage;
unset($unserialized); unset($unserialized);
yield from $this->API->initAsynchronously(); yield from $this->API->initAsynchronously();
$this->APIFactory(); $this->APIFactory();
$this->logger->logger(Lang::$current_lang['madelineproto_ready'], Logger::NOTICE); $this->logger->logger(Lang::$current_lang['madelineproto_ready'], Logger::NOTICE);
@ -182,7 +182,7 @@ class API extends InternalDoc
} }
} }
/** /**
* Wakeup function * Wakeup function.
* *
* @return void * @return void
*/ */

View File

@ -48,14 +48,14 @@ final class APIWrapper
private bool $gettingApiId = false; private bool $gettingApiId = false;
/** /**
* Web API template * Web API template.
* *
* @var string * @var string
*/ */
private string $webApiTemplate = ''; private string $webApiTemplate = '';
/** /**
* My.telegram.org wrapper * My.telegram.org wrapper.
* *
* @var ?MyTelegramOrgWrapper * @var ?MyTelegramOrgWrapper
*/ */
@ -69,13 +69,13 @@ final class APIWrapper
private int $serialized = 0; private int $serialized = 0;
/** /**
* AbstractAPIFactory instance * AbstractAPIFactory instance.
* *
* @var AbstractAPIFactory * @var AbstractAPIFactory
*/ */
private AbstractAPIFactory $factory; private AbstractAPIFactory $factory;
/** /**
* API wrapper * API wrapper.
* *
* @param API $API API instance to wrap * @param API $API API instance to wrap
* @param AbstractAPIFactory $factory Factory * @param AbstractAPIFactory $factory Factory
@ -87,11 +87,11 @@ final class APIWrapper
} }
/** /**
* Link two APIWrapper and API instances * Link two APIWrapper and API instances.
* *
* @param API|APIWrapper $a Instance to which link * @param API|APIWrapper $a Instance to which link
* @param API|APIWrapper $b Instance from which link * @param API|APIWrapper $b Instance from which link
* *
* @return void * @return void
*/ */
public static function link($a, $b): void public static function link($a, $b): void
@ -115,7 +115,7 @@ final class APIWrapper
} }
/** /**
* Get MTProto instance * Get MTProto instance.
* *
* @return MTProto|null * @return MTProto|null
*/ */
@ -125,7 +125,7 @@ final class APIWrapper
} }
/** /**
* Get API factory * Get API factory.
* *
* @return AbstractAPIFactory * @return AbstractAPIFactory
*/ */

View File

@ -70,7 +70,7 @@ abstract class AbstractAPIFactory extends AsyncConstruct
*/ */
protected function exportNamespace(string $namespace = ''): self protected function exportNamespace(string $namespace = ''): self
{ {
$class = array_reverse(array_values(class_parents(static::class)))[3]; $class = \array_reverse(\array_values(\class_parents(static::class)))[3];
$instance = new $class; $instance = new $class;
$instance->namespace = $namespace.'.'; $instance->namespace = $namespace.'.';
self::link($instance, $this); self::link($instance, $this);
@ -78,11 +78,11 @@ abstract class AbstractAPIFactory extends AsyncConstruct
return $instance; return $instance;
} }
/** /**
* Link two APIFactory instances * Link two APIFactory instances.
* *
* @param self $a First instance * @param self $a First instance
* @param self $b Second instance * @param self $b Second instance
* *
* @return void * @return void
*/ */
protected static function link(self $a, self $b): void protected static function link(self $a, self $b): void
@ -135,7 +135,7 @@ abstract class AbstractAPIFactory extends AsyncConstruct
} }
} }
/** /**
* Info to dump * Info to dump.
* *
* @return array * @return array
*/ */

View File

@ -68,10 +68,10 @@ class AsyncConstruct
return !$this->asyncInitPromise; return !$this->asyncInitPromise;
} }
/** /**
* Mark instance as (de)inited forcefully * Mark instance as (de)inited forcefully.
* *
* @param boolean $inited Whether to mark the instance as inited or deinited * @param boolean $inited Whether to mark the instance as inited or deinited
* *
* @return void * @return void
*/ */
public function forceInit(bool $inited): void public function forceInit(bool $inited): void

View File

@ -115,7 +115,7 @@ class DataCenter
*/ */
private $CookieJar; private $CookieJar;
/** /**
* DNS connector * DNS connector.
* *
* @var DNSConnector * @var DNSConnector
*/ */
@ -226,7 +226,7 @@ class DataCenter
$nonProxiedDoHConfig = new DoHConfig([new Nameserver('https://mozilla.cloudflare-dns.com/dns-query'), new Nameserver('https://dns.google/resolve')]); $nonProxiedDoHConfig = new DoHConfig([new Nameserver('https://mozilla.cloudflare-dns.com/dns-query'), new Nameserver('https://dns.google/resolve')]);
$this->DoHClient = Magic::$altervista || Magic::$zerowebhost ? new Rfc1035StubResolver() : new Rfc8484StubResolver($DoHConfig); $this->DoHClient = Magic::$altervista || Magic::$zerowebhost ? new Rfc1035StubResolver() : new Rfc8484StubResolver($DoHConfig);
$this->nonProxiedDoHClient = Magic::$altervista || Magic::$zerowebhost ? new Rfc1035StubResolver() : new Rfc8484StubResolver($nonProxiedDoHConfig); $this->nonProxiedDoHClient = Magic::$altervista || Magic::$zerowebhost ? new Rfc1035StubResolver() : new Rfc8484StubResolver($nonProxiedDoHConfig);
$this->dnsConnector = new DnsConnector(new Rfc1035StubResolver()); $this->dnsConnector = new DnsConnector(new Rfc1035StubResolver());
} }
} }

View File

@ -5409,6 +5409,20 @@ class InternalDoc extends APIFactory
{ {
return $this->__call(__FUNCTION__, [$obj, $var]); return $this->__call(__FUNCTION__, [$obj, $var]);
} }
/**
* Sets a private variable in an object.
*
* @param object $obj Object
* @param string $var Attribute name
* @param mixed $val Attribute value
*
* @return mixed
* @access public
*/
public function setVar($obj, string $var, &$val): void
{
\danog\MadelineProto\MTProto::setVar($obj, $var, $val);
}
/** /**
* Discard call. * Discard call.
* *

View File

@ -30,19 +30,19 @@ use danog\MadelineProto\MTProto;
class PeriodicLoop extends ResumableSignalLoop class PeriodicLoop extends ResumableSignalLoop
{ {
/** /**
* Callback * Callback.
* *
* @var callable * @var callable
*/ */
private $callback; private $callback;
/** /**
* Loop name * Loop name.
* *
* @var string * @var string
*/ */
private string $name; private string $name;
/** /**
* Loop timeeout * Loop timeeout.
* *
* @var int * @var int
*/ */

File diff suppressed because one or more lines are too long

View File

@ -24,10 +24,10 @@ use function Amp\ByteStream\getOutputBufferStream;
trait Templates trait Templates
{ {
/** /**
* Echo page to console * Echo page to console.
* *
* @param string $message Error message * @param string $message Error message
* *
* @return \Generator * @return \Generator
*/ */
private function webEcho(string $message = ''): \Generator private function webEcho(string $message = ''): \Generator
@ -57,17 +57,17 @@ trait Templates
} }
} }
/** /**
* Web template * Web template.
* *
* @var string * @var string
*/ */
private $web_template = '<!DOCTYPE html><html><head><title>MadelineProto</title></head><body><h1>MadelineProto</h1><form method="POST">%s<button type="submit"/>Go</button></form><p>%s</p></body></html>'; private $web_template = '<!DOCTYPE html><html><head><title>MadelineProto</title></head><body><h1>MadelineProto</h1><form method="POST">%s<button type="submit"/>Go</button></form><p>%s</p></body></html>';
/** /**
* Format message according to template * Format message according to template.
* *
* @param string $message Message * @param string $message Message
* @param string $form Form contents * @param string $form Form contents
* *
* @return string * @return string
*/ */
private function webEchoTemplate(string $message, string $form): string private function webEchoTemplate(string $message, string $form): string

View File

@ -73,7 +73,7 @@ final class DataCenterTest extends TestCase
); );
$API->datacenter = $datacenter; $API->datacenter = $datacenter;
$API->getLogger()->logger("Testing protocol $protocol using transport $transport, ".($obfuscated ? 'obfuscated ' : 'not obfuscated ').($test_mode ? 'test DC ' : 'main DC ').($ipv6 ? 'IPv6 ' : 'IPv4 ').($doh ? "DNS over HTTPS" : "DNS"); $API->getLogger()->logger("Testing protocol $protocol using transport $transport, ".($obfuscated ? 'obfuscated ' : 'not obfuscated ').($test_mode ? 'test DC ' : 'main DC ').($ipv6 ? 'IPv6 ' : 'IPv4 ').($doh ? "DNS over HTTPS" : "DNS"));
\sleep(1); \sleep(1);
try { try {