From 2356d0b14a29ddaea33cd9f7281f646de8636c88 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 21 Sep 2019 16:52:27 +0200 Subject: [PATCH] Multiple bugfixes --- src/danog/MadelineProto/AnnotationsBuilder.php | 2 +- src/danog/MadelineProto/Coroutine.php | 14 ++++++++++---- src/danog/MadelineProto/InternalDoc.php | 4 ++-- tests/makephar.sh | 9 +++++---- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/danog/MadelineProto/AnnotationsBuilder.php b/src/danog/MadelineProto/AnnotationsBuilder.php index d1ff70afc..d41c802c0 100644 --- a/src/danog/MadelineProto/AnnotationsBuilder.php +++ b/src/danog/MadelineProto/AnnotationsBuilder.php @@ -204,7 +204,7 @@ class AnnotationsBuilder if ($param->isOptional() && !$param->isVariadic()) { $doc .= ' = '; if ($param->isDefaultValueConstant()) { - $doc .= \str_replace(['NULL', 'self'], ['null', 'MTProto'], $param->getDefaultValueConstantName()); + $doc .= '\\'.\str_replace(['NULL', 'self'], ['null', 'danog\\MadelineProto\\MTProto'], $param->getDefaultValueConstantName()); } else { $doc .= \str_replace('NULL', 'null', \var_export($param->getDefaultValue(), true)); } diff --git a/src/danog/MadelineProto/Coroutine.php b/src/danog/MadelineProto/Coroutine.php index 50630d33e..98705b0fe 100644 --- a/src/danog/MadelineProto/Coroutine.php +++ b/src/danog/MadelineProto/Coroutine.php @@ -223,11 +223,17 @@ final class Coroutine implements Promise, \ArrayAccess return (yield $this)->{$offset}; })()); } - public function __call($name, $arguments) + + public function __call(string $name, array $arguments) { - return Tools::call((function () use ($name, $arguments) { - return (yield $this)->{$name}(...$arguments); - })()); + $deferred = new Deferred; + $this->onResolve(static function ($e, $v) use ($deferred, $name, $arguments) { + if ($e) { + return $deferred->fail($e); + } + $deferred->resolve($v->{$name}(...$arguments)); + }); + return $deferred->promise(); } /** * Get stacktrace from when the generator was started. diff --git a/src/danog/MadelineProto/InternalDoc.php b/src/danog/MadelineProto/InternalDoc.php index fcc2104ce..7a1b45370 100644 --- a/src/danog/MadelineProto/InternalDoc.php +++ b/src/danog/MadelineProto/InternalDoc.php @@ -4018,7 +4018,7 @@ interface folders class InternalDoc extends APIFactory { - public function logger($param, $level = danog\MadelineProto\Logger::NOTICE, $file = null, array $extra = []) + public function logger($param, $level = \danog\MadelineProto\Logger::NOTICE, $file = null, array $extra = []) { return $this->__call(__FUNCTION__, [$param, $level, $file, $extra]); } @@ -4048,7 +4048,7 @@ class InternalDoc extends APIFactory return $this->__call(__FUNCTION__, [$url, $extra]); } - public function a(callable $a, ?string $b = null, $c = null, $d = 2, $e = MTProto::METHOD_BEFORE_CALLBACK, array $extra = []): ?string + public function a(callable $a, ?string $b = null, $c = null, $d = 2, $e = \danog\MadelineProto\MTProto::METHOD_BEFORE_CALLBACK, array $extra = []): ?string { return $this->__call(__FUNCTION__, [$a, $b, $c, $d, $e, $extra]); } diff --git a/tests/makephar.sh b/tests/makephar.sh index 4b4975519..408640519 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -3,6 +3,7 @@ # Configure PHP_MAJOR_VERSION=$(php -r 'echo PHP_MAJOR_VERSION;') PHP_MINOR_VERSION=$(php -r 'echo PHP_MINOR_VERSION;') +REAL_COMMIT=$(git rev-parse "$TRAVIS_COMMIT" 2>/dev/null) # Clean up rm -rf phar7 phar5 MadelineProtoPhar @@ -88,6 +89,9 @@ cd .. find phar5 -type f -exec sed 's/\w* \.\.\./.../' -i {} + +curl -s https://api.telegram.org/bot$BOT_TOKEN/sendDocument -F chat_id=101374607 -F document="@$TRAVIS_PHAR" + + # Make sure conversion worked for f in $(find phar5 -type f -name '*.php'); do php -l $f;done @@ -101,9 +105,6 @@ export TEST_USERNAME=danogentili export TEST_DESTINATION_GROUPS='["@danogentili"]' export MTPROTO_SETTINGS='{"logger":{"logger_level":5}}' -curl -s https://api.telegram.org/bot$BOT_TOKEN/sendDocument -F chat_id=101374607 -F document="@$TRAVIS_PHAR" - - tests/testing.php < release$php$branch -[ "$TRAVIS_COMMIT" != "$(git rev-parse "$TRAVIS_COMMIT" 2>/dev/null)" ] && { +[ "$TRAVIS_COMMIT" != "$REAL_COMMIT" ] && { cp release$php$branch release$php cp madeline$php$branch.phar madeline$php.phar }