HHVM fixes

This commit is contained in:
Daniil Gentili 2018-06-22 13:28:33 +02:00
parent 96f943f78e
commit 092cc44d75
5 changed files with 14 additions and 3 deletions

View File

@ -2,9 +2,18 @@
namespace phpseclib\Math; 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'); 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 class BigIntegor
{ {

View File

@ -19,7 +19,7 @@ class Exception extends \Exception
public function __toString() 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 = '') public function __construct($message, $file = '')

View File

@ -597,7 +597,7 @@ trait TL
stream_get_contents($stream, $resto); stream_get_contents($stream, $resto);
} }
} else { } else {
$x = stream_get_contents($stream, $l); $x = $l ? stream_get_contents($stream, $l) : '';
$resto = $this->posmod(-($l + 1), 4); $resto = $this->posmod(-($l + 1), 4);
if ($resto > 0) { if ($resto > 0) {
stream_get_contents($stream, $resto); stream_get_contents($stream, $resto);

View File

@ -32,6 +32,7 @@ composer update
cd .. cd ..
$php7to5 convert --copy-all phar7 phar5 >/dev/null $php7to5 convert --copy-all phar7 phar5 >/dev/null
find phar5 -type f -exec sed 's/\w* \.\.\./.../' -i {} +
[ "$TRAVIS_BRANCH" != "master" ] && branch="-$TRAVIS_BRANCH" || branch="" [ "$TRAVIS_BRANCH" != "master" ] && branch="-$TRAVIS_BRANCH" || branch=""

View File

@ -32,6 +32,7 @@ cp -a ../src vendor/danog/madelineproto
cd .. cd ..
$php7to5 convert --copy-all phar7 phar5 >/dev/null $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) php makephar.php phar5 madeline.phar $(cat .git/refs/heads/master)