1--TEST--
2BcMath\Number calc methods (add, sub, mul, div, mod, pow) num arg error
3--EXTENSIONS--
4bcmath
5--FILE--
6<?php
7$args = [
8    ['a', 'non number str'],
9    [[], 'array'],
10    [new stdClass(), 'other object'],
11    [0.1, 'float'],
12    [null, 'null'],
13];
14
15$methods = [
16    'add',
17    'sub',
18    'mul',
19    'div',
20    'mod',
21    'pow',
22];
23
24$num = new BcMath\Number('100.0000');
25foreach ($methods as $method) {
26    echo "========== {$method} ==========\n";
27    foreach ($args as [$val, $type]) {
28        echo "{$type}:\n";
29        try {
30            $num->$method($val);
31        } catch (Error $e) {
32            echo $e->getMessage() . "\n";
33        }
34    }
35    echo "\n";
36}
37?>
38--EXPECTF--
39========== add ==========
40non number str:
41BcMath\Number::add(): Argument #1 ($num) is not well-formed
42array:
43BcMath\Number::add(): Argument #1 ($num) must be of type int, string, or BcMath\Number, array given
44other object:
45BcMath\Number::add(): Argument #1 ($num) must be of type int, string, or BcMath\Number, stdClass given
46float:
47
48Deprecated: Implicit conversion from float 0.1 to int loses precision in %s
49null:
50
51Deprecated: BcMath\Number::add(): Passing null to parameter #1 ($num) of type BcMath\Number|string|int is deprecated in %s
52
53========== sub ==========
54non number str:
55BcMath\Number::sub(): Argument #1 ($num) is not well-formed
56array:
57BcMath\Number::sub(): Argument #1 ($num) must be of type int, string, or BcMath\Number, array given
58other object:
59BcMath\Number::sub(): Argument #1 ($num) must be of type int, string, or BcMath\Number, stdClass given
60float:
61
62Deprecated: Implicit conversion from float 0.1 to int loses precision in %s
63null:
64
65Deprecated: BcMath\Number::sub(): Passing null to parameter #1 ($num) of type BcMath\Number|string|int is deprecated in %s
66
67========== mul ==========
68non number str:
69BcMath\Number::mul(): Argument #1 ($num) is not well-formed
70array:
71BcMath\Number::mul(): Argument #1 ($num) must be of type int, string, or BcMath\Number, array given
72other object:
73BcMath\Number::mul(): Argument #1 ($num) must be of type int, string, or BcMath\Number, stdClass given
74float:
75
76Deprecated: Implicit conversion from float 0.1 to int loses precision in %s
77null:
78
79Deprecated: BcMath\Number::mul(): Passing null to parameter #1 ($num) of type BcMath\Number|string|int is deprecated in %s
80
81========== div ==========
82non number str:
83BcMath\Number::div(): Argument #1 ($num) is not well-formed
84array:
85BcMath\Number::div(): Argument #1 ($num) must be of type int, string, or BcMath\Number, array given
86other object:
87BcMath\Number::div(): Argument #1 ($num) must be of type int, string, or BcMath\Number, stdClass given
88float:
89
90Deprecated: Implicit conversion from float 0.1 to int loses precision in %s
91Division by zero
92null:
93
94Deprecated: BcMath\Number::div(): Passing null to parameter #1 ($num) of type BcMath\Number|string|int is deprecated in %s
95Division by zero
96
97========== mod ==========
98non number str:
99BcMath\Number::mod(): Argument #1 ($num) is not well-formed
100array:
101BcMath\Number::mod(): Argument #1 ($num) must be of type int, string, or BcMath\Number, array given
102other object:
103BcMath\Number::mod(): Argument #1 ($num) must be of type int, string, or BcMath\Number, stdClass given
104float:
105
106Deprecated: Implicit conversion from float 0.1 to int loses precision in %s
107Modulo by zero
108null:
109
110Deprecated: BcMath\Number::mod(): Passing null to parameter #1 ($num) of type BcMath\Number|string|int is deprecated in %s
111Modulo by zero
112
113========== pow ==========
114non number str:
115BcMath\Number::pow(): Argument #1 ($exponent) is not well-formed
116array:
117BcMath\Number::pow(): Argument #1 ($exponent) must be of type int, string, or BcMath\Number, array given
118other object:
119BcMath\Number::pow(): Argument #1 ($exponent) must be of type int, string, or BcMath\Number, stdClass given
120float:
121
122Deprecated: Implicit conversion from float 0.1 to int loses precision in %s
123null:
124
125Deprecated: BcMath\Number::pow(): Passing null to parameter #1 ($exponent) of type BcMath\Number|string|int is deprecated in %s
126