Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2 into feat…
Browse files Browse the repository at this point in the history
…ure/console
  • Loading branch information
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/BigInteger/Adapter/Bcmath.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public function init($operand, $base = null)
$base = 10;
$operand = $m[1];
// octal
} else if (preg_match('#^(0[0-7]+)$#', $operand, $m)) {
} elseif (preg_match('#^(0[0-7]+)$#', $operand, $m)) {
$base = 8;
$operand = $m[1];
// hex
} else if (preg_match('#^(?:0x)?([0-9a-f]+)$#', strtolower($operand), $m)) {
} elseif (preg_match('#^(?:0x)?([0-9a-f]+)$#', strtolower($operand), $m)) {
$base = 16;
$operand = $m[1];
// scientific notation
} else if (preg_match('#^([1-9]?\.?[0-9]+)[eE]\+?([0-9]+)$#', $operand, $m)) {
} elseif (preg_match('#^([1-9]?\.?[0-9]+)[eE]\+?([0-9]+)$#', $operand, $m)) {
$base = 10;
$operand = bcmul($m[1], bcpow('10', $m[2]));
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/BigInteger/AdapterPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Plugin manager implementation for BigInteger adapters.
*
* Enforces that adapters retrieved are instances of
* Adapter\AdapterInterface. Additionally, it registers a number of default
* Adapter\AdapterInterface. Additionally, it registers a number of default
* adapters available.
*
* @category Zend
Expand All @@ -27,7 +27,7 @@ class AdapterPluginManager extends AbstractPluginManager
{
/**
* Default set of adapters
*
*
* @var array
*/
protected $invokableClasses = array(
Expand All @@ -39,8 +39,8 @@ class AdapterPluginManager extends AbstractPluginManager
* Validate the plugin
*
* Checks that the adapter loaded is an instance of Adapter\AdapterInterface.
*
* @param mixed $plugin
*
* @param mixed $plugin
* @return void
* @throws Exception\RuntimeException if invalid
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function randBytes($length, $strong = false)
if ($rand !== false && strlen($rand) === $length) {
return $rand;
}
}
}
}
if ($strong) {
throw new Exception\RuntimeException(
Expand Down Expand Up @@ -81,8 +81,8 @@ public static function rand($min, $max, $strong = false)
);
}
$log = log($range, 2);
$bytes = (int) ($log / 8) + 1;
$bits = (int) $log + 1;
$bytes = (int) ($log / 8) + 1;
$bits = (int) $log + 1;
$filter = (int) (1 << $bits) - 1;
do {
$rnd = hexdec(bin2hex(self::randBytes($bytes, $strong)));
Expand Down
2 changes: 1 addition & 1 deletion test/BigInteger/Adapter/BcmathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class BcmathTest extends \PHPUnit_Framework_TestCase
protected $adapter = null;

protected $opts = array();

public function setUp()
{
if (!extension_loaded('bcmath')) {
Expand Down
18 changes: 9 additions & 9 deletions test/MathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public static function provideRandInt()
array(2, 1, 10000, 100, 0.9, 1.1, false),
array(2, 1, 10000, 100, 0.8, 1.2, true)
);
}
}

public function testRandBytes()
{
for ($length=1; $length<4096; $length++) {
Expand All @@ -36,16 +36,16 @@ public function testRandBytes()
$this->assertEquals($length, strlen($rand));
}
}

/**
* A Monte Carlo test that generates $cycles numbers from 0 to $tot
* and test if the numbers are above or below the line y=x with a
* and test if the numbers are above or below the line y=x with a
* frequency range of [$min, $max]
*
*
* Note: this code is inspired by the random number generator test
* included in the PHP-CryptLib project of Anthony Ferrara
* @see https://github.com/ircmaxell/PHP-CryptLib
*
*
* @dataProvider provideRandInt
*/
public function testRandInt($num, $valid, $cycles, $tot, $min, $max, $strong)
Expand All @@ -67,7 +67,7 @@ public function testRandInt($num, $valid, $cycles, $tot, $min, $max, $strong)
$up++;
} elseif ($x < $y) {
$down++;
}
}
}
$this->assertGreaterThan(0, $up);
$this->assertGreaterThan(0, $down);
Expand All @@ -76,12 +76,12 @@ public function testRandInt($num, $valid, $cycles, $tot, $min, $max, $strong)
$count++;
}
$i++;
} while ($i < $num && $count < $valid);
} while ($i < $num && $count < $valid);
if ($count < $valid) {
$this->fail('The random number generator failed the Monte Carlo test');
}
}

public function testRandBigInteger()
{
try {
Expand Down

0 comments on commit 8e63b20

Please sign in to comment.