Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Warning: Decimal\Decimal::__construct() expects exactly 1 parameter, 2 #42

Open
vishalmelmatti opened this issue Apr 7, 2020 · 2 comments

Comments

@vishalmelmatti
Copy link

vishalmelmatti commented Apr 7, 2020

HI,
I am trying to use this extension on PHP 7.2.26 and Alpine 3.8 docker image.

use Decimal\Decimal;

$a = new Decimal("1", 2);
$b = new Decimal("7", 8);

print_r($a / $b);

This example code from documentation https://php-decimal.io/#basic-usage gives error

PHP Warning: Decimal\Decimal::__construct() expects exactly 1 parameter, 2 given in /app/public/index1.php on line 8 PHP Warning: Decimal\Decimal::__construct() expects exactly 1 parameter, 2 given in /app/public/index1.php on line 9 Assertion failed: dec->len > 0 (mpdecimal.c: mpd_msword: 216)

Trace:
`[New LWP 124]
[New LWP 125]
[New LWP 126]
Assertion failed: dec->len > 0 (mpdecimal.c: mpd_msword: 216)

Thread 1 "php" received signal SIGABRT, Aborted.
0x00007ffff7db2f1b in __restore_sigs () from /lib/ld-musl-x86_64.so.1
(gdb) bt
#0 0x00007ffff7db2f1b in __restore_sigs () from /lib/ld-musl-x86_64.so.1
#1 0x00007ffff7db3035 in raise () from /lib/ld-musl-x86_64.so.1
#2 0x0000000000000000 in ?? ()
`

Without 2nd parameter

use Decimal\Decimal;

$a = new Decimal("1");
$b = new Decimal("7");

print_r($a / $b);`

gives this error

Assertion failed: dec->len > 0 (mpdecimal.c: mpd_msword: 216)

@vishalmelmatti
Copy link
Author

Any inputs on above please ? These are the versions installed & in phpinfo.

decimal support | enabled
decimal version | 1.3.1
libmpdec version | 2.4.2

@rtheunissen
Copy link
Contributor

@vishalmelmatti Do your tests pass when you build this project and run make test? The __construct tests clearly test passing zero, one or two arguments. Therefore, I am at a loss how Decimal\Decimal::__construct() expects exactly 1 parameter, 2 given can be possible.

If you could share a Dockerfile that demonstrates this bug I will be happy to look closer. In the meantime, I will focus on more recent issues and release maintenance. I apologize for not coming back to this sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants