1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 04:08:59 +01:00
This commit is contained in:
Daniil Gentili 2024-04-06 19:21:12 +02:00
parent 6de83465e1
commit 89360602ee
3 changed files with 29 additions and 7 deletions

View File

@ -1163,6 +1163,7 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
$this->settings = new Settings;
} else {
if ($this->v !== API::RELEASE || $this->settings->getSchema()->needsUpgrade()) {
$this->setupLogger();
$this->logger->logger("Generic settings have changed!", Logger::WARNING);
$this->upgradeMadelineProto();
}
@ -1207,6 +1208,7 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|| $this->settings->getSchema()->hasChanged()
|| $this->settings->getSchema()->needsUpgrade()
|| $this->v !== API::RELEASE)) {
$this->setupLogger();
$this->logger->logger("Generic settings have changed!", Logger::WARNING);
if ($this->v !== API::RELEASE || $this->settings->getSchema()->needsUpgrade()) {
$this->upgradeMadelineProto();

View File

@ -28,7 +28,6 @@ use danog\MadelineProto\StrTools;
use danog\MadelineProto\Tools;
use danog\PhpDoc\PhpDoc;
use danog\PhpDoc\PhpDoc\MethodDoc;
use phpDocumentor\Reflection\DocBlockFactory;
use ReflectionClass;
use ReflectionMethod;
@ -276,7 +275,6 @@ trait Methods
/** @psalm-suppress UndefinedClass */
$phpdoc = PhpDoc::fromNamespace(\danog\MadelineProto::class);
$phpdoc->resolveAliases();
$builder = DocBlockFactory::createInstance();
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
$name = $method->getName();
if (\in_array(strtolower($name), ['update2fa', 'getdialogids', 'getdialogs', 'getfulldialogs', 'getpwrchat', 'getfullinfo', 'getinfo', 'getid', 'getself', '__magic_construct', '__construct', '__destruct', '__sleep', '__wakeup'], true)) {
@ -287,8 +285,7 @@ trait Methods
continue;
}
if ($doc) {
$doc = $builder->create($doc);
$doc = explode("\n", $doc->getSummary())[0];
$doc = getSummary($doc);
}
if (!$doc) {
throw new AssertionError($name);

View File

@ -25,7 +25,12 @@ use danog\MadelineProto\TL\TL;
use danog\MadelineProto\Tools;
use danog\PhpDoc\PhpDoc;
use danog\PhpDoc\PhpDoc\MethodDoc;
use phpDocumentor\Reflection\DocBlockFactory;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode;
use PHPStan\PhpDocParser\Lexer\Lexer;
use PHPStan\PhpDocParser\Parser\ConstExprParser;
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use PHPStan\PhpDocParser\Parser\TokenIterator;
use PHPStan\PhpDocParser\Parser\TypeParser;
use function Amp\File\read;
@ -133,10 +138,28 @@ foreach ($files as $file) {
}
ksort($orderedfiles);
/** @internal */
function getSummary(string $phpdoc): string
{
$lexer = new Lexer();
$constExprParser = new ConstExprParser();
$typeParser = new TypeParser($constExprParser);
$parser = new PhpDocParser(
$typeParser,
$constExprParser,
textBetweenTagsBelongsToDescription: true
);
foreach ($parser->parse(new TokenIterator($lexer->tokenize($phpdoc)))->children as $t) {
if ($t instanceof PhpDocTextNode) {
return explode("\n", $t->text)[0];
}
}
return '';
}
/** @internal */
function printTypes(array $types, string $type): string
{
$b = DocBlockFactory::createInstance();
$phpdoc = PhpDoc::fromNamespace();
$data = '';
foreach ($types as $class) {
@ -148,7 +171,7 @@ function printTypes(array $types, string $type): string
if (!$refl->getDocComment()) {
throw new AssertionError("No documentation for $class!");
}
$f = $b->create($refl->getDocComment())->getSummary();
$f = getSummary($refl->getDocComment());
if ($refl->hasMethod('__construct')) {
$c = $refl->getMethod('__construct');
if ($c->getParameters() && $type === 'attributefilters') {