diff --git a/examples/magnaluna b/examples/magnaluna index 1f3cae09..499f1d8e 160000 --- a/examples/magnaluna +++ b/examples/magnaluna @@ -1 +1 @@ -Subproject commit 1f3cae095fb9d4cfc48a178f246d80ac81eea108 +Subproject commit 499f1d8ec8f7f2f554d0b347bd06c26404a2e402 diff --git a/examples/pipesbot b/examples/pipesbot index a13d70b2..a8e5d660 160000 --- a/examples/pipesbot +++ b/examples/pipesbot @@ -1 +1 @@ -Subproject commit a13d70b29c10d39a0f46caf86c1c560ffe26f254 +Subproject commit a8e5d660b61d231960705c33a951a78ce11e27de diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index b1861598..05dc305a 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -88,7 +88,7 @@ class API extends InternalDoc } catch (\danog\MadelineProto\Bug74586Exception $e) { \class_exists('\\Volatile'); $tounserialize = \str_replace('O:26:"danog\\MadelineProto\\Button":', 'O:35:"danog\\MadelineProto\\TL\\Types\\Button":', $tounserialize); - foreach (['RSA', 'TL\\TLMethod', 'TL\\TLConstructor', 'MTProto', 'API', 'DataCenter', 'Connection', 'TL\\Types\\Button', 'TL\\Types\\Bytes', 'APIFactory'] as $class) { + foreach (['RSA', 'TL\\TLMethods', 'TL\\TLConstructors', 'MTProto', 'API', 'DataCenter', 'Connection', 'TL\\Types\\Button', 'TL\\Types\\Bytes', 'APIFactory'] as $class) { \class_exists('\\danog\\MadelineProto\\'.$class); } $unserialized = \danog\Serialization::unserialize($tounserialize); @@ -100,7 +100,7 @@ class API extends InternalDoc throw $e; } \class_exists('\\Volatile'); - foreach (['RSA', 'TL\\TLMethod', 'TL\\TLConstructor', 'MTProto', 'API', 'DataCenter', 'Connection', 'TL\\Types\\Button', 'TL\\Types\\Bytes', 'APIFactory'] as $class) { + foreach (['RSA', 'TL\\TLMethods', 'TL\\TLConstructors', 'MTProto', 'API', 'DataCenter', 'Connection', 'TL\\Types\\Button', 'TL\\Types\\Bytes', 'APIFactory'] as $class) { \class_exists('\\danog\\MadelineProto\\'.$class); } $changed = false; diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index 246e8a22..205e7526 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -35,13 +35,13 @@ class TL /** * Constructors. * - * @var TLConstructor + * @var TLConstructors */ private $constructors; /** * Methods. * - * @var TLMethod + * @var TLMethods */ private $methods; /** @@ -53,7 +53,7 @@ class TL /** * TD Methods. * - * @var TLMethod + * @var TLMethods */ private $td_methods; /** @@ -99,9 +99,9 @@ class TL * * @param int $td Whether to get TD or normal methods * - * @return TLConstructor + * @return TLConstructors */ - public function getConstructors(bool $td = false): TLConstructor + public function getConstructors(bool $td = false): TLConstructors { return $td ? $this->td_constructors : $this->constructors; } @@ -111,9 +111,9 @@ class TL * * @param int $td Whether to get TD or normal methods * - * @return TLMethod + * @return TLMethods */ - public function getMethods(bool $td = false): TLMethod + public function getMethods(bool $td = false): TLMethods { return $td ? $this->td_methods : $this->methods; } @@ -140,10 +140,10 @@ class TL { $this->API->logger->logger(\danog\MadelineProto\Lang::$current_lang['TL_loading'], \danog\MadelineProto\Logger::VERBOSE); $this->updateCallbacks($objects); - $this->constructors = new TLConstructor(); - $this->methods = new TLMethod(); - $this->td_constructors = new TLConstructor(); - $this->td_methods = new TLMethod(); + $this->constructors = new TLConstructors(); + $this->methods = new TLMethods(); + $this->td_constructors = new TLConstructors(); + $this->td_methods = new TLMethods(); $this->td_descriptions = ['types' => [], 'constructors' => [], 'methods' => []]; foreach ($files as $scheme_type => $file) { $this->API->logger->logger(\sprintf(\danog\MadelineProto\Lang::$current_lang['file_parsing'], \basename($file)), \danog\MadelineProto\Logger::VERBOSE); diff --git a/src/danog/MadelineProto/TL/TLConstructor.php b/src/danog/MadelineProto/TL/TLConstructors.php similarity index 98% rename from src/danog/MadelineProto/TL/TLConstructor.php rename to src/danog/MadelineProto/TL/TLConstructors.php index c23af03d..94b7194e 100644 --- a/src/danog/MadelineProto/TL/TLConstructor.php +++ b/src/danog/MadelineProto/TL/TLConstructors.php @@ -1,7 +1,7 @@ getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC); + +function ssort($a, $b) +{ + return \strlen($b->getName())-\strlen($a->getName()); +} + +\usort($methods, 'ssort'); + +$find = []; +$replace = []; +$findDocs = []; +$replaceDocs = []; +foreach ($methods as $methodObj) { + $method = $methodObj->getName(); + + $find[] = "\$this->$method("; + $replace[] = "\\danog\\MadelineProto\\Tools::$method("; +} + +foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(\realpath('.'))), '/\.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); +} +exit; + +foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(\realpath('docs'))), '/\.md$/') as $filename) { + $filename = (string) $filename; + $new = \str_replace($findDocs, $replaceDocs, $old = \file_get_contents($filename)); + do { + \file_put_contents($filename, $new); + $new = \str_replace($findDocs, $replaceDocs, $old = \file_get_contents($filename)); + } while ($old !== $new); +} +$filename = 'README.md'; + + $new = \str_replace($findDocs, $replaceDocs, $old = \file_get_contents($filename)); + do { + \file_put_contents($filename, $new); + $new = \str_replace($findDocs, $replaceDocs, $old = \file_get_contents($filename)); + } while ($old !== $new);