1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-12-11 19:59:42 +01:00
MadelineProto/tools/static.php

56 lines
1.7 KiB
PHP
Raw Normal View History

2022-12-29 20:40:06 +01:00
<?php declare(strict_types=1);
2019-10-31 22:41:22 +01:00
use danog\MadelineProto\Tools;
2022-12-08 20:16:40 +01:00
chdir(__DIR__.'/../');
2019-10-31 22:41:22 +01:00
require 'vendor/autoload.php';
$class = new \ReflectionClass(Tools::class);
$methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC);
2023-08-13 15:47:21 +02:00
/** @internal */
2019-10-31 22:41:22 +01:00
function ssort($a, $b)
{
2022-12-08 20:16:40 +01:00
return strlen($b->getName())-strlen($a->getName());
2019-10-31 22:41:22 +01:00
}
2022-12-08 20:16:40 +01:00
usort($methods, 'ssort');
2019-10-31 22:41:22 +01:00
$find = [];
$replace = [];
$findDocs = [];
$replaceDocs = [];
foreach ($methods as $methodObj) {
$method = $methodObj->getName();
$find[] = "\$this->$method(";
$replace[] = "\\danog\\MadelineProto\\Tools::$method(";
}
2022-12-08 20:16:40 +01:00
foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath('.'))), '/\.php$/') as $filename) {
2019-10-31 22:41:22 +01:00
$filename = (string) $filename;
2022-12-08 20:16:40 +01:00
$new = str_replace($find, $replace, $old = file_get_contents($filename));
2019-10-31 22:41:22 +01:00
do {
2022-12-08 20:16:40 +01:00
file_put_contents($filename, $new);
$new = str_replace($find, $replace, $old = file_get_contents($filename));
2019-10-31 22:41:22 +01:00
} while ($old !== $new);
}
exit;
2022-12-08 20:16:40 +01:00
foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath('docs'))), '/\.md$/') as $filename) {
2019-10-31 22:41:22 +01:00
$filename = (string) $filename;
2022-12-08 20:16:40 +01:00
$new = str_replace($findDocs, $replaceDocs, $old = file_get_contents($filename));
2019-10-31 22:41:22 +01:00
do {
2022-12-08 20:16:40 +01:00
file_put_contents($filename, $new);
$new = str_replace($findDocs, $replaceDocs, $old = file_get_contents($filename));
2019-10-31 22:41:22 +01:00
} while ($old !== $new);
}
$filename = 'README.md';
2022-12-08 20:16:40 +01:00
$new = str_replace($findDocs, $replaceDocs, $old = file_get_contents($filename));
2020-06-16 17:52:55 +02:00
do {
2022-12-08 20:16:40 +01:00
file_put_contents($filename, $new);
$new = str_replace($findDocs, $replaceDocs, $old = file_get_contents($filename));
2020-06-16 17:52:55 +02:00
} while ($old !== $new);