From 11a939c403f51649bce39e5994801fe9a0c7524c Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 21 Sep 2019 15:38:54 +0200 Subject: [PATCH] Asynchronously call methods of yielded objects, no extra syntax required (+ automatically release tagged commits) --- src/danog/MadelineProto/Coroutine.php | 12 ++++++++++++ tests/makephar.sh | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/danog/MadelineProto/Coroutine.php b/src/danog/MadelineProto/Coroutine.php index 4e3d3eb5..50630d33 100644 --- a/src/danog/MadelineProto/Coroutine.php +++ b/src/danog/MadelineProto/Coroutine.php @@ -217,6 +217,18 @@ final class Coroutine implements Promise, \ArrayAccess })()); } + public function __get($offset) + { + return Tools::call((function () use ($offset) { + return (yield $this)->{$offset}; + })()); + } + public function __call($name, $arguments) + { + return Tools::call((function () use ($name, $arguments) { + return (yield $this)->{$name}(...$arguments); + })()); + } /** * Get stacktrace from when the generator was started. * diff --git a/tests/makephar.sh b/tests/makephar.sh index 3e5aafa8..4b497551 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -91,7 +91,6 @@ find phar5 -type f -exec sed 's/\w* \.\.\./.../' -i {} + # Make sure conversion worked for f in $(find phar5 -type f -name '*.php'); do php -l $f;done -#[ "$TRAVIS_BRANCH" != "master" ] && branch="-$TRAVIS_BRANCH" || branch="" branch="-$TRAVIS_BRANCH" cd $madelinePath php makephar.php $HOME/phar5 "madeline$php$branch.phar" $TRAVIS_COMMIT @@ -135,7 +134,7 @@ cp "../madeline$php$branch.phar" . cp ../phar.php ../mtproxyd . echo -n $TRAVIS_COMMIT > release$php$branch -echo "$TRAVIS_COMMIT_MESSAGE" | grep -i "subrelease" && { +[ "$TRAVIS_COMMIT" != "$(git rev-parse "$TRAVIS_COMMIT" 2>/dev/null)" ] && { cp release$php$branch release$php cp madeline$php$branch.phar madeline$php.phar }