From 09e48a05b98b94fd52dc2562089f67e8d1279298 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 4 Feb 2020 09:37:24 +0100 Subject: update to 2.0.0 (alpha) raise dependency on PHP 7.2 fix undefined symbol using patch from https://github.com/php-decimal/ext-decimal/pull/34 disable ZTS build which segfaults, reported as https://github.com/php-decimal/ext-decimal/issues/35 --- 34.patch | 111 +++++++ Number.php | 132 ++++++++ PHPINFO | 2 +- REFLECTION | 827 +++++++++++++++++++++++++++++++++++++++++++------- php-pecl-decimal.spec | 22 +- 5 files changed, 979 insertions(+), 115 deletions(-) create mode 100644 34.patch create mode 100644 Number.php diff --git a/34.patch b/34.patch new file mode 100644 index 0000000..d883be8 --- /dev/null +++ b/34.patch @@ -0,0 +1,111 @@ +From e71f1488b666e30e4f0121a10fee3eeab22bd327 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Tue, 4 Feb 2020 08:23:05 +0100 +Subject: [PATCH 1/3] fix harcoded path in test + +--- + tests/Number/methods/pow.phpt | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/tests/Number/methods/pow.phpt b/tests/Number/methods/pow.phpt +index 5ce6582..2c78f16 100644 +--- a/tests/Number/methods/pow.phpt ++++ b/tests/Number/methods/pow.phpt +@@ -87,7 +87,7 @@ Number Object + ) + Number::pow + +-Warning: Decimal arithmetic operand truncated to integer in /Users/rtheunissen/dev/decimal/ext-decimal/tests/Number/helpers/Number.php on line 63 ++Warning: Decimal arithmetic operand truncated to integer in %sNumber.php on line 63 + Number Object + ( + [value:protected] => Decimal\Rational Object +@@ -99,7 +99,7 @@ Number Object + ) + Number::pow + +-Warning: Decimal arithmetic operand truncated to integer in /Users/rtheunissen/dev/decimal/ext-decimal/tests/Number/helpers/Number.php on line 63 ++Warning: Decimal arithmetic operand truncated to integer in %sNumber.php on line 63 + Number Object + ( + [value:protected] => Decimal\Rational Object +@@ -123,7 +123,7 @@ Decimal\Decimal Object + ) + Number::toRational + +-Warning: Decimal arithmetic operand truncated to integer in /Users/rtheunissen/dev/decimal/ext-decimal/tests/Number/methods/pow.php on line 38 ++Warning: Decimal arithmetic operand truncated to integer in %spow.php on line 38 + Decimal\Rational Object + ( + [num] => 16 +@@ -131,7 +131,7 @@ Decimal\Rational Object + ) + Number::toRational + +-Warning: Decimal arithmetic operand truncated to integer in /Users/rtheunissen/dev/decimal/ext-decimal/tests/Number/methods/pow.php on line 41 ++Warning: Decimal arithmetic operand truncated to integer in %spow.php on line 41 + Decimal\Rational Object + ( + [num] => 16 + +From d983b8f76f59996339a434c40d1f57703fadbd42 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Tue, 4 Feb 2020 08:25:35 +0100 +Subject: [PATCH 3/3] fix #33 remomve unused function + +--- + src/convert.c | 15 +-------------- + src/convert.h | 2 -- + 2 files changed, 1 insertion(+), 16 deletions(-) + +diff --git a/src/convert.c b/src/convert.c +index 4136a35..77581e3 100644 +--- a/src/convert.c ++++ b/src/convert.c +@@ -444,19 +444,6 @@ zend_string *php_decimal_rational_to_sci(const php_rational_t *obj, zend_long pr + return str; + } + +-zend_string *php_decimal_rational_to_eng(const php_rational_t *obj, zend_long prec) +-{ +- zend_string *str; +- +- PHP_DECIMAL_TEMP_MPD(tmp); +- php_decimal_rational_evaluate(&tmp, obj, prec); +- +- str = php_decimal_mpd_to_eng(&tmp); +- mpd_del(&tmp); +- +- return str; +-} +- + zend_string *php_decimal_rational_to_fixed(const php_rational_t *obj, zend_long places, zend_bool commas, php_decimal_rounding_t mode) + { + PHP_DECIMAL_TEMP_MPD(tmp); +@@ -597,4 +584,4 @@ void php_decimal_number_to_num_den(mpd_t *num, mpd_t *den, const zval *obj) + + assert(status == 0); + zval_ptr_dtor(&result); +-} +\ No newline at end of file ++} +diff --git a/src/convert.h b/src/convert.h +index cb5e031..a3924e3 100644 +--- a/src/convert.h ++++ b/src/convert.h +@@ -56,7 +56,6 @@ php_decimal_success_t php_decimal_mpd_set_string(mpd_t *mpd, const zend_string * + php_decimal_success_t php_decimal_mpd_set_charptr(mpd_t *mpd, const char *str); + + zend_string *php_decimal_mpd_to_serialized(const mpd_t *mpd); +-zend_string *php_decimal_mpd_to_eng(const mpd_t *mpd); + zend_string *php_decimal_mpd_to_sci(const mpd_t *mpd); + zend_string *php_decimal_mpd_to_string(const mpd_t *mpd); + zend_string *php_decimal_mpd_to_fixed(const mpd_t *mpd, zend_long places, zend_bool commas, php_decimal_rounding_t mode); +@@ -69,7 +68,6 @@ void php_decimal_rational_set_nan(php_rational_t *obj); + void php_decimal_rational_set_zero(php_rational_t *obj); + + zend_string *php_decimal_rational_to_sci(const php_rational_t *obj, zend_long prec); +-zend_string *php_decimal_rational_to_eng(const php_rational_t *obj, zend_long prec); + zend_string *php_decimal_rational_to_string(const php_rational_t *obj); + zend_string *php_decimal_rational_to_fixed(const php_rational_t *obj, zend_long places, zend_bool commas, php_decimal_rounding_t mode); + zend_long php_decimal_rational_to_long(const php_rational_t *obj); diff --git a/Number.php b/Number.php new file mode 100644 index 0000000..07ca222 --- /dev/null +++ b/Number.php @@ -0,0 +1,132 @@ +value : $number; + + if ($value === "INF") $value = INF; + else if ($value === "-INF") $value = -INF; + else if ($value === "NAN") $value = NAN; + + return $value; + } + + protected function __construct($value) + { + $this->value = self::parse($value); + } + + public static function valueOf($value): \Decimal\Number + { + return new static($value); + } + + public function add($other): \Decimal\Number + { + printf("%s\n", __METHOD__); + + return new static($this->value + $this->parse($other)); + } + + public function sub($other): \Decimal\Number + { + printf("%s\n", __METHOD__); + + return new static($this->value - $this->parse($other)); + } + + public function mul($other): \Decimal\Number + { + printf("%s\n", __METHOD__); + + return new static($this->value * $this->parse($other)); + } + + public function div($other): \Decimal\Number + { + printf("%s\n", __METHOD__); + + return new static($this->value / $this->parse($other)); + } + + public function pow($other): \Decimal\Number + { + printf("%s\n", __METHOD__); + + return new static($this->value ** $this->parse($other)); + } + + public function mod($other): \Decimal\Number + { + printf("%s\n", __METHOD__); + + return new static($this->value % $this->parse($other)); + } + + public function shiftl($places): \Decimal\Number + { + printf("%s\n", __METHOD__); + + return new static($this->value * (10 ** $places)); + } + + public function shiftr($places): \Decimal\Number + { + printf("%s\n", __METHOD__); + + return new static($this->value / (10 ** $places)); + } + + public function round(int $places = NULL, int $mode = NULL): \Decimal\Number + { + return new static($this->toDecimal(\Decimal\Decimal::MAX_PRECISION)->round($places, $mode)->toString()); + } + + public function toFixed(int $places = NULL, bool $commas = NULL, int $mode = NULL): string + { + return new static($this->toDecimal(\Decimal\Decimal::MAX_PRECISION)->toFixed($places, $commas, $mode)); + } + + public function toDecimal(int $precision): \Decimal\Decimal + { + printf("%s\n", __METHOD__); + + return parent::toDecimal($precision); + } + + public function toRational(): \Decimal\Rational + { + printf("%s\n", __METHOD__); + + return parent::toRational(); + } + + public function toString(): string + { + return (string) $this->value; + } + + public function toInt(): int + { + return (int) $this->value; + } + + public function toFloat(): float + { + return (float) $this->value; + } + + public function compareTo($other): int + { + printf("%s\n", __METHOD__); + + return $this->value <=> self::parse($other); + } +} diff --git a/PHPINFO b/PHPINFO index 1690582..fb3ebaa 100644 --- a/PHPINFO +++ b/PHPINFO @@ -2,5 +2,5 @@ decimal decimal support => enabled -decimal version => 1.3.1 +decimal version => 2.0.0 libmpdec version => 2.4.2 diff --git a/REFLECTION b/REFLECTION index bba6510..d8f893c 100644 --- a/REFLECTION +++ b/REFLECTION @@ -1,20 +1,20 @@ -Extension [ extension #109 decimal version 1.3.1 ] { +Extension [ extension #109 decimal version 2.0.0 ] { - - Classes [1] { - Class [ final class Decimal\Decimal implements JsonSerializable ] { + - Classes [3] { + Class [ abstract class Decimal\Number implements JsonSerializable ] { - Constants [13] { + Constant [ public int DEFAULT_ROUNDING ] { 3 } Constant [ public int ROUND_UP ] { 101 } Constant [ public int ROUND_DOWN ] { 102 } Constant [ public int ROUND_CEILING ] { 103 } Constant [ public int ROUND_FLOOR ] { 104 } - Constant [ public int ROUND_HALF_UP ] { 105 } - Constant [ public int ROUND_HALF_DOWN ] { 106 } - Constant [ public int ROUND_HALF_EVEN ] { 107 } - Constant [ public int ROUND_HALF_ODD ] { 108 } - Constant [ public int ROUND_TRUNCATE ] { 109 } - Constant [ public int DEFAULT_PRECISION ] { 28 } - Constant [ public int DEFAULT_ROUNDING ] { 107 } + Constant [ public int ROUND_HALF_UP ] { 1 } + Constant [ public int ROUND_HALF_DOWN ] { 2 } + Constant [ public int ROUND_HALF_EVEN ] { 3 } + Constant [ public int ROUND_HALF_ODD ] { 4 } + Constant [ public int ROUND_TRUNCATE ] { 105 } + Constant [ public int DEFAULT_PRECISION ] { 34 } Constant [ public int MIN_PRECISION ] { 1 } Constant [ public int MAX_PRECISION ] { 999999999999999999 } } @@ -22,305 +22,901 @@ Extension [ extension #109 decimal version 1.3.1 ] { - Static properties [0] { } - - Static methods [2] { - Method [ static public method sum ] { + - Static methods [1] { + Method [ static public method valueOf ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + } + + - Properties [0] { + } + + - Methods [33] { + Method [ abstract public method add ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ abstract public method sub ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ abstract public method mul ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ abstract public method div ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ abstract public method pow ] { + + - Parameters [1] { + Parameter #0 [ $exponent ] + } + - Return [ Decimal\Number ] + } + + Method [ abstract public method mod ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ abstract public method shiftl ] { + + - Parameters [1] { + Parameter #0 [ $places ] + } + - Return [ Decimal\Number ] + } + + Method [ abstract public method shiftr ] { + + - Parameters [1] { + Parameter #0 [ $places ] + } + - Return [ Decimal\Number ] + } + + Method [ abstract public method round ] { - Parameters [2] { - Parameter #0 [ $values ] + Parameter #0 [ int or NULL $places ] + Parameter #1 [ int or NULL $mode ] + } + - Return [ Decimal\Number ] + } + + Method [ public method floor ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method ceil ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method trunc ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method abs ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method negate ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method isNaN ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method isInf ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method isInteger ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method isZero ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method isEven ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method isOdd ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method isPositive ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method isNegative ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ abstract public method toString ] { + + - Parameters [0] { + } + - Return [ string ] + } + + Method [ abstract public method toFixed ] { + + - Parameters [3] { + Parameter #0 [ int or NULL $places ] + Parameter #1 [ bool or NULL $commas ] + Parameter #2 [ int or NULL $mode ] + } + - Return [ string ] + } + + Method [ abstract public method toInt ] { + + - Parameters [0] { + } + - Return [ int ] + } + + Method [ abstract public method toFloat ] { + + - Parameters [0] { + } + - Return [ float ] + } + + Method [ public method toDecimal ] { + + - Parameters [1] { + Parameter #0 [ int $precision ] + } + - Return [ Decimal\Decimal ] + } + + Method [ public method toRational ] { + + - Parameters [0] { + } + - Return [ Decimal\Rational ] + } + + Method [ abstract public method compareTo ] { + + - Parameters [1] { + Parameter #0 [ $other ] + } + - Return [ int ] + } + + Method [ public method between ] { + + - Parameters [3] { + Parameter #0 [ $a ] + Parameter #1 [ $b ] + Parameter #2 [ bool or NULL $inclusive ] + } + - Return [ bool ] + } + + Method [ public method equals ] { + + - Parameters [1] { + Parameter #0 [ $other ] + } + - Return [ bool ] + } + + Method [ public method __toString ] { + + - Parameters [0] { + } + - Return [ string ] + } + + Method [ public method jsonSerialize ] { + + - Parameters [0] { + } + - Return [ string ] + } + } + } + + Class [ final class Decimal\Decimal extends Decimal\Number implements JsonSerializable ] { + + - Constants [15] { + Constant [ public int DEFAULT_ROUNDING ] { 3 } + Constant [ public int ROUND_UP ] { 101 } + Constant [ public int ROUND_DOWN ] { 102 } + Constant [ public int ROUND_CEILING ] { 103 } + Constant [ public int ROUND_FLOOR ] { 104 } + Constant [ public int ROUND_HALF_UP ] { 1 } + Constant [ public int ROUND_HALF_DOWN ] { 2 } + Constant [ public int ROUND_HALF_EVEN ] { 3 } + Constant [ public int ROUND_HALF_ODD ] { 4 } + Constant [ public int ROUND_TRUNCATE ] { 105 } + Constant [ public int DEFAULT_PRECISION ] { 34 } + Constant [ public int MIN_PRECISION ] { 1 } + Constant [ public int MAX_PRECISION ] { 999999999999999999 } + Constant [ public object PI ] { 3.141592653589793 } + Constant [ public object E ] { 2.7182818284590452353602874713526625 } + } + + - Static properties [0] { + } + + - Static methods [1] { + Method [ static public method valueOf ] { + + - Parameters [2] { + Parameter #0 [ $value ] Parameter #1 [ int or NULL $precision ] } - - Return [ Decimal\Decimal ] + - Return [ Decimal\Number ] + } + } + + - Properties [0] { + } + + - Methods [43] { + Method [ private method __construct ] { + + - Parameters [0] { + } + } + + Method [ public method add ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method sub ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method mul ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method div ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method rem ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method mod ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method pow ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method shiftl ] { + + - Parameters [1] { + Parameter #0 [ $places ] + } + - Return [ Decimal\Number ] + } + + Method [ public method shiftr ] { + + - Parameters [1] { + Parameter #0 [ $places ] + } + - Return [ Decimal\Number ] + } + + Method [ public method ln ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method exp ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method log10 ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method sqrt ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method floor ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] } - Method [ static public method avg ] { + Method [ public method ceil ] { - - Parameters [2] { - Parameter #0 [ $values ] - Parameter #1 [ int or NULL $precision ] + - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ Decimal\Number ] } - } - - Properties [0] { - } + Method [ public method trunc ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } - - Methods [41] { - Method [ public method __construct ] { + Method [ public method round ] { - Parameters [2] { - Parameter #0 [ $value ] - Parameter #1 [ int $precision ] + Parameter #0 [ int or NULL $places ] + Parameter #1 [ int or NULL $mode ] } + - Return [ Decimal\Number ] } - Method [ public method copy ] { + Method [ public method trim ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ Decimal\Number ] } - Method [ public method add ] { + Method [ public method reduce ] { - - Parameters [1] { - Parameter #0 [ $value ] + - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ Decimal\Number ] } - Method [ public method sub ] { + Method [ public method precision ] { - - Parameters [1] { - Parameter #0 [ $value ] + - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ int ] } - Method [ public method mul ] { + Method [ public method abs ] { - - Parameters [1] { - Parameter #0 [ $value ] + - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ Decimal\Number ] } - Method [ public method div ] { + Method [ public method negate ] { - - Parameters [1] { - Parameter #0 [ $value ] + - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ Decimal\Number ] } - Method [ public method rem ] { + Method [ public method isEven ] { - - Parameters [1] { - Parameter #0 [ $value ] + - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ bool ] } - Method [ public method mod ] { + Method [ public method isOdd ] { - - Parameters [1] { - Parameter #0 [ $value ] + - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ bool ] } - Method [ public method pow ] { + Method [ public method isPositive ] { - - Parameters [1] { - Parameter #0 [ $value ] + - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ bool ] } - Method [ public method ln ] { + Method [ public method isNegative ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ bool ] } - Method [ public method exp ] { + Method [ public method isNaN ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ bool ] } - Method [ public method log10 ] { + Method [ public method isInf ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ bool ] } - Method [ public method sqrt ] { + Method [ public method isInteger ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ bool ] } - Method [ public method floor ] { + Method [ public method isZero ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ bool ] } - Method [ public method ceil ] { + Method [ public method toString ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ string ] + } + + Method [ public method toFixed ] { + + - Parameters [3] { + Parameter #0 [ int or NULL $places ] + Parameter #1 [ bool or NULL $commas ] + Parameter #2 [ int or NULL $mode ] + } + - Return [ string ] + } + + Method [ public method toSci ] { + + - Parameters [1] { + Parameter #0 [ int or NULL $precision ] + } + - Return [ string ] } - Method [ public method truncate ] { + Method [ public method toInt ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ int ] } - Method [ public method round ] { + Method [ public method toFloat ] { - - Parameters [2] { - Parameter #0 [ int or NULL $places ] - Parameter #1 [ int or NULL $rounding ] + - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ float ] } - Method [ public method shift ] { + Method [ public method toDecimal ] { - Parameters [1] { - Parameter #0 [ int $places ] + Parameter #0 [ int $precision ] } - Return [ Decimal\Decimal ] } - Method [ public method trim ] { + Method [ public method toRational ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ Decimal\Rational ] } - Method [ public method precision ] { + Method [ public method compareTo ] { - - Parameters [0] { + - Parameters [1] { + Parameter #0 [ $other ] } - Return [ int ] } - Method [ public method signum ] { + Method [ public method between ] { + + - Parameters [3] { + Parameter #0 [ $a ] + Parameter #1 [ $b ] + Parameter #2 [ bool or NULL $inclusive ] + } + - Return [ bool ] + } + + Method [ public method equals ] { + + - Parameters [1] { + Parameter #0 [ $other ] + } + - Return [ bool ] + } + + Method [ public method __toString ] { - Parameters [0] { } - - Return [ int ] + - Return [ string ] } - Method [ public method parity ] { + Method [ public method jsonSerialize ] { - Parameters [0] { } - - Return [ int ] + - Return [ string ] } + } + } - Method [ public method abs ] { + Class [ final class Decimal\Rational extends Decimal\Number implements JsonSerializable ] { + + - Constants [13] { + Constant [ public int DEFAULT_ROUNDING ] { 3 } + Constant [ public int ROUND_UP ] { 101 } + Constant [ public int ROUND_DOWN ] { 102 } + Constant [ public int ROUND_CEILING ] { 103 } + Constant [ public int ROUND_FLOOR ] { 104 } + Constant [ public int ROUND_HALF_UP ] { 1 } + Constant [ public int ROUND_HALF_DOWN ] { 2 } + Constant [ public int ROUND_HALF_EVEN ] { 3 } + Constant [ public int ROUND_HALF_ODD ] { 4 } + Constant [ public int ROUND_TRUNCATE ] { 105 } + Constant [ public int DEFAULT_PRECISION ] { 34 } + Constant [ public int MIN_PRECISION ] { 1 } + Constant [ public int MAX_PRECISION ] { 999999999999999999 } + } + + - Static properties [0] { + } + + - Static methods [1] { + Method [ static public method valueOf ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + } + + - Properties [0] { + } + + - Methods [36] { + Method [ private method __construct ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] } - Method [ public method negate ] { + Method [ public method add ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method sub ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method mul ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method div ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method pow ] { + + - Parameters [1] { + Parameter #0 [ $exponent ] + } + - Return [ Decimal\Number ] + } + + Method [ public method rem ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method mod ] { + + - Parameters [1] { + Parameter #0 [ $value ] + } + - Return [ Decimal\Number ] + } + + Method [ public method shiftl ] { + + - Parameters [1] { + Parameter #0 [ $places ] + } + - Return [ Decimal\Number ] + } + + Method [ public method shiftr ] { + + - Parameters [1] { + Parameter #0 [ $places ] + } + - Return [ Decimal\Number ] + } + + Method [ public method floor ] { - Parameters [0] { } - - Return [ Decimal\Decimal ] + - Return [ Decimal\Number ] } - Method [ public method isEven ] { + Method [ public method ceil ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method trunc ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method round ] { + + - Parameters [2] { + Parameter #0 [ int or NULL $places ] + Parameter #1 [ int or NULL $rounding ] + } + - Return [ Decimal\Number ] + } + + Method [ public method abs ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method negate ] { + + - Parameters [0] { + } + - Return [ Decimal\Number ] + } + + Method [ public method isEven ] { - Parameters [0] { } - Return [ bool ] } - Method [ public method isOdd ] { + Method [ public method isOdd ] { - Parameters [0] { } - Return [ bool ] } - Method [ public method isPositive ] { + Method [ public method isPositive ] { - Parameters [0] { } - Return [ bool ] } - Method [ public method isNegative ] { + Method [ public method isNegative ] { - Parameters [0] { } - Return [ bool ] } - Method [ public method isNaN ] { + Method [ public method isNaN ] { - Parameters [0] { } - Return [ bool ] } - Method [ public method isInf ] { + Method [ public method isInf ] { - Parameters [0] { } - Return [ bool ] } - Method [ public method isInteger ] { + Method [ public method isInteger ] { - Parameters [0] { } - Return [ bool ] } - Method [ public method isZero ] { + Method [ public method isZero ] { - Parameters [0] { } - Return [ bool ] } - Method [ public method toFixed ] { + Method [ public method toFixed ] { - Parameters [3] { Parameter #0 [ int or NULL $places ] Parameter #1 [ bool or NULL $commas ] - Parameter #2 [ int or NULL $rounding ] + Parameter #2 [ int or NULL $mode ] + } + - Return [ string ] + } + + Method [ public method toSci ] { + + - Parameters [1] { + Parameter #0 [ int or NULL $precision ] } - Return [ string ] } - Method [ public method toString ] { + Method [ public method toString ] { - Parameters [0] { } - Return [ string ] } - Method [ public method toInt ] { + Method [ public method toInt ] { - Parameters [0] { } - Return [ int ] } - Method [ public method toFloat ] { + Method [ public method toFloat ] { - Parameters [0] { } - Return [ float ] } - Method [ public method equals ] { + Method [ public method toDecimal ] { - Parameters [1] { - Parameter #0 [ $other ] + Parameter #0 [ int $precision ] } - - Return [ bool ] + - Return [ Decimal\Decimal ] } - Method [ public method compareTo ] { + Method [ public method toRational ] { + + - Parameters [0] { + } + - Return [ Decimal\Rational ] + } + + Method [ public method compareTo ] { - Parameters [1] { Parameter #0 [ $other ] @@ -328,23 +924,32 @@ Extension [ extension #109 decimal version 1.3.1 ] { - Return [ int ] } - Method [ public method between ] { + Method [ public method between ] { - - Parameters [2] { + - Parameters [3] { + Parameter #0 [ $a ] + Parameter #1 [ $b ] + Parameter #2 [ bool or NULL $inclusive ] + } + - Return [ bool ] + } + + Method [ public method equals ] { + + - Parameters [1] { Parameter #0 [ $other ] - Parameter #1 [ $other ] } - Return [ bool ] } - Method [ public method __toString ] { + Method [ public method __toString ] { - Parameters [0] { } - Return [ string ] } - Method [ public method jsonSerialize ] { + Method [ public method jsonSerialize ] { - Parameters [0] { } diff --git a/php-pecl-decimal.spec b/php-pecl-decimal.spec index d289100..d084c77 100644 --- a/php-pecl-decimal.spec +++ b/php-pecl-decimal.spec @@ -15,7 +15,8 @@ %scl_package php-pecl-decimal %endif -%global with_zts 0%{!?_without_zts:%{?__ztsphp:1}} +# see https://github.com/php-decimal/ext-decimal/issues/35 +%global with_zts 0 %global with_tests 0%{!?_without_tests:1} %global pecl_name decimal # After 20-json.ini @@ -23,14 +24,17 @@ Summary: Arbitrary-precision floating-point decimal Name: %{?sub_prefix}php-pecl-%{pecl_name} -Version: 1.3.1 +Version: 2.0.0 Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: MIT URL: https://pecl.php.net/package/%{pecl_name} Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz +Source1: https://raw.githubusercontent.com/php-decimal/ext-decimal/42bfd98e8742c6321b9b58eedeebc3de13eede99/tests/Number/helpers/Number.php +Patch0: https://patch-diff.githubusercontent.com/raw/php-decimal/ext-decimal/pull/34.patch + BuildRequires: %{?dtsprefix}gcc -BuildRequires: %{?scl_prefix}php-devel > 7 +BuildRequires: %{?scl_prefix}php-devel > 7.2 BuildRequires: %{?scl_prefix}php-pear BuildRequires: %{?scl_prefix}php-json BuildRequires: mpdecimal-devel @@ -92,6 +96,10 @@ sed -e 's/role="test"/role="src"/' \ mv %{pecl_name}-%{version} NTS cd NTS +mkdir tests/Number/helpers +cp %{SOURCE1} tests/Number/helpers/Number.php +%patch0 -p1 -b .pr34 + # Sanity check, really often broken extver=$(sed -n '/#define PHP_DECIMAL_VERSION/{s/.* "//;s/".*$//;p}' php_decimal.h) if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then @@ -228,6 +236,14 @@ REPORT_EXIT_STATUS=1 \ %changelog +* Tue Feb 4 2020 Remi Collet - 2.0.0-1 +- update to 2.0.0 (alpha) +- raise dependency on PHP 7.2 +- fix undefined symbol using patch from + https://github.com/php-decimal/ext-decimal/pull/34 +- disable ZTS build which segfaults, reported as + https://github.com/php-decimal/ext-decimal/issues/35 + * Tue Feb 4 2020 Remi Collet - 1.3.1-1 - update to 1.3.1 - drop patch merged upstream -- cgit