From 37535744b269f5f3e5044a23122bacdbfbd84d82 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 21 Nov 2015 22:55:20 -0500 Subject: [PATCH 1/3] small tweaks --- phpseclib/File/ASN1.php | 2 +- phpseclib/Math/BigInteger.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 8677521b..f5c3e448 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -677,7 +677,7 @@ class File_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 FILE_ASN1_TYPE_SET: diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 4ab30d83..4ba64240 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -811,6 +811,18 @@ class Math_BigInteger } } + /** + * __debugInfo() magic method + * + * Will be called, automatically, when print_r() or var_dump() are called + * + * @access public + */ + function __debugInfo() + { + return array('value' => '0x' . $this->toHex(true)); + } + /** * Adds two BigIntegers. * From c655b16f7529a9d3ceee5224cdaaed72443f7996 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 1 Dec 2015 19:30:49 -0600 Subject: [PATCH 2/3] BigInteger: add engine to __debugInfo output and add unit test --- phpseclib/Math/BigInteger.php | 23 ++++++++++++++++++++++- tests/Unit/Math/BigInteger/TestCase.php | 11 +++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 4ba64240..98ec4a93 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -820,7 +820,28 @@ class Math_BigInteger */ function __debugInfo() { - return array('value' => '0x' . $this->toHex(true)); + $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 + ); } /** diff --git a/tests/Unit/Math/BigInteger/TestCase.php b/tests/Unit/Math/BigInteger/TestCase.php index 10eacc66..827b2b90 100644 --- a/tests/Unit/Math/BigInteger/TestCase.php +++ b/tests/Unit/Math/BigInteger/TestCase.php @@ -358,4 +358,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; + } } From b9ce54aae9d7b4cefd03464a46071303f53ce66d Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 13 Dec 2015 16:02:17 -0600 Subject: [PATCH 3/3] Travis: re-add hhvm and use zenovich github repo only --- .travis.yml | 1 + travis/install-php-extensions.sh | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 125406fb..d1fa0e07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ php: - 5.5.9 - 5.5 - 5.6 + - hhvm env: global: 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'