mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 06:39:01 +01:00
Fixes
This commit is contained in:
parent
6de83465e1
commit
89360602ee
@ -1163,6 +1163,7 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
|||||||
$this->settings = new Settings;
|
$this->settings = new Settings;
|
||||||
} else {
|
} else {
|
||||||
if ($this->v !== API::RELEASE || $this->settings->getSchema()->needsUpgrade()) {
|
if ($this->v !== API::RELEASE || $this->settings->getSchema()->needsUpgrade()) {
|
||||||
|
$this->setupLogger();
|
||||||
$this->logger->logger("Generic settings have changed!", Logger::WARNING);
|
$this->logger->logger("Generic settings have changed!", Logger::WARNING);
|
||||||
$this->upgradeMadelineProto();
|
$this->upgradeMadelineProto();
|
||||||
}
|
}
|
||||||
@ -1207,6 +1208,7 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
|||||||
|| $this->settings->getSchema()->hasChanged()
|
|| $this->settings->getSchema()->hasChanged()
|
||||||
|| $this->settings->getSchema()->needsUpgrade()
|
|| $this->settings->getSchema()->needsUpgrade()
|
||||||
|| $this->v !== API::RELEASE)) {
|
|| $this->v !== API::RELEASE)) {
|
||||||
|
$this->setupLogger();
|
||||||
$this->logger->logger("Generic settings have changed!", Logger::WARNING);
|
$this->logger->logger("Generic settings have changed!", Logger::WARNING);
|
||||||
if ($this->v !== API::RELEASE || $this->settings->getSchema()->needsUpgrade()) {
|
if ($this->v !== API::RELEASE || $this->settings->getSchema()->needsUpgrade()) {
|
||||||
$this->upgradeMadelineProto();
|
$this->upgradeMadelineProto();
|
||||||
|
@ -28,7 +28,6 @@ use danog\MadelineProto\StrTools;
|
|||||||
use danog\MadelineProto\Tools;
|
use danog\MadelineProto\Tools;
|
||||||
use danog\PhpDoc\PhpDoc;
|
use danog\PhpDoc\PhpDoc;
|
||||||
use danog\PhpDoc\PhpDoc\MethodDoc;
|
use danog\PhpDoc\PhpDoc\MethodDoc;
|
||||||
use phpDocumentor\Reflection\DocBlockFactory;
|
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionMethod;
|
use ReflectionMethod;
|
||||||
|
|
||||||
@ -276,7 +275,6 @@ trait Methods
|
|||||||
/** @psalm-suppress UndefinedClass */
|
/** @psalm-suppress UndefinedClass */
|
||||||
$phpdoc = PhpDoc::fromNamespace(\danog\MadelineProto::class);
|
$phpdoc = PhpDoc::fromNamespace(\danog\MadelineProto::class);
|
||||||
$phpdoc->resolveAliases();
|
$phpdoc->resolveAliases();
|
||||||
$builder = DocBlockFactory::createInstance();
|
|
||||||
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
|
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
|
||||||
$name = $method->getName();
|
$name = $method->getName();
|
||||||
if (\in_array(strtolower($name), ['update2fa', 'getdialogids', 'getdialogs', 'getfulldialogs', 'getpwrchat', 'getfullinfo', 'getinfo', 'getid', 'getself', '__magic_construct', '__construct', '__destruct', '__sleep', '__wakeup'], true)) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
if ($doc) {
|
if ($doc) {
|
||||||
$doc = $builder->create($doc);
|
$doc = getSummary($doc);
|
||||||
$doc = explode("\n", $doc->getSummary())[0];
|
|
||||||
}
|
}
|
||||||
if (!$doc) {
|
if (!$doc) {
|
||||||
throw new AssertionError($name);
|
throw new AssertionError($name);
|
||||||
|
@ -25,7 +25,12 @@ use danog\MadelineProto\TL\TL;
|
|||||||
use danog\MadelineProto\Tools;
|
use danog\MadelineProto\Tools;
|
||||||
use danog\PhpDoc\PhpDoc;
|
use danog\PhpDoc\PhpDoc;
|
||||||
use danog\PhpDoc\PhpDoc\MethodDoc;
|
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;
|
use function Amp\File\read;
|
||||||
|
|
||||||
@ -133,10 +138,28 @@ foreach ($files as $file) {
|
|||||||
}
|
}
|
||||||
ksort($orderedfiles);
|
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 */
|
/** @internal */
|
||||||
function printTypes(array $types, string $type): string
|
function printTypes(array $types, string $type): string
|
||||||
{
|
{
|
||||||
$b = DocBlockFactory::createInstance();
|
|
||||||
$phpdoc = PhpDoc::fromNamespace();
|
$phpdoc = PhpDoc::fromNamespace();
|
||||||
$data = '';
|
$data = '';
|
||||||
foreach ($types as $class) {
|
foreach ($types as $class) {
|
||||||
@ -148,7 +171,7 @@ function printTypes(array $types, string $type): string
|
|||||||
if (!$refl->getDocComment()) {
|
if (!$refl->getDocComment()) {
|
||||||
throw new AssertionError("No documentation for $class!");
|
throw new AssertionError("No documentation for $class!");
|
||||||
}
|
}
|
||||||
$f = $b->create($refl->getDocComment())->getSummary();
|
$f = getSummary($refl->getDocComment());
|
||||||
if ($refl->hasMethod('__construct')) {
|
if ($refl->hasMethod('__construct')) {
|
||||||
$c = $refl->getMethod('__construct');
|
$c = $refl->getMethod('__construct');
|
||||||
if ($c->getParameters() && $type === 'attributefilters') {
|
if ($c->getParameters() && $type === 'attributefilters') {
|
||||||
|
Loading…
Reference in New Issue
Block a user