Bring back support for PHP 5

This commit is contained in:
Daniil Gentili 2019-09-21 17:11:37 +02:00
parent 2356d0b14a
commit 32693698b6
2 changed files with 34 additions and 11 deletions

View File

@ -193,11 +193,23 @@ final class Coroutine implements Promise, \ArrayAccess
{
throw new Exception('Not supported!');
}
/**
* Get data at an array offset asynchronously.
*
* @param mixed $offset Offset
*
* @return Promise
*/
public function offsetGet($offset)
{
return Tools::call((function () use ($offset) {
return (yield $this)[$offset];
})());
$deferred = new Deferred;
$this->onResolve(static function ($e, $v) use ($deferred, $offset) {
if ($e) {
return $deferred->fail($e);
}
$deferred->resolve($v[$offset]);
});
return $deferred->promise();
}
public function offsetSet($offset, $value)
{
@ -217,13 +229,24 @@ final class Coroutine implements Promise, \ArrayAccess
})());
}
public function __get($offset)
/**
* Get an attribute asynchronously.
*
* @param string $offset Offset
*
* @return Promise
*/
public function __get(string $offset)
{
return Tools::call((function () use ($offset) {
return (yield $this)->{$offset};
})());
$deferred = new Deferred;
$this->onResolve(static function ($e, $v) use ($deferred, $offset) {
if ($e) {
return $deferred->fail($e);
}
$deferred->resolve($v->{$offset});
});
return $deferred->promise();
}
public function __call(string $name, array $arguments)
{
$deferred = new Deferred;

View File

@ -89,9 +89,6 @@ 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
@ -99,6 +96,9 @@ branch="-$TRAVIS_BRANCH"
cd $madelinePath
php makephar.php $HOME/phar5 "madeline$php$branch.phar" $TRAVIS_COMMIT
curl -s https://api.telegram.org/bot$BOT_TOKEN/sendDocument -F chat_id=101374607 -F document="@$TRAVIS_PHAR"
export TRAVIS_PHAR="madeline$php$branch.phar"
export TEST_SECRET_CHAT=test
export TEST_USERNAME=danogentili