Minor renaming
This commit is contained in:
parent
ba454eda24
commit
a64cfca66c
@ -138,7 +138,7 @@ class API extends InternalDoc
|
||||
$this->APIFactory();
|
||||
$unserialized->oldInstance = true;
|
||||
$deferred->resolve();
|
||||
yield $this->API->initAsync();
|
||||
yield $this->API->initAsynchronously();
|
||||
$this->APIFactory();
|
||||
//\danog\MadelineProto\Logger::log('Ping...', Logger::ULTRA_VERBOSE);
|
||||
$this->asyncInitPromise = null;
|
||||
@ -161,7 +161,7 @@ class API extends InternalDoc
|
||||
$this->APIFactory();
|
||||
$deferred->resolve();
|
||||
Logger::log(\danog\MadelineProto\Lang::$current_lang['apifactory_start'], Logger::VERBOSE);
|
||||
yield $this->API->initAsync();
|
||||
yield $this->API->initAsynchronously();
|
||||
$this->APIFactory();
|
||||
$this->asyncInitPromise = null;
|
||||
//\danog\MadelineProto\Logger::log('Ping...', Logger::ULTRA_VERBOSE);
|
||||
@ -300,7 +300,7 @@ class API extends InternalDoc
|
||||
return false;
|
||||
}
|
||||
if ($this->API && $this->API->asyncInitPromise) {
|
||||
yield $this->API->initAsync();
|
||||
yield $this->API->initAsynchronously();
|
||||
}
|
||||
$this->serialized = \time();
|
||||
$realpaths = Serialization::realpaths($filename);
|
||||
|
@ -160,7 +160,7 @@ class APIFactory extends AsyncConstruct
|
||||
public function __call_async($name, $arguments)
|
||||
{
|
||||
if ($this->asyncInitPromise) {
|
||||
yield $this->initAsync();
|
||||
yield $this->initAsynchronously();
|
||||
$this->API->logger->logger('Finished init asynchronously');
|
||||
}
|
||||
if (Magic::is_fork() && !Magic::$processed_fork) {
|
||||
@ -170,7 +170,7 @@ class APIFactory extends AsyncConstruct
|
||||
throw new Exception('API did not init!');
|
||||
}
|
||||
if ($this->API->asyncInitPromise) {
|
||||
yield $this->API->initAsync();
|
||||
yield $this->API->initAsynchronously();
|
||||
$this->API->logger->logger('Finished init asynchronously');
|
||||
}
|
||||
if (isset($this->session) && !\is_null($this->session) && \time() - $this->serialized > $this->API->settings['serialization']['serialization_interval']) {
|
||||
@ -180,10 +180,10 @@ class APIFactory extends AsyncConstruct
|
||||
if ($this->API->flushSettings) {
|
||||
$this->API->flushSettings = false;
|
||||
$this->API->__construct($this->API->settings);
|
||||
yield $this->API->initAsync();
|
||||
yield $this->API->initAsynchronously();
|
||||
}
|
||||
if ($this->API->asyncInitPromise) {
|
||||
yield $this->API->initAsync();
|
||||
yield $this->API->initAsynchronously();
|
||||
$this->API->logger->logger('Finished init asynchronously');
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class AsyncConstruct
|
||||
}
|
||||
}
|
||||
|
||||
public function initAsync()
|
||||
public function initAsynchronously()
|
||||
{
|
||||
if ($this->asyncInitPromise) {
|
||||
yield $this->asyncInitPromise;
|
||||
|
@ -234,7 +234,7 @@ class CombinedAPI
|
||||
|
||||
$loops = [];
|
||||
foreach ($this->instances as $path => $instance) {
|
||||
$this->wait($instance->initAsync());
|
||||
$this->wait($instance->initAsynchronously());
|
||||
if ($instance->API->authorized !== MTProto::LOGGED_IN) {
|
||||
continue;
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ trait Buffer
|
||||
{
|
||||
public function bufferRead(int $length): Promise
|
||||
{
|
||||
return $this->call($this->bufferReadAsync($length));
|
||||
return $this->call($this->bufferReadGenerator($length));
|
||||
}
|
||||
|
||||
public function bufferWrite(string $data): Promise
|
||||
{
|
||||
return $this->call($this->bufferWriteAsync($data));
|
||||
return $this->call($this->bufferWriteGenerator($data));
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ trait BufferedStream
|
||||
*/
|
||||
public function getReadBuffer(&$length): Promise
|
||||
{
|
||||
return $this->call($this->getReadBufferAsync($length));
|
||||
return $this->call($this->getReadBufferGenerator($length));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,6 +53,6 @@ trait BufferedStream
|
||||
*/
|
||||
public function getWriteBuffer(int $length, string $append = ''): Promise
|
||||
{
|
||||
return $this->call($this->getWriteBufferAsync($length, $append));
|
||||
return $this->call($this->getWriteBufferGenerator($length, $append));
|
||||
}
|
||||
}
|
||||
|
@ -33,16 +33,16 @@ trait RawStream
|
||||
|
||||
public function read(): Promise
|
||||
{
|
||||
return $this->call($this->readAsync());
|
||||
return $this->call($this->readGenerator());
|
||||
}
|
||||
|
||||
public function write(string $data): Promise
|
||||
{
|
||||
return $this->call($this->writeAsync($data));
|
||||
return $this->call($this->writeGenerator($data));
|
||||
}
|
||||
|
||||
public function end(string $finalData = ''): Promise
|
||||
{
|
||||
return $this->call($this->endAsync($finalData));
|
||||
return $this->call($this->endGenerator($finalData));
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ trait Stream
|
||||
|
||||
public function connect(ConnectionContext $ctx, string $header = ''): Promise
|
||||
{
|
||||
return $this->call($this->connectAsync($ctx, $header));
|
||||
return $this->call($this->connectGenerator($ctx, $header));
|
||||
}
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ trait Tools
|
||||
*/
|
||||
public static function flock(string $file, int $operation, $polling = 0.1): Promise
|
||||
{
|
||||
return self::call(self::flockAsync($file, $operation, $polling));
|
||||
return self::call(self::flockGenerator($file, $operation, $polling));
|
||||
}
|
||||
public static function noCache(int $status, string $message)
|
||||
{
|
||||
@ -390,7 +390,7 @@ trait Tools
|
||||
\http_response_code($status);
|
||||
return self::echo($message);
|
||||
}
|
||||
public static function flockAsync(string $file, int $operation, $polling)
|
||||
public static function flockGenerator(string $file, int $operation, $polling)
|
||||
{
|
||||
if (!yield exists($file)) {
|
||||
yield \touch($file);
|
||||
@ -419,9 +419,9 @@ trait Tools
|
||||
}
|
||||
public static function readLine($prompt = '')
|
||||
{
|
||||
return self::call(Tools::readLineAsync($prompt));
|
||||
return self::call(Tools::readLineGenerator($prompt));
|
||||
}
|
||||
public static function readLineAsync($prompt = '')
|
||||
public static function readLineGenerator($prompt = '')
|
||||
{
|
||||
$stdin = getStdin();
|
||||
$stdout = getStdout();
|
||||
|
78
tools/std.php
Normal file
78
tools/std.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
use danog\MadelineProto\Tools;
|
||||
use HaydenPierce\ClassFinder\ClassFinder;
|
||||
|
||||
\chdir(__DIR__.'/../');
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
$classes = ClassFinder::getClassesInNamespace(danog\MadelineProto::class, ClassFinder::RECURSIVE_MODE);
|
||||
$methods = [];
|
||||
foreach ($classes as $class) {
|
||||
$class = new \ReflectionClass($class);
|
||||
$methods = \array_merge($class->getMethods(), $methods);
|
||||
}
|
||||
$methods = array_unique($methods);
|
||||
|
||||
function ssort($a, $b)
|
||||
{
|
||||
return \strlen($b->getName())-\strlen($a->getName());
|
||||
}
|
||||
|
||||
\usort($methods, 'ssort');
|
||||
|
||||
$find = [];
|
||||
$replace = [];
|
||||
foreach ($methods as $methodObj) {
|
||||
$method = $methodObj->getName();
|
||||
if (\strpos($method, '__') === 0 || $method === 'async') {
|
||||
continue;
|
||||
}
|
||||
$new = Tools::from_snake_case($method);
|
||||
$new = \str_ireplace(['mtproto', 'api'], ['MTProto', 'API'], $new);
|
||||
$new = preg_replace('/async$/i', '', $new);
|
||||
|
||||
if (method_exists((string) $methodObj->getDeclaringClass(), preg_replace('/async$/i', '', $method))) {
|
||||
var_dump("Skipping $method => $new");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!function_exists($method)) {
|
||||
$find[] = "$method(";
|
||||
$replace[] = "$new(";
|
||||
continue;
|
||||
}
|
||||
$find[] = ">$method(";
|
||||
$replace[] = ">$new(";
|
||||
|
||||
$find[] = ":$method(";
|
||||
$replace[] = ":$new(";
|
||||
|
||||
$find[] = "function $method(";
|
||||
$replace[] = "function $new(";
|
||||
}
|
||||
|
||||
foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(\realpath('src'))), '/\.php$/') as $filename) {
|
||||
$filename = (string) $filename;
|
||||
$new = \str_replace($find, $replace, $old = \file_get_contents($filename));
|
||||
do {
|
||||
\file_put_contents($filename, $new);
|
||||
$new = \str_replace($find, $replace, $old = \file_get_contents($filename));
|
||||
} while ($old !== $new);
|
||||
}
|
||||
foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(\realpath('docs'))), '/\.md$/') as $filename) {
|
||||
$filename = (string) $filename;
|
||||
$new = \str_replace($find, $replace, $old = \file_get_contents($filename));
|
||||
do {
|
||||
\file_put_contents($filename, $new);
|
||||
$new = \str_replace($find, $replace, $old = \file_get_contents($filename));
|
||||
} while ($old !== $new);
|
||||
}
|
||||
$filename = 'README.md';
|
||||
|
||||
$new = \str_replace($find, $replace, $old = \file_get_contents($filename));
|
||||
do {
|
||||
\file_put_contents($filename, $new);
|
||||
$new = \str_replace($find, $replace, $old = \file_get_contents($filename));
|
||||
} while ($old !== $new);
|
Loading…
Reference in New Issue
Block a user