diff --git a/.travis.yml b/.travis.yml index 8983904d..9ae12b4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ php: - 5.5 - 5.6 - 7.0 + - hhvm env: global: diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 0e67b217..180b0e67 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -616,7 +616,7 @@ class ASN1 } // Fail mapping if all input items have not been consumed. - return $i < $n? null: $map; + return $i < $n ? null: $map; // the main diff between sets and sequences is the encapsulation of the foreach in another for loop case self::TYPE_SET: diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 8ea9f1b2..9744275d 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -803,6 +803,39 @@ class BigInteger } } + /** + * __debugInfo() magic method + * + * Will be called, automatically, when print_r() or var_dump() are called + * + * @access public + */ + function __debugInfo() + { + $opts = array(); + switch (MATH_BIGINTEGER_MODE) { + case MATH_BIGINTEGER_MODE_GMP: + $engine = 'gmp'; + break; + case MATH_BIGINTEGER_MODE_BCMATH: + $engine = 'bcmath'; + break; + case MATH_BIGINTEGER_MODE_INTERNAL: + $engine = 'internal'; + $opts[] = PHP_INT_SIZE == 8 ? '64-bit' : '32-bit'; + } + if (MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_GMP && defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) { + $opts[] = 'OpenSSL'; + } + if (!empty($opts)) { + $engine.= ' (' . implode($opts, ', ') . ')'; + } + return array( + 'value' => '0x' . $this->toHex(true), + 'engine' => $engine + ); + } + /** * Adds two BigIntegers. * diff --git a/tests/Unit/Math/BigInteger/TestCase.php b/tests/Unit/Math/BigInteger/TestCase.php index bb5293b3..1992fb8d 100644 --- a/tests/Unit/Math/BigInteger/TestCase.php +++ b/tests/Unit/Math/BigInteger/TestCase.php @@ -355,4 +355,15 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase 'Failed asserting that Alice and Bob share the same BigInteger.' ); } + + /** + * @requires PHP 5.6 + */ + public function testDebugInfo() + { + $num = new Math_BigInteger(50); + $str = print_r($num, true); + $this->assertContains('[value] => 0x32', $str); + return $str; + } } diff --git a/travis/install-php-extensions.sh b/travis/install-php-extensions.sh index 2acfdfd7..5244261c 100755 --- a/travis/install-php-extensions.sh +++ b/travis/install-php-extensions.sh @@ -21,10 +21,5 @@ function install_php_extension } # runkit -if [ "$TRAVIS_PHP_VERSION" == "5.6" ] -then - git clone https://github.com/adrianguenter/runkit.git -else - git clone https://github.com/zenovich/runkit.git -fi +git clone https://github.com/zenovich/runkit.git install_php_extension 'runkit'