Skip to content

Commit

Permalink
Fix PHPDoc errors (#2)
Browse files Browse the repository at this point in the history
Some of the new PHPDocs are inaccurate; fix them.

Also force the scale to be an integer.
  • Loading branch information
danhunsaker authored May 29, 2017
1 parent 41235e8 commit cd8c759
Showing 1 changed file with 79 additions and 79 deletions.
158 changes: 79 additions & 79 deletions src/BC.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
class BC
{
/**
* @var int
* @var integer
*/
protected static $internalScale = 100;

/**
* @var int
* @var integer
*/
protected static $iterations = 50;

/**
* @var null
* @var integer
*/
protected static $scale = null;

/**
* @var null
* @var integer
*/
protected $instanceScale = null;

Expand All @@ -34,10 +34,10 @@ class BC
/**
* Add two arbitrary precision numbers
*
* @param $a
* @param $b
* @param null $scale
* @return string
* @param string|integer|float $a
* @param string|integer|float $b
* @param integer|null $scale
* @return string|integer|float
*/
public static function add($a, $b, $scale = null)
{
Expand All @@ -49,10 +49,10 @@ public static function add($a, $b, $scale = null)
/**
* Compare two arbitrary precision numbers
*
* @param $a
* @param $b
* @param null $scale
* @return int
* @param string|integer|float $a
* @param string|integer|float $b
* @param integer|null $scale
* @return string|integer|float
*/
public static function comp($a, $b, $scale = null)
{
Expand All @@ -64,10 +64,10 @@ public static function comp($a, $b, $scale = null)
/**
* Divide ($a / $b) two arbitrary precision numbers
*
* @param $a
* @param $b
* @param null $scale
* @return string
* @param string|integer|float $a
* @param string|integer|float $b
* @param integer|null $scale
* @return string|integer|float
*/
public static function div($a, $b, $scale = null)
{
Expand All @@ -79,9 +79,9 @@ public static function div($a, $b, $scale = null)
/**
* Get modulus of an arbitrary precision number
*
* @param $a
* @param $b
* @return string
* @param string|integer|float $a
* @param string|integer|float $b
* @return string|integer|float
*/
public static function mod($a, $b)
{
Expand All @@ -91,10 +91,10 @@ public static function mod($a, $b)
/**
* Multiply ($a * $b) two arbitrary precision numbers
*
* @param $a
* @param $b
* @param null $scale
* @return string
* @param string|integer|float $a
* @param string|integer|float $b
* @param integer|null $scale
* @return string|integer|float
*/
public static function mul($a, $b, $scale = null)
{
Expand All @@ -106,10 +106,10 @@ public static function mul($a, $b, $scale = null)
/**
* Raise an arbitrary precision number to another
*
* @param $base
* @param $power
* @param null $scale
* @return string
* @param string|integer|float $base
* @param string|integer|float $power
* @param integer|null $scale
* @return string|integer|float
*/
public static function pow($base, $power, $scale = null)
{
Expand All @@ -121,11 +121,11 @@ public static function pow($base, $power, $scale = null)
/**
* Raise an arbitrary precision number to another, reduced by a specified modulus
*
* @param $base
* @param $power
* @param $modulo
* @param null $scale
* @return string
* @param string|integer|float $base
* @param string|integer|float $power
* @param string|integer|float $modulo
* @param integer|null $scale
* @return string|integer|float
*/
public static function powmod($base, $power, $modulo, $scale = null)
{
Expand All @@ -137,7 +137,7 @@ public static function powmod($base, $power, $modulo, $scale = null)
/**
* Set default scale parameter for all bc math functions
*
* @param $scale
* @param integer|null $scale
* @return bool
*/
public static function scale($scale)
Expand All @@ -152,9 +152,9 @@ public static function scale($scale)
/**
* Get the square root of an arbitrary precision number
*
* @param $val
* @param null $scale
* @return string
* @param string|integer|float $val
* @param integer|null $scale
* @return string|integer|float
*/
public static function sqrt($val, $scale = null)
{
Expand All @@ -166,10 +166,10 @@ public static function sqrt($val, $scale = null)
/**
* Subtract one arbitrary precision number from another
*
* @param $a
* @param $b
* @param null $scale
* @return string
* @param string|integer|float $a
* @param string|integer|float $b
* @param integer|null $scale
* @return string|integer|float
*/
public static function sub($a, $b, $scale = null)
{
Expand All @@ -183,9 +183,9 @@ public static function sub($a, $b, $scale = null)
/**
* Raises e to the argument's power.
*
* @param $val
* @param null $scale
* @return string
* @param string|integer|float $val
* @param integer|null $scale
* @return string|integer|float
*/
public static function epow($val, $scale = null)
{
Expand All @@ -203,9 +203,9 @@ public static function epow($val, $scale = null)
/**
* Calculates the factorial of the argument.
*
* @param $val
* @param null $scale
* @return string
* @param string|integer|float $val
* @param integer|null $scale
* @return string|integer|float
*/
public static function fact($val, $scale = null)
{
Expand All @@ -217,9 +217,9 @@ public static function fact($val, $scale = null)
/**
* Truncates the fractional portion of the argument, if any.
*
* @param $val
* @param null $scale
* @return string
* @param string|integer|float $val
* @param integer|null $scale
* @return string|integer|float
*/
public static function intval($val, $scale = null)
{
Expand All @@ -231,9 +231,9 @@ public static function intval($val, $scale = null)
/**
* Gives the natural logarithm of the argument.
*
* @param $val
* @param null $scale
* @return string
* @param string|integer|float $val
* @param integer|null $scale
* @return string|integer|float
*/
public static function ln($val, $scale = null)
{
Expand All @@ -254,9 +254,9 @@ public static function ln($val, $scale = null)
/**
* Gives the base 10 logarithm of the argument (uses ln $val/ln 10).
*
* @param $val
* @param null $scale
* @return string
* @param string|integer|float $val
* @param integer|null $scale
* @return string|integer|float
*/
public static function log($val, $scale = null)
{
Expand All @@ -269,8 +269,8 @@ public static function log($val, $scale = null)
* Returns the largest value in an array (the first argument).
*
* @param array $args
* @param null $scale
* @return string
* @param integer|null $scale
* @return string|integer|float
*/
public static function max(array $args, $scale = null)
{
Expand All @@ -290,8 +290,8 @@ public static function max(array $args, $scale = null)
* Returns the smallest value in an array (the first argument).
*
* @param array $args
* @param null $scale
* @return string
* @param integer|null $scale
* @return string|integer|float
*/
public static function min(array $args, $scale = null)
{
Expand All @@ -311,10 +311,10 @@ public static function min(array $args, $scale = null)
* Behaves exactly like BC::mod(), except it will return the fractional part of any remainder
* as well as the integer part.
*
* @param $a
* @param $b
* @param null $scale
* @return string
* @param string|integer|float $a
* @param string|integer|float $b
* @param integer|null $scale
* @return string|integer|float
*/
public static function modfrac($a, $b, $scale = null)
{
Expand All @@ -326,10 +326,10 @@ public static function modfrac($a, $b, $scale = null)
/**
* Supports fractional exponents, allowing roots other than the square to be calculated.
*
* @param $base
* @param $pow
* @param null $scale
* @return string
* @param string|integer|float $base
* @param string|integer|float $pow
* @param integer|null $scale
* @return string|integer|float
*/
public static function powfrac($base, $pow, $scale = null)
{
Expand All @@ -341,10 +341,10 @@ public static function powfrac($base, $pow, $scale = null)
/**
* Complement to BC::powfrac(), and is in fact just a convenience wrapper for it.
*
* @param $base
* @param $root
* @param null $scale
* @return string
* @param string|integer|float $base
* @param string|integer|float $root
* @param integer|null $scale
* @return string|integer|float
*/
public static function root($base, $root, $scale = null)
{
Expand All @@ -356,9 +356,9 @@ public static function root($base, $root, $scale = null)
/**
* Rounds a value to a given scale.
*
* @param $val
* @param null $scale
* @return string
* @param string|integer|float $val
* @param integer|null $scale
* @return string|integer|float
*/
public static function round($val, $scale = null)
{
Expand Down Expand Up @@ -390,7 +390,7 @@ public static function round($val, $scale = null)
*
* @param string $formula The expression to evaluate
* @param array|object $values An associative array of values to substitute into the expression
* @param integer $scale The scale to pass to BC::math methods
* @param integer|null $scale The scale to pass to BC::math methods
* @return string|integer|float|boolean
*/
public static function parse($formula, $values = [], $scale = null)
Expand Down Expand Up @@ -463,19 +463,19 @@ public static function parse($formula, $values = [], $scale = null)
/**
* Retrieve a scale value, using the one passed, or falling back to the internal one
*
* @param $scale
* @return null
* @param integer|null $scale
* @return integer
*/
protected static function getScale($scale)
{
if (is_null(static::$scale)) {
static::$scale = ini_get('bcmath.scale');
static::$scale = intval(ini_get('bcmath.scale'));
}

if (is_null($scale)) {
$scale = static::$scale;
}

return $scale;
return intval($scale);
}
}

0 comments on commit cd8c759

Please sign in to comment.