forked from JetBrains/phpstorm-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
decimal.php
440 lines (391 loc) · 11.7 KB
/
decimal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<?php
namespace Decimal {
use ArithmeticError;
use DivisionByZeroError;
use Traversable;
use TypeError;
class Decimal {
public const ROUND_UP = 101;
public const ROUND_DOWN = 102;
public const ROUND_CEILING = 103;
public const ROUND_FLOOR = 104;
public const ROUND_HALF_UP = 105;
public const ROUND_HALF_DOWN = 106;
public const ROUND_HALF_EVEN = 107;
public const ROUND_HALF_ODD = 108;
public const ROUND_TRUNCATE = 109;
public const DEFAULT_PRECISION = 28;
public const DEFAULT_ROUNDING = 107;
public const MIN_PRECISION = 1;
/**
* 425000000 for 32 bits systems
* 999999999999999999 for 64 bits systems
*/
public const MAX_PRECISION = 999999999999999999;
/**
* @param string $value
* @param int $precision
*/
public function __construct(string $value, int $precision = self::DEFAULT_PRECISION) { }
/**
* This method is equivalent to the + operator
*
* @param Decimal|string|int $value
*
* @return Decimal
*
* @throws TypeError
*
* @link https://php-decimal.io/#add
*/
public function add($value): Decimal { }
/**
* This method is equivalent to the - operator
*
* @param Decimal|string|int $value
*
* @return Decimal
*
* @throws TypeError
*
* @link https://php-decimal.io/#sub
*/
public function sub($value): Decimal { }
/**
* This method is equivalent to the * operator
*
* @param Decimal|string|int $value
*
* @return Decimal
*
* @throws TypeError
*
* @link https://php-decimal.io/#mul
*/
public function mul($value): Decimal { }
/**
* This method is equivalent to the / operator
*
* @param Decimal|string|int $value
*
* @return Decimal
*
* @throws TypeError
*
* @link https://php-decimal.io/#div
*/
public function div($value): Decimal { }
/**
* This method is equivalent to the % operator
*
* @param Decimal|string|int $value
*
* @return Decimal
*
* @throws TypeError
* @throws DivisionByZeroError
* @throws ArithmeticError
*
* @link https://php-decimal.io/#mod
*/
public function mod($value): Decimal { }
/**
* This method is equivalent to the ** operator
*
* @param Decimal|string|int $value
*
* @return Decimal
*
* @throws TypeError
*
* @link https://php-decimal.io/#pow
*/
public function pow($value): Decimal { }
/**
* @param Decimal|string|int $value
*
* @return Decimal
*
* @throws TypeError
* @throws DivisionByZeroError
* @throws ArithmeticError
*
* @link https://php-decimal.io/#rem
*/
public function rem($value): Decimal { }
/**
* This method is equivalent in function to PHP's log
*
* @return Decimal
*
* @link https://php-decimal.io/#ln
*/
public function ln(): Decimal { }
/**
* @return Decimal
*
* @link https://php-decimal.io/#exp
*/
public function exp(): Decimal { }
/**
* @return Decimal
*
* @link https://php-decimal.io/#log10
*/
public function log10(): Decimal { }
/**
* @return Decimal
*
* @link https://php-decimal.io/#sqrt
*/
public function sqrt(): Decimal { }
/**
* Returns the value of this decimal with the same precision
*
* Rounded according to the specified number of decimal places and rounding mode
*
* @param int $places
* @param int $mode
*
* @return Decimal
*
* @link https://php-decimal.io/#round
*/
public function round(int $places = 0, int $mode = Decimal::ROUND_HALF_EVEN): Decimal { }
/**
* Returns the closest integer towards negative infinity
*
* @return Decimal
*
* @link https://php-decimal.io/#floor
*/
public function floor(): Decimal { }
/**
* Returns the closest integer towards positive infinity
*
* @return Decimal
*
* @link https://php-decimal.io/#ceil
*/
public function ceil(): Decimal { }
/**
* Returns the result of discarding all digits behind the decimal point
*
* @return Decimal
*
* @link https://php-decimal.io/#truncate
*/
public function truncate(): Decimal { }
/**
* Returns a copy of this decimal with its decimal place shifted
*
* @return Decimal
*
* @link https://php-decimal.io/#shift
*/
public function shift(): Decimal { }
/**
* @since 1.1.0
*
* Returns a copy of this decimal without trailing zeroes
*
* @return Decimal
*
* @link https://php-decimal.io/#trim
*/
public function trim(): Decimal { }
/**
* Returns the precision of this decimal
*
* @return int
*
* @link https://php-decimal.io/#precision
*/
public function precision(): int { }
/**
* Returns 0 if zero, -1 if negative, or 1 if positive
*
* @return int
*
* @link https://php-decimal.io/#signum
*/
public function signum(): int { }
/**
* Returns 0 if the integer value of this decimal is even, 1 if odd. Special numbers like NAN and INF will return 1
*
* @return int
*
* @link https://php-decimal.io/#parity
*/
public function parity(): int { }
/**
* Returns the absolute (positive) value of this decimal
*
* @return Decimal
*
* @link https://php-decimal.io/#abs
*/
public function abs(): Decimal { }
/**
* Returns the same value as this decimal, but the sign inverted
*
* @return Decimal
*
* @link https://php-decimal.io/#negate
*/
public function negate(): Decimal { }
/**
* @return bool
*
* @link https://php-decimal.io/#isEven
*/
public function isEven(): bool { }
/**
* @return bool
*
* @link https://php-decimal.io/#isOdd
*/
public function isOdd(): bool { }
/**
* @return bool
*
* @link https://php-decimal.io/#isPositive
*/
public function isPositive(): bool { }
/**
* @return bool
*
* @link https://php-decimal.io/#isNegative
*/
public function isNegative(): bool { }
/**
* @return bool
*
* @link https://php-decimal.io/#isNan
*/
public function isNaN(): bool { }
/**
* @return bool
*
* @link https://php-decimal.io/#isInf
*/
public function isInf(): bool { }
/**
* @return bool
*
* @link https://php-decimal.io/#isInteger
*/
public function isInteger(): bool { }
/**
* @return bool
*
* @link https://php-decimal.io/#isZero
*/
public function isZero(): bool { }
/**
* Returns the value of this decimal formatted to a fixed number of decimal places, with thousands comma-separated, using a given rounding mode.
*
* @param int $places
* @param bool $commas
* @param int $mode
*
* @return Decimal
*
* @link https://php-decimal.io/#toFixed
*/
public function toFixed(int $places = 0, bool $commas = false, int $mode = Decimal::ROUND_HALF_EVEN): Decimal { }
/**
* Returns the value of this decimal represented exactly, in either fixed or scientific form, depending on the value
*
* @return string
*/
public function __toString(): string { }
/**
* This method is equivalent to a cast to string
*
* Returns the value of this decimal represented exactly, in either fixed or scientific form, depending on the value
*
* @return string
*/
public function toString(): string { }
/**
* JSON conversions will automatically convert the decimal to string using all signficant figures
*
* @return string
*/
public function jsonSerialize(): string { }
/**
* @return int
*/
public function toInt(): int { }
/**
* @return float
*/
public function toFloat(): float { }
/**
* @return Decimal
*/
public function copy(): Decimal { }
/**
* This method is equivalent to the == operator.
*
* @param mixed $value
*
* @return bool TRUE if this decimal is considered equal to the given value.
*
* @link https://php-decimal.io/#equals
*/
public function equals($value): bool { }
/**
* This method is equivalent to the <=> operator.
*
* Returns 0 if this decimal is considered equal to $other,
* -1 if this decimal should be placed before $other,
* 1 if this decimal should be placed after $other.
*
* @param $value
*
* @return int
*
* @link https://php-decimal.io/#compareTo
*/
public function compareTo($value): int { }
/**
* Returns TRUE if the value is between the two operands
*
* @param Decimam|string|int $value
* @param Decimam|string|int $leftOp
* @param Decimam|string|int $rightOp
*
* @return bool
*/
public function between($value, $leftOp, $rightOp): bool { }
/**
* Returns the sum of all given values
*
* The precision of the result will be the max of all precisions that were encountered during the calculation.
* The given precision should therefore be considered the minimum precision of the result.
* This method is equivalent to adding each value individually
*
* @param array|Traversable $values
*
* @return Decimal
*
* @link https://php-decimal.io/#sum
*/
public function sum(array $values): Decimal { }
/**
* Returns the average of all given values
*
* The precision of the result will be the max of all precisions that were encountered during the calculation.
* The given precision should therefore be considered the minimum precision of the result.
* This method is equivalent to adding each value individually, then dividing by the number of values
* @param array $values
*
* @return Decimal
*
* @link https://php-decimal.io/#avg
*/
public function avg(array $values): Decimal { }
}
}