1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 08:18:59 +01:00
MadelineProto/tools/static.php
2023-08-13 15:47:21 +02:00

56 lines
1.7 KiB
PHP

<?php declare(strict_types=1);
use danog\MadelineProto\Tools;
chdir(__DIR__.'/../');
require 'vendor/autoload.php';
$class = new \ReflectionClass(Tools::class);
$methods = $class->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC);
/** @internal */
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);