diff --git a/src/BigIntegor.php b/src/BigIntegor.php index f539af6b..1ddf371c 100644 --- a/src/BigIntegor.php +++ b/src/BigIntegor.php @@ -2,9 +2,18 @@ namespace phpseclib\Math; -if (PHP_MAJOR_VERSION < 7 && !(class_exists('\Phar') && \Phar::running())) { +if (PHP_MAJOR_VERSION < 7 && !(class_exists('\\Phar') && \Phar::running())) { throw new \Exception('MadelineProto requires php 7 to run'); } +if (defined('HHVM_VERSION')) { + $engines = [['PHP64', ['OpenSSL']], ['BCMath', ['OpenSSL']], ['PHP32', ['OpenSSL']]]; + foreach ($engines as $engine) { + try { + \phpseclib\Math\BigInteger::setEngine($engine[0], isset($engine[1]) ? $engine[1] : []); + break; + } catch (\Exception $e) {} + } +} class BigIntegor { diff --git a/src/danog/MadelineProto/TL/Exception.php b/src/danog/MadelineProto/TL/Exception.php index dce65211..e42cca4d 100644 --- a/src/danog/MadelineProto/TL/Exception.php +++ b/src/danog/MadelineProto/TL/Exception.php @@ -19,7 +19,7 @@ class Exception extends \Exception public function __toString() { - return get_class($this).($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.@file_get_contents(__DIR__.'/../../../.git/refs/heads/master').PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL; + return get_class($this). ($this->message !== '' ? ': ' : '').$this->message.PHP_EOL.@file_get_contents(__DIR__.'/../../../.git/refs/heads/master').PHP_EOL.'TL Trace (YOU ABSOLUTELY MUST READ THE TEXT BELOW):'.PHP_EOL.PHP_EOL.$this->getTLTrace().PHP_EOL; } public function __construct($message, $file = '') diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index 8ef48046..13b72bfe 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -597,7 +597,7 @@ trait TL stream_get_contents($stream, $resto); } } else { - $x = stream_get_contents($stream, $l); + $x = $l ? stream_get_contents($stream, $l) : ''; $resto = $this->posmod(-($l + 1), 4); if ($resto > 0) { stream_get_contents($stream, $resto); diff --git a/tests/makephar.sh b/tests/makephar.sh index 1bf15bb2..4e6216cf 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -32,6 +32,7 @@ composer update cd .. $php7to5 convert --copy-all phar7 phar5 >/dev/null +find phar5 -type f -exec sed 's/\w* \.\.\./.../' -i {} + [ "$TRAVIS_BRANCH" != "master" ] && branch="-$TRAVIS_BRANCH" || branch="" diff --git a/tests/makephardebug.sh b/tests/makephardebug.sh index 3fb0d60a..6b566823 100755 --- a/tests/makephardebug.sh +++ b/tests/makephardebug.sh @@ -32,6 +32,7 @@ cp -a ../src vendor/danog/madelineproto cd .. $php7to5 convert --copy-all phar7 phar5 >/dev/null +find phar5 -type f -exec sed 's/\w* \.\.\./.../' -i {} + php makephar.php phar5 madeline.phar $(cat .git/refs/heads/master)